mirror of
https://github.com/jupyter/notebook.git
synced 2025-01-24 12:05:22 +08:00
Fixing casperjs tests to run on casperjs 1.0.x.
This commit is contained in:
parent
717f031e01
commit
6ac7f6c2b4
@ -1,7 +1,4 @@
|
||||
casper.wait_for_list = function () {
|
||||
casper.waitForSelector('.list_item');
|
||||
// casper.wait(500);
|
||||
}
|
||||
|
||||
|
||||
casper.get_list_items = function () {
|
||||
return this.evaluate(function () {
|
||||
@ -14,7 +11,7 @@ casper.get_list_items = function () {
|
||||
});
|
||||
}
|
||||
|
||||
casper.test_items = function (test, baseUrl) {
|
||||
casper.test_items = function (baseUrl) {
|
||||
casper.then(function () {
|
||||
var items = casper.get_list_items();
|
||||
casper.each(items, function (self, item) {
|
||||
@ -22,9 +19,9 @@ casper.test_items = function (test, baseUrl) {
|
||||
var followed_url = baseUrl+item.link;
|
||||
if (!followed_url.match('/\.\.$')) {
|
||||
casper.thenOpen(baseUrl+item.link, function () {
|
||||
casper.wait_for_list();
|
||||
test.assertEquals(this.getCurrentUrl(), followed_url, 'Testing dashboard link: '+followed_url);
|
||||
casper.test_items(test, baseUrl);
|
||||
casper.wait_for_dashboard();
|
||||
this.test.assertEquals(this.getCurrentUrl(), followed_url, 'Testing dashboard link: '+followed_url);
|
||||
casper.test_items(baseUrl);
|
||||
this.back();
|
||||
});
|
||||
}
|
||||
@ -33,13 +30,8 @@ casper.test_items = function (test, baseUrl) {
|
||||
});
|
||||
}
|
||||
|
||||
casper.test.begin('Testing dashboard navigation', function (test) {
|
||||
var baseUrl = casper.get_notebook_server();
|
||||
casper.start(baseUrl);
|
||||
casper.echo(baseUrl);
|
||||
casper.wait_for_list();
|
||||
casper.test_items(test, baseUrl);
|
||||
casper.run(function() {
|
||||
test.done();
|
||||
});
|
||||
});
|
||||
casper.dashboard_test(function () {
|
||||
baseUrl = this.get_notebook_server()
|
||||
casper.test_items(baseUrl);
|
||||
})
|
||||
|
||||
|
@ -250,6 +250,34 @@ casper.notebook_test = function(test) {
|
||||
});
|
||||
};
|
||||
|
||||
casper.wait_for_dashboard = function () {
|
||||
// Wait for the dashboard list to load.
|
||||
casper.waitForSelector('.list_item');
|
||||
}
|
||||
|
||||
casper.open_dashboard = function () {
|
||||
// Start casper by opening the dashboard page.
|
||||
var baseUrl = this.get_notebook_server();
|
||||
this.start(baseUrl);
|
||||
this.wait_for_dashboard();
|
||||
}
|
||||
|
||||
casper.dashboard_test = function (test) {
|
||||
// Open the dashboard page and run a test.
|
||||
this.open_dashboard();
|
||||
this.then(test);
|
||||
|
||||
this.then(function () {
|
||||
this.page.close();
|
||||
this.page = null;
|
||||
});
|
||||
|
||||
// Run the browser automation.
|
||||
this.run(function() {
|
||||
this.test.done();
|
||||
});
|
||||
}
|
||||
|
||||
casper.options.waitTimeout=10000
|
||||
casper.on('waitFor.timeout', function onWaitForTimeout(timeout) {
|
||||
this.echo("Timeout for " + casper.get_notebook_server());
|
||||
|
Loading…
Reference in New Issue
Block a user