This repository has been archived by the owner on Sep 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(c) Copyright IBM Corp. 2016
- Loading branch information
Showing
4 changed files
with
242 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Copyright (c) Jupyter Development Team. | ||
// Distributed under the terms of the Modified BSD License. | ||
|
||
var wd = require('wd'); | ||
var chai = require('chai'); | ||
var Boilerplate = require('./utils/boilerplate'); | ||
var boilerplate = new Boilerplate(); | ||
|
||
describe('Urth Viz Explorer Test', function() { | ||
|
||
var tagChaiAssertionError = function(err) { | ||
// throw error and tag as retriable to poll again | ||
err.retriable = err instanceof chai.AssertionError; | ||
throw err; | ||
}; | ||
|
||
wd.PromiseChainWebdriver.prototype.waitForWidgetElement = function(selector, browserSupportsShadowDOM, timeout, pollFreq) { | ||
return this.waitForElementByCssSelector( | ||
browserSupportsShadowDOM ? 'urth-viz-explorer::shadow urth-viz-vega::shadow svg' : 'urth-viz-explorer urth-viz-vega svg', | ||
wd.asserters.isDisplayed, | ||
timeout) | ||
.catch(tagChaiAssertionError); | ||
}; | ||
|
||
boilerplate.setup(this.title, '/notebooks/examples/urth-viz-explorer.ipynb'); | ||
|
||
it('should run all cells and find an explorer in the 5th output area', function(done) { | ||
boilerplate.browser | ||
.waitForElementsByCssSelector('div.output_area').nth(5) | ||
.waitForWidgetElement("urth-viz-explorer", boilerplate.browserSupportsShadowDOM, 10000) | ||
.nodeify(done); | ||
}); | ||
|
||
it('should have 20 items plotted, by default, then 10 after setting the limit accordingly', function(done) { | ||
boilerplate.browser | ||
.waitForElementsByCssSelector('div.output_area').nth(7) | ||
.moveTo() | ||
.waitForElementsByCssSelector('urth-viz-explorer#v1::shadow urth-viz-vega::shadow svg .marks *', wd.asserters.isDisplayed, 10000) | ||
.should.be.eventually.length(20) | ||
.waitForElementByCssSelector('urth-viz-explorer#v1::shadow #viz-explorer-controls .viz-explorer-controls-section paper-input[label=Limit]::shadow paper-input-container #input', wd.asserters.isDisplayed, 10000) | ||
.click() | ||
.doubleclick() | ||
.type('10') | ||
.sleep(1000) | ||
.elementsByCssSelector('urth-viz-explorer#v1::shadow urth-viz-vega::shadow svg .marks *') | ||
.should.be.eventually.length(10) | ||
.nodeify(done); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
// Copyright (c) Jupyter Development Team. | ||
// Distributed under the terms of the Modified BSD License. | ||
|
||
var wd = require('wd'); | ||
require('colors'); | ||
var chai = require('chai'); | ||
var chaiAsPromised = require('chai-as-promised'); | ||
var parseArgs = require('minimist'); | ||
|
||
// Parse the args | ||
var args = parseArgs(process.argv); | ||
args.local = args['test-type'] === 'local'; | ||
var remote = !args.local; | ||
args.server = args.server || (remote ? 'ondemand.saucelabs.com' : 'localhost:4444'); | ||
|
||
// Setup chai | ||
chai.use(chaiAsPromised); | ||
chai.should(); | ||
chaiAsPromised.transferPromiseness = wd.transferPromiseness; | ||
|
||
// Configure webdriver | ||
wd.configureHttp({ | ||
timeout: 60000, | ||
retryDelay: 15000, | ||
retries: 5, | ||
baseUrl: args.baseurl | ||
}); | ||
|
||
// The browser capabilities we would like setup by selenium | ||
var desired = {browserName: 'chrome', platform: 'OS X 10.10'}; | ||
if (args.browser && args.browser === 'InternetExplorer') { | ||
args.browser = 'internet explorer'; | ||
} | ||
desired.browserName = args.browser || desired.browserName; | ||
desired.platform = args.platform || | ||
(desired.browserName === 'internet explorer' || desired.browserName === 'MicrosoftEdge') ? | ||
'Windows 10': desired.platform; | ||
desired.tags = ['widgets', 'system-test', desired.browserName]; | ||
// If there is a build number, include it in the desired attributes for sauce labs | ||
if (process.env.TRAVIS_JOB_NUMBER) { | ||
desired.tunnelIdentifier = process.env.TRAVIS_JOB_NUMBER; | ||
desired.build = 'widgets-build-' + process.env.TRAVIS_JOB_NUMBER; | ||
} | ||
|
||
// The selenium test server, local or remote, we will be using to test against | ||
var testServer = 'http://' + args.server + '/wd/hub'; | ||
if (remote) { | ||
testServer = 'http://' + process.env.SAUCE_USERNAME + ':' + process.env.SAUCE_ACCESS_KEY + '@' + args.server + '/wd/hub'; | ||
} | ||
|
||
console.log('Test server is ', args.server); | ||
console.log('Travis job number is: ', process.env.TRAVIS_JOB_NUMBER); | ||
console.log('Sauce user name is defined? ', !!process.env.SAUCE_USERNAME); | ||
console.log('Sauce access key is defined? ', !!process.env.SAUCE_ACCESS_KEY); | ||
|
||
/** | ||
* A helper class to setup webdriver, create a browser, and widget objects for | ||
* use within the system tests. | ||
*/ | ||
var Boilerplate = function(){ | ||
this.browser = wd.promiseChainRemote(testServer); | ||
this.allPassed = true; | ||
this.SPECIAL_KEYS = wd.SPECIAL_KEYS; | ||
}; | ||
|
||
/** | ||
* Setups the before and after calls for each of your tests. The boilerplate | ||
* will start each test on startingURL, which is a relative path to the resource to load. | ||
*/ | ||
Boilerplate.prototype.setup = function(testName, startingURL){ | ||
var that = this; | ||
|
||
before(function(done){ | ||
if (args.verbose) { | ||
// optional logging | ||
this.browser.on('status', function(info) { | ||
console.log(info.cyan); | ||
}); | ||
this.browser.on('command', function(meth, path, data) { | ||
console.log(' > ' + meth.yellow, path.grey, data || ''); | ||
}); | ||
} | ||
|
||
desired.name = testName ? 'Urth Widgets System Test - ' + testName | ||
: 'Urth Widgets System Test'; | ||
|
||
this.browser.init(desired) | ||
.get(startingURL || '/') | ||
.waitForElementByCssSelector('#kernel_indicator_icon.kernel_idle_icon', wd.asserters.isDisplayed, 10000) | ||
.waitForElementByLinkText('Cell', wd.asserters.isDisplayed, 10000) | ||
.safeExecute('localStorage.clear()') | ||
.elementByLinkText('Cell') | ||
.click() | ||
.waitForElementByLinkText('Run All', wd.asserters.isDisplayed, 10000) | ||
.elementByLinkText('Run All') | ||
.click() | ||
.eval('!!document.body.createShadowRoot', function(err, value) { | ||
this.browserSupportsShadowDOM = value; | ||
}.bind(this)) | ||
.waitForElementByCssSelector('div.output_area', wd.asserters.isDisplayed, 10000) | ||
.setAsyncScriptTimeout(15000) | ||
.waitForConditionInBrowser('window.Urth && Urth.kernel && Urth.kernel.is_connected()', 10000) | ||
.waitForElementByCssSelector('#kernel_indicator_icon.kernel_idle_icon', wd.asserters.isDisplayed, 20000) | ||
.waitForConditionInBrowser('typeof Urth.whenReady === "function"', 10000) | ||
.nodeify(done); | ||
}.bind(this)); | ||
|
||
after(function(done){ | ||
var result = this.browser.quit(); | ||
if (remote) { | ||
result = result.sauceJobStatus(this.allPassed); | ||
} | ||
result.nodeify(done); | ||
}.bind(this)); | ||
|
||
afterEach(function(done) { | ||
that.allPassed = that.allPassed && (this.currentTest.state === 'passed'); | ||
done(); | ||
}); | ||
}; | ||
|
||
module.exports = Boilerplate; |