Skip to content
This repository was archived by the owner on Sep 1, 2022. It is now read-only.

Commit aa048a3

Browse files
committed
Run Scala/R only in chrome & run all cells with output count asserter
(c) Copyright IBM Corp. 2016
1 parent eb6070b commit aa048a3

8 files changed

+104
-111
lines changed

Makefile

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,11 @@ BROWSER_LIST?=chrome
4141
ALT_BROWSER_LIST?=chrome
4242
BASEURL?=http://192.168.99.100:9500
4343
TEST_TYPE?=local
44-
SPECS?=system-test/*-specs.js
44+
SPECS?=system-test/urth-system-test-specs.js system-test/urth-core-bind-specs.js system-test/urth-viz-table-specs.js
4545
PYTHON2_SPECS?=system-test/urth-system-test-specs.js
46-
ALT_JUPYTER_SPECS?=system-test/urth-system-test-specs.js system-test/urth-r-widgets-specs.js
46+
ALT_JUPYTER_SPECS?=system-test/urth-system-test-specs.js
47+
R_SPECS?=system-test/urth-r-widgets-specs.js
48+
SCALA_SPECS?=system-test/urth-scala-widgets-specs.js
4749
ALT_JUPYTER_VERSION?=4.2
4850
PYTHON?=python3
4951
TEST_MSG?="Starting system tests"
@@ -394,7 +396,17 @@ system-test-alt-jupyter: TEST_MSG="Starting system tests for Jupyter $(ALT_JUPYT
394396
system-test-alt-jupyter:
395397
@TEST_MSG=$(TEST_MSG) TEST_TYPE=$(TEST_TYPE) BROWSER_LIST="$(ALT_BROWSER_LIST)" JUPYTER=$(JUPYTER) SPECS="$(SPECS)" BASEURL=$(BASEURL) $(MAKE) run-test
396398

397-
system-test-all: system-test-python3 system-test-python2 system-test-alt-jupyter
399+
system-test-scala: SPECS:=$(SCALA_SPECS)
400+
system-test-scala: TEST_MSG="Starting system tests for Scala"
401+
system-test-scala:
402+
@TEST_MSG=$(TEST_MSG) TEST_TYPE=$(TEST_TYPE) BROWSER_LIST="$(ALT_BROWSER_LIST)" JUPYTER=$(JUPYTER) SPECS="$(SPECS)" BASEURL=$(BASEURL) $(MAKE) run-test
403+
404+
system-test-r: SPECS:=$(R_SPECS)
405+
system-test-r: TEST_MSG="Starting system tests for R"
406+
system-test-r:
407+
@TEST_MSG=$(TEST_MSG) TEST_TYPE=$(TEST_TYPE) BROWSER_LIST="$(ALT_BROWSER_LIST)" JUPYTER=$(JUPYTER) SPECS="$(SPECS)" BASEURL=$(BASEURL) $(MAKE) run-test
408+
409+
system-test-all: system-test-python3 system-test-python2 system-test-alt-jupyter system-test-scala system-test-r
398410

399411
start-selenium: node_modules stop-selenium
400412
@echo "Installing and starting Selenium Server..."

etc/notebooks/tests/Walkthrough-Scala.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@
4444
"outputs": [],
4545
"source": [
4646
"// modify to IP and Port of this notebook server\n",
47-
"%addjar http://localhost:8888/nbextensions/urth_widgets/urth-widgets.jar"
47+
"%addjar http://localhost:8888/nbextensions/declarativewidgets/urth-widgets.jar"
4848
]
4949
},
5050
{
5151
"cell_type": "code",
5252
"execution_count": null,
5353
"metadata": {
54-
"collapsed": true
54+
"collapsed": false
5555
},
5656
"outputs": [],
5757
"source": [

system-test/urth-core-bind-specs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ var boilerplate = new Boilerplate();
77

88
describe('Urth Core Bind', function() {
99

10-
boilerplate.setup(this.title, '/notebooks/tests/urth-core-bind.ipynb', 3);
10+
boilerplate.setup(this.title, '/notebooks/tests/urth-core-bind.ipynb', 4);
1111

1212
it('should wait for dependency to load', function(done) {
1313
// Using a random number to protect against the possibility of a previous

system-test/urth-r-widgets-specs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ var Boilerplate = require('./utils/boilerplate');
66
var boilerplate = new Boilerplate();
77

88
process.env.PYTHON != "python2" && describe('Widgets R System Test', function() {
9-
boilerplate.setup(this.title, '/notebooks/tests/urth-r-widgets.ipynb', 7);
9+
boilerplate.setup(this.title, '/notebooks/tests/urth-r-widgets.ipynb', 8);
1010

1111
it('should print the result of a Function Widget invocation', function(done) {
1212
boilerplate.browser
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
// Copyright (c) Jupyter Development Team.
2+
// Distributed under the terms of the Modified BSD License.
3+
4+
var wd = require('wd');
5+
var Boilerplate = require('./utils/boilerplate');
6+
var boilerplate = new Boilerplate();
7+
8+
process.env.PYTHON != "python2" && describe('Widgets Scala System Test', function() {
9+
boilerplate.setup(this.title, '/notebooks/tests/Walkthrough-Scala.ipynb', 11);
10+
11+
var timeout = 30000;
12+
13+
it('should print the correct variable that is used for urth-core-function', function(done) {
14+
15+
boilerplate.browser
16+
.elementsByCssSelector('div.code_cell').nth(5)
17+
.elementByXPath('//button[text()="invoke"]').click()
18+
.waitForElementById('test1', wd.asserters.textInclude('world'), timeout)
19+
.nodeify(done);
20+
});
21+
22+
it('should bind variable to channel a', function(done) {
23+
boilerplate.browser
24+
.elementsByCssSelector('div.code_cell').nth(6)
25+
.elementByCssSelector('>', 'input')
26+
.type('A')
27+
.waitForElementById('test2', wd.asserters.textInclude('A'), timeout)
28+
.nodeify(done);
29+
});
30+
31+
it('should bind variable to channel b', function(done) {
32+
boilerplate.browser
33+
.elementsByCssSelector('div.code_cell').nth(7)
34+
.elementByCssSelector('>', 'input')
35+
.type('B')
36+
.waitForElementById('test3', wd.asserters.textInclude('B'), timeout)
37+
.nodeify(done);
38+
});
39+
40+
it('should bind variables to channels independently', function(done) {
41+
boilerplate.browser
42+
.elementsByCssSelector('div.code_cell').nth(6)
43+
.elementByCssSelector('>', 'input')
44+
.type('2')
45+
.elementByCssSelector('#test2')
46+
.text().should.eventually.include('A2')
47+
.waitForElementById('test2', wd.asserters.textInclude('A2'), timeout)
48+
.waitForElementById('test3', wd.asserters.textInclude('B'), timeout)
49+
.nodeify(done);
50+
});
51+
52+
it('should watch for changes in a watched variable', function(done) {
53+
boilerplate.browser
54+
.elementByXPath('//button[text()="initChannelWatch"]').click()
55+
.elementsByCssSelector('div.code_cell').nth(8)
56+
.elementByCssSelector('>', 'input')
57+
.type('watched message')
58+
.waitForElementById('test4', wd.asserters.textInclude('watched message'), timeout)
59+
.nodeify(done);
60+
});
61+
62+
it('should update output when DataFrame is modified and set to auto', function(done) {
63+
boilerplate.browser
64+
.elementsByCssSelector('div.code_cell').nth(14)
65+
.waitForElementByClassName('test5', wd.asserters.textInclude('Richard Roe'), timeout)
66+
.nodeify(done);
67+
});
68+
});

system-test/urth-system-test-specs.js

Lines changed: 1 addition & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ var Boilerplate = require('./utils/boilerplate');
66
var boilerplate = new Boilerplate();
77

88
describe('Widgets Python System Test', function() {
9-
boilerplate.setup(this.title, '/notebooks/tests/Walkthrough.ipynb', 10);
9+
boilerplate.setup(this.title, '/notebooks/tests/Walkthrough.ipynb', 13);
1010

1111
it('should not execute Urth.whenReady API until components have upgraded', function(done) {
1212
boilerplate.browser
@@ -89,64 +89,3 @@ describe('Widgets Python System Test', function() {
8989
});
9090
});
9191

92-
process.env.PYTHON != "python2" && describe('Widgets Scala System Test', function() {
93-
boilerplate.setup(this.title, '/notebooks/tests/Walkthrough-Scala.ipynb', 10);
94-
95-
var timeout = 30000;
96-
97-
it('should print the correct variable that is used for urth-core-function', function(done) {
98-
99-
boilerplate.browser
100-
.elementsByCssSelector('div.code_cell').nth(5)
101-
.elementByXPath('//button[text()="invoke"]').click()
102-
.waitForElementById('test1', wd.asserters.textInclude('world'), timeout)
103-
.nodeify(done);
104-
});
105-
106-
it('should bind variable to channel a', function(done) {
107-
boilerplate.browser
108-
.elementsByCssSelector('div.code_cell').nth(6)
109-
.elementByCssSelector('>', 'input')
110-
.type('A')
111-
.waitForElementById('test2', wd.asserters.textInclude('A'), timeout)
112-
.nodeify(done);
113-
});
114-
115-
it('should bind variable to channel b', function(done) {
116-
boilerplate.browser
117-
.elementsByCssSelector('div.code_cell').nth(7)
118-
.elementByCssSelector('>', 'input')
119-
.type('B')
120-
.waitForElementById('test3', wd.asserters.textInclude('B'), timeout)
121-
.nodeify(done);
122-
});
123-
124-
it('should bind variables to channels independently', function(done) {
125-
boilerplate.browser
126-
.elementsByCssSelector('div.code_cell').nth(6)
127-
.elementByCssSelector('>', 'input')
128-
.type('2')
129-
.elementByCssSelector('#test2')
130-
.text().should.eventually.include('A2')
131-
.waitForElementById('test2', wd.asserters.textInclude('A2'), timeout)
132-
.waitForElementById('test3', wd.asserters.textInclude('B'), timeout)
133-
.nodeify(done);
134-
});
135-
136-
it('should watch for changes in a watched variable', function(done) {
137-
boilerplate.browser
138-
.elementByXPath('//button[text()="initChannelWatch"]').click()
139-
.elementsByCssSelector('div.code_cell').nth(8)
140-
.elementByCssSelector('>', 'input')
141-
.type('watched message')
142-
.waitForElementById('test4', wd.asserters.textInclude('watched message'), timeout)
143-
.nodeify(done);
144-
});
145-
146-
it('should update output when DataFrame is modified and set to auto', function(done) {
147-
boilerplate.browser
148-
.elementsByCssSelector('div.code_cell').nth(14)
149-
.waitForElementByClassName('test5', wd.asserters.textInclude('Richard Roe'), timeout)
150-
.nodeify(done);
151-
});
152-
});

system-test/urth-viz-table-specs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ describe('Urth Viz Table Test', function() {
2222
.catch(tagChaiAssertionError);
2323
};
2424

25-
boilerplate.setup(this.title, '/notebooks/tests/urth-viz-table.ipynb', 3);
25+
boilerplate.setup(this.title, '/notebooks/tests/urth-viz-table.ipynb', 4);
2626

2727
it('should run all cells and find a handsontable in the 3rd output area', function(done) {
2828
boilerplate.browser

system-test/utils/boilerplate.js

Lines changed: 15 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ Boilerplate.prototype.setup = function(testName, startingURL, outputCount){
8181
function(target) { // browser or el
8282
return target
8383
.elementsByCssSelector('div.output_area').then(function(nodes) {
84-
console.log("output areas visible: ", nodes.length, "/", outputCount)
84+
//console.log("output areas visible: ", nodes.length, "/", outputCount)
8585
nodes.should.have.length.above(outputCount-1);
8686
return target; // this will be returned by waitFor
8787
// and ignored by waitForElement.
@@ -104,51 +104,25 @@ Boilerplate.prototype.setup = function(testName, startingURL, outputCount){
104104
desired.name = testName ? 'Urth Widgets System Test - ' + testName
105105
: 'Urth Widgets System Test';
106106

107-
var kernelStartTimeout = 200000;
108-
var defaultTimeout = 10000;
109-
var runAllCompletionTimeout = 50000;
110-
111-
function clickTheElement(element) {
112-
return new Promise(function(resolve) {
113-
var newElement = element.click()
114-
.elementByLinkText("<", "Cell")
115-
.click()
116-
.waitForElementByLinkText("Run Cells", wd.asserters.isDisplayed, 10000)
117-
.elementByLinkText("Run Cells")
118-
.click()
119-
.sleep(5000);
120-
resolve(newElement);
121-
});
122-
}
123-
124-
function runAllCells(elements, idx) {
125-
if (idx > elements.length - 1) {
126-
return;
127-
}
128-
129-
var element = elements[idx];
130-
clickTheElement(element).then(function(elem) {
131-
console.log("running cell: ", idx);
132-
runAllCells(elements, idx+1);
133-
})
134-
}
135-
136107
this.browser.init(desired)
137108
.get(startingURL || '/')
138-
.waitForElementByCssSelector("#kernel_indicator_icon.kernel_idle_icon", wd.asserters.isDisplayed, kernelStartTimeout)
109+
.waitForElementByCssSelector('#kernel_indicator_icon.kernel_idle_icon', wd.asserters.isDisplayed, 80000)
110+
.waitForElementByLinkText('Cell', wd.asserters.isDisplayed, 10000)
139111
.safeExecute('localStorage.clear()')
140-
.waitForElementByCssSelector('div.output_area', wd.asserters.isDisplayed, defaultTimeout)
141-
.setAsyncScriptTimeout(15000)
142-
.waitForConditionInBrowser('window.Urth && Urth.kernel && Urth.kernel.is_connected()', defaultTimeout)
143-
.waitForElementByCssSelector('#kernel_indicator_icon.kernel_idle_icon', wd.asserters.isDisplayed, kernelStartTimeout)
144-
.waitForConditionInBrowser('typeof Urth.whenReady === "function"', kernelStartTimeout)
145-
.elementsByCssSelector('div.input').then(function (elements) {
146-
runAllCells(elements, 0);
147-
})
148-
.waitFor(outputAsserter, runAllCompletionTimeout*5, defaultTimeout)
149-
.eval("!!document.body.createShadowRoot", function(err, value) {
112+
.elementByLinkText('Cell')
113+
.click()
114+
.waitForElementByLinkText('Run All', wd.asserters.isDisplayed, 10000)
115+
.elementByLinkText('Run All')
116+
.click()
117+
.eval('!!document.body.createShadowRoot', function(err, value) {
150118
this.browserSupportsShadowDOM = value;
151119
}.bind(this))
120+
.waitForElementByCssSelector('div.output_area', wd.asserters.isDisplayed, 10000)
121+
.setAsyncScriptTimeout(15000)
122+
.waitForConditionInBrowser('window.Urth && Urth.kernel && Urth.kernel.is_connected()', 10000)
123+
.waitForElementByCssSelector('#kernel_indicator_icon.kernel_idle_icon', wd.asserters.isDisplayed, 20000)
124+
.waitForConditionInBrowser('typeof Urth.whenReady === "function"', 10000)
125+
.waitFor(outputAsserter, 250000, 1000)
152126
.nodeify(done);
153127
}.bind(this));
154128

0 commit comments

Comments
 (0)