Cleaning up settings functional tests

ref #1702

- All the tests need cleaning up a bit, but these ones are failing
  regularly and I'd like to get to the bottom of it.
This commit is contained in:
Hannah Wolfe 2014-05-08 08:44:48 +01:00
parent 1c3ba536c9
commit 896be9119f
2 changed files with 129 additions and 150 deletions

View File

@ -1,26 +1,26 @@
/*globals casper, __utils__, url */
/*globals casper, CasperTest, url */
CasperTest.begin("Settings screen is correct", 18, function suite(test) {
casper.thenOpen(url + "ghost/settings/", function testTitleAndUrl() {
test.assertTitle("Ghost Admin", "Ghost admin has no title");
test.assertUrlMatch(/ghost\/settings\/general\/$/, "Ghost doesn't require login this time");
CasperTest.begin('Settings screen is correct', 20, function suite(test) {
casper.thenOpen(url + 'ghost/settings/', function testTitleAndUrl() {
test.assertTitle('Ghost Admin', 'Ghost admin has no title');
test.assertUrlMatch(/ghost\/settings\/general\/$/, 'Ghost doesn\'t require login this time');
});
casper.then(function testViews() {
test.assertExists(".wrapper", "Settings main view is present");
test.assertExists(".settings-sidebar", "Settings sidebar view is present");
test.assertExists(".settings-menu", "Settings menu is present");
test.assertExists(".settings-menu .general", "General tab is present");
test.assertExists(".settings-menu .users", "Users tab is present");
test.assertExists(".settings-menu .apps", "Apps is present");
test.assertExists(".wrapper", "Settings main view is present");
test.assertExists(".settings-content", "Settings content view is present");
test.assertExists('.wrapper', 'Settings main view is present');
test.assertExists('.settings-sidebar', 'Settings sidebar view is present');
test.assertExists('.settings-menu', 'Settings menu is present');
test.assertExists('.settings-menu .general', 'General tab is present');
test.assertExists('.settings-menu .users', 'Users tab is present');
test.assertExists('.settings-menu .apps', 'Apps is present');
test.assertExists('.wrapper', 'Settings main view is present');
test.assertExists('.settings-content', 'Settings content view is present');
test.assertEval(function testGeneralIsActive() {
return document.querySelector('.settings-menu .general').classList.contains('active');
}, "general tab is marked active");
}, 'general tab is marked active');
test.assertEval(function testContentIsGeneral() {
return document.querySelector('.settings-content').id === 'general';
}, "loaded content is general screen");
}, 'loaded content is general screen');
});
// test the user tab
@ -28,28 +28,26 @@ CasperTest.begin("Settings screen is correct", 18, function suite(test) {
casper.waitForSelector('#user', function then() {
test.assertEval(function testGeneralIsNotActive() {
return !document.querySelector('.settings-menu .general').classList.contains('active');
}, "general tab is not marked active");
}, 'general tab is not marked active');
test.assertEval(function testUserIsActive() {
return document.querySelector('.settings-menu .users').classList.contains('active');
}, "user tab is marked active");
}, 'user tab is marked active');
test.assertEval(function testContentIsUser() {
return document.querySelector('.settings-content').id === 'user';
}, "loaded content is user screen");
}, function onTimeOut() {
test.fail('User screen failed to load');
});
}, 'loaded content is user screen');
}, casper.failOnTimeout(test, 'waitForSelector #user timed out'));
function handleUserRequest(requestData, request) {
function handleUserRequest(requestData) {
// make sure we only get requests from the user pane
if (requestData.url.indexOf('settings/') !== -1) {
test.fail("Saving the user pane triggered another settings pane to save");
test.fail('Saving the user pane triggered another settings pane to save');
}
}
function handleSettingsRequest(requestData, request) {
function handleSettingsRequest(requestData) {
// make sure we only get requests from the user pane
if (requestData.url.indexOf('users/') !== -1) {
test.fail("Saving a settings pane triggered the user pane to save");
test.fail('Saving a settings pane triggered the user pane to save');
}
}
@ -63,10 +61,8 @@ CasperTest.begin("Settings screen is correct", 18, function suite(test) {
return document.querySelectorAll('.js-bb-notification section').length > 0;
});
}, function doneWaiting() {
}, function waitTimeout() {
test.fail("Saving the user pane did not result in a notification");
});
test.pass('Waited for notification');
}, casper.failOnTimeout(test, 'Saving the user pane did not result in a notification'));
casper.then(function checkUserWasSaved() {
casper.removeListener('resource.requested', handleUserRequest);
@ -74,15 +70,13 @@ CasperTest.begin("Settings screen is correct", 18, function suite(test) {
casper.waitForSelector('.notification-success', function onSuccess() {
test.assert(true, 'Got success notification');
}, function onTimeout() {
test.assert(false, 'No success notification :(');
});
}, casper.failOnTimeout(test, 'No success notification :('));
casper.thenClick('#main-menu .settings a').then(function testOpeningSettingsTwice() {
casper.on('resource.requested', handleSettingsRequest);
test.assertEval(function testUserIsActive() {
return document.querySelector('.settings-menu .general').classList.contains('active');
}, "general tab is marked active");
}, 'general tab is marked active');
});
@ -91,10 +85,8 @@ CasperTest.begin("Settings screen is correct", 18, function suite(test) {
return document.querySelectorAll('.js-bb-notification section').length > 0;
});
}, function doneWaiting() {
}, function waitTimeout() {
test.fail("Saving the general pane did not result in a notification");
});
test.pass('Waited for notification');
}, casper.failOnTimeout(test, 'Saving the general pane did not result in a notification'));
casper.then(function checkSettingsWereSaved() {
casper.removeListener('resource.requested', handleSettingsRequest);
@ -102,9 +94,7 @@ CasperTest.begin("Settings screen is correct", 18, function suite(test) {
casper.waitForSelector('.notification-success', function onSuccess() {
test.assert(true, 'Got success notification');
}, function onTimeout() {
test.assert(false, 'No success notification :(');
});
}, casper.failOnTimeout(test, 'No success notification :('));
CasperTest.beforeDone(function () {
casper.removeListener('resource.requested', handleUserRequest);
@ -113,51 +103,47 @@ CasperTest.begin("Settings screen is correct", 18, function suite(test) {
});
CasperTest.begin('Ensure general blog title field length validation', 3, function suite(test) {
casper.thenOpen(url + "ghost/settings/general/", function testTitleAndUrl() {
test.assertTitle("Ghost Admin", "Ghost admin has no title");
test.assertUrlMatch(/ghost\/settings\/general\/$/, "Ghost doesn't require login this time");
casper.thenOpen(url + 'ghost/settings/general/', function testTitleAndUrl() {
test.assertTitle('Ghost Admin', 'Ghost admin has no title');
test.assertUrlMatch(/ghost\/settings\/general\/$/, 'Ghost doesn\'t require login this time');
});
casper.waitForSelector('#general', function then() {
this.fill("form#settings-general", {
this.fill('form#settings-general', {
'general[title]': new Array(152).join('a')
});
});
}, casper.failOnTimeout(test, 'waitForSelector #general timed out'));
casper.thenClick('#general .button-save');
casper.waitForSelectorTextChange('.notification-error', function onSuccess() {
test.assertSelectorHasText('.notification-error', 'too long');
}, function onTimeout() {
test.fail('Blog title length error did not appear');
}, 2000);
}, casper.failOnTimeout(test, 'Blog title length error did not appear'), 2000);
});
CasperTest.begin('Ensure general blog description field length validation', 3, function suite(test) {
casper.thenOpen(url + "ghost/settings/general/", function testTitleAndUrl() {
test.assertTitle("Ghost Admin", "Ghost admin has no title");
test.assertUrlMatch(/ghost\/settings\/general\/$/, "Ghost doesn't require login this time");
casper.thenOpen(url + 'ghost/settings/general/', function testTitleAndUrl() {
test.assertTitle('Ghost Admin', 'Ghost admin has no title');
test.assertUrlMatch(/ghost\/settings\/general\/$/, 'Ghost doesn\'t require login this time');
});
casper.waitForSelector('#general', function then() {
this.fillSelectors("form#settings-general", {
this.fillSelectors('form#settings-general', {
'#blog-description': new Array(202).join('a')
});
});
}, casper.failOnTimeout(test, 'waitForSelector #general timed out'));
casper.thenClick('#general .button-save');
casper.waitForSelectorTextChange('.notification-error', function onSuccess() {
test.assertSelectorHasText('.notification-error', 'too long');
}, function onTimeout() {
test.fail('Blog description length error did not appear');
}, 2000);
}, casper.failOnTimeout(test, 'Blog description length error did not appear'));
});
CasperTest.begin('Ensure image upload modals display correctly', 6, function suite(test) {
casper.thenOpen(url + "ghost/settings/general/", function testTitleAndUrl() {
test.assertTitle("Ghost Admin", "Ghost admin has no title");
test.assertUrlMatch(/ghost\/settings\/general\/$/, "Ghost doesn't require login this time");
casper.thenOpen(url + 'ghost/settings/general/', function testTitleAndUrl() {
test.assertTitle('Ghost Admin', 'Ghost admin has no title');
test.assertUrlMatch(/ghost\/settings\/general\/$/, 'Ghost doesn\'t require login this time');
});
function assertImageUploaderModalThenClose() {
@ -165,38 +151,32 @@ CasperTest.begin('Ensure image upload modals display correctly', 6, function sui
this.click('#modal-container .js-button-accept');
casper.waitForSelector('.notification-success', function onSuccess() {
test.assert(true, 'Got success notification');
}, function onTimeout() {
test.fail('No success notification');
}, 1000);
};
}, casper.failOnTimeout(test, 'No success notification'));
}
// Test Blog Logo Upload Button
casper.waitForSelector('#general', function then() {
casper.waitForOpaque('#general', function then() {
this.click('#general .js-modal-logo');
});
}, casper.failOnTimeout(test, 'waitForOpaque #general timed out'));
casper.waitForSelector('#modal-container .modal-content', assertImageUploaderModalThenClose,
function onTimeout() {
test.fail('No upload logo modal container appeared');
}, 1000);
casper.failOnTimeout(test, 'No upload logo modal container appeared'));
// Test Blog Cover Upload Button
casper.then(function() {
casper.then(function () {
this.click('#general .js-modal-cover');
});
casper.waitForSelector('#modal-container .modal-content', assertImageUploaderModalThenClose,
function onTimeout() {
test.fail('No upload cover modal container appeared');
}, 1000);
casper.failOnTimeout(test, 'No upload cover modal container appeared'));
});
CasperTest.begin("User settings screen validates email", 6, function suite(test) {
CasperTest.begin('User settings screen validates email', 6, function suite(test) {
var email, brokenEmail;
casper.thenOpen(url + "ghost/settings/user/", function testTitleAndUrl() {
test.assertTitle("Ghost Admin", "Ghost admin has no title");
test.assertUrlMatch(/ghost\/settings\/user\/$/, "Ghost doesn't require login this time");
casper.thenOpen(url + 'ghost/settings/user/', function testTitleAndUrl() {
test.assertTitle('Ghost Admin', 'Ghost admin has no title');
test.assertUrlMatch(/ghost\/settings\/user\/$/, 'Ghost doesn\'t require login this time');
});
casper.then(function setEmailToInvalid() {
@ -215,9 +195,7 @@ CasperTest.begin("User settings screen validates email", 6, function suite(test)
casper.waitForSelector('.notification-error', function onSuccess() {
test.assert(true, 'Got error notification');
test.assertSelectorDoesntHaveText('.notification-error', '[object Object]');
}, function onTimeout() {
test.assert(false, 'No error notification :(');
});
}, casper.failOnTimeout(test, 'No error notification :('));
casper.then(function resetEmailToValid() {
casper.fillSelectors('.user-profile', {
@ -232,83 +210,75 @@ CasperTest.begin("User settings screen validates email", 6, function suite(test)
casper.waitForSelector('.notification-success', function onSuccess() {
test.assert(true, 'Got success notification');
test.assertSelectorDoesntHaveText('.notification-success', '[object Object]');
}, function onTimeout() {
test.assert(false, 'No success notification :(');
});
}, casper.failOnTimeout(test, 'No success notification :('));
});
CasperTest.begin('Ensure postsPerPage number field form validation', 3, function suite(test) {
casper.thenOpen(url + "ghost/settings/general/", function testTitleAndUrl() {
test.assertTitle("Ghost Admin", "Ghost admin has no title");
test.assertUrlMatch(/ghost\/settings\/general\/$/, "Ghost doesn't require login this time");
casper.thenOpen(url + 'ghost/settings/general/', function testTitleAndUrl() {
test.assertTitle('Ghost Admin', 'Ghost admin has no title');
test.assertUrlMatch(/ghost\/settings\/general\/$/, 'Ghost doesn\'t require login this time');
});
casper.waitForSelector('#general', function then() {
this.fill("form#settings-general", {
this.fill('form#settings-general', {
'general[postsPerPage]': 'notaninteger'
});
});
}, casper.failOnTimeout(test, 'waitForSelector #general timed out'));
casper.thenClick('#general .button-save');
casper.waitForSelectorTextChange('.notification-error', function onSuccess() {
test.assertSelectorHasText('.notification-error', 'use a number');
}, function onTimeout() {
test.fail('postsPerPage error did not appear');
}, 2000);
}, casper.failOnTimeout(test, 'postsPerPage error did not appear'), 2000);
});
CasperTest.begin('Ensure postsPerPage max of 1000', 3, function suite(test) {
casper.thenOpen(url + "ghost/settings/general/", function testTitleAndUrl() {
test.assertTitle("Ghost Admin", "Ghost admin has no title");
test.assertUrlMatch(/ghost\/settings\/general\/$/, "Ghost doesn't require login this time");
casper.thenOpen(url + 'ghost/settings/general/', function testTitleAndUrl() {
test.assertTitle('Ghost Admin', 'Ghost admin has no title');
test.assertUrlMatch(/ghost\/settings\/general\/$/, 'Ghost doesn\'t require login this time');
});
casper.waitForSelector('#general', function then() {
this.fill("form#settings-general", {
this.fill('form#settings-general', {
'general[postsPerPage]': '1001'
});
});
}, casper.failOnTimeout(test, 'waitForSelector #general timed out'));
casper.thenClick('#general .button-save');
casper.waitForSelectorTextChange('.notification-error', function onSuccess() {
test.assertSelectorHasText('.notification-error', 'use a number less than 1000');
}, function onTimeout() {
test.fail('postsPerPage max error did not appear');
}, 2000);
}, casper.failOnTimeout(test, 'postsPerPage max error did not appear', 2000));
});
CasperTest.begin('Ensure postsPerPage min of 0', 3, function suite(test) {
casper.thenOpen(url + "ghost/settings/general/", function testTitleAndUrl() {
test.assertTitle("Ghost Admin", "Ghost admin has no title");
test.assertUrlMatch(/ghost\/settings\/general\/$/, "Ghost doesn't require login this time");
casper.thenOpen(url + 'ghost/settings/general/', function testTitleAndUrl() {
test.assertTitle('Ghost Admin', 'Ghost admin has no title');
test.assertUrlMatch(/ghost\/settings\/general\/$/, 'Ghost doesn\'t require login this time');
});
casper.waitForSelector('#general', function then() {
this.fill("form#settings-general", {
this.fill('form#settings-general', {
'general[postsPerPage]': '-1'
});
});
}, casper.failOnTimeout(test, 'waitForSelector #general timed out'));
casper.thenClick('#general .button-save');
casper.waitForSelectorTextChange('.notification-error', function onSuccess() {
test.assertSelectorHasText('.notification-error', 'use a number greater than 0');
}, function onTimeout() {
test.fail('postsPerPage min error did not appear');
}, 2000);
}, casper.failOnTimeout(test, 'postsPerPage min error did not appear', 2000));
});
CasperTest.begin("User settings screen shows remaining characters for Bio properly", 4, function suite(test) {
CasperTest.begin('User settings screen shows remaining characters for Bio properly', 4, function suite(test) {
function getRemainingBioCharacterCount() {
return casper.getHTML('.word-count');
}
casper.thenOpen(url + "ghost/settings/user/", function testTitleAndUrl() {
test.assertTitle("Ghost Admin", "Ghost admin has no title");
test.assertUrlMatch(/ghost\/settings\/user\/$/, "Ghost doesn't require login this time");
casper.thenOpen(url + 'ghost/settings/user/', function testTitleAndUrl() {
test.assertTitle('Ghost Admin', 'Ghost admin has no title');
test.assertUrlMatch(/ghost\/settings\/user\/$/, 'Ghost doesn\'t require login this time');
});
casper.then(function checkCharacterCount() {
@ -327,72 +297,66 @@ CasperTest.begin("User settings screen shows remaining characters for Bio proper
});
CasperTest.begin('Ensure user bio field length validation', 3, function suite(test) {
casper.thenOpen(url + "ghost/settings/user/", function testTitleAndUrl() {
test.assertTitle("Ghost Admin", "Ghost admin has no title");
test.assertUrlMatch(/ghost\/settings\/user\/$/, "Ghost doesn't require login this time");
casper.thenOpen(url + 'ghost/settings/user/', function testTitleAndUrl() {
test.assertTitle('Ghost Admin', 'Ghost admin has no title');
test.assertUrlMatch(/ghost\/settings\/user\/$/, 'Ghost doesn\'t require login this time');
});
casper.waitForSelector('#user', function then() {
this.fillSelectors("form.user-profile", {
this.fillSelectors('form.user-profile', {
'#user-bio': new Array(202).join('a')
});
});
}, casper.failOnTimeout(test, 'waitForSelector #user timed out'));
casper.thenClick('#user .button-save');
casper.waitForSelectorTextChange('.notification-error', function onSuccess() {
test.assertSelectorHasText('.notification-error', 'is too long');
}, function onTimeout() {
test.fail('Bio field length error did not appear');
}, 2000);
}, casper.failOnTimeout(test, 'Bio field length error did not appear', 2000));
});
CasperTest.begin('Ensure user url field validation', 3, function suite(test) {
casper.thenOpen(url + "ghost/settings/user/", function testTitleAndUrl() {
test.assertTitle("Ghost Admin", "Ghost admin has no title");
test.assertUrlMatch(/ghost\/settings\/user\/$/, "Ghost doesn't require login this time");
casper.thenOpen(url + 'ghost/settings/user/', function testTitleAndUrl() {
test.assertTitle('Ghost Admin', 'Ghost admin has no title');
test.assertUrlMatch(/ghost\/settings\/user\/$/, 'Ghost doesn\'t require login this time');
});
casper.waitForSelector('#user', function then() {
this.fillSelectors("form.user-profile", {
this.fillSelectors('form.user-profile', {
'#user-website': 'notaurl'
});
});
}, casper.failOnTimeout(test, 'waitForSelector #user timed out'));
casper.thenClick('#user .button-save');
casper.waitForSelectorTextChange('.notification-error', function onSuccess() {
test.assertSelectorHasText('.notification-error', 'use a valid url');
}, function onTimeout() {
test.fail('Url validation error did not appear');
}, 2000);
}, casper.failOnTimeout(test, 'Url validation error did not appear', 2000));
});
CasperTest.begin('Ensure user location field length validation', 3, function suite(test) {
casper.thenOpen(url + "ghost/settings/user/", function testTitleAndUrl() {
test.assertTitle("Ghost Admin", "Ghost admin has no title");
test.assertUrlMatch(/ghost\/settings\/user\/$/, "Ghost doesn't require login this time");
casper.thenOpen(url + 'ghost/settings/user/', function testTitleAndUrl() {
test.assertTitle('Ghost Admin', 'Ghost admin has no title');
test.assertUrlMatch(/ghost\/settings\/user\/$/, 'Ghost doesn\'t require login this time');
});
casper.waitForSelector('#user', function then() {
this.fillSelectors("form.user-profile", {
this.fillSelectors('form.user-profile', {
'#user-location': new Array(1002).join('a')
});
});
}, casper.failOnTimeout(test, 'waitForSelector #user timed out'));
casper.thenClick('#user .button-save');
casper.waitForSelectorTextChange('.notification-error', function onSuccess() {
test.assertSelectorHasText('.notification-error', 'is too long');
}, function onTimeout() {
test.fail('Location field length error did not appear');
}, 2000);
}, casper.failOnTimeout(test, 'Location field length error did not appear', 2000));
});
CasperTest.begin('Admin navigation bar is correct', 28, function suite(test) {
casper.thenOpen(url + 'ghost/settings/', function testTitleAndUrl() {
test.assertTitle('Ghost Admin', 'Ghost admin has no title');
test.assertUrlMatch(/ghost\/settings\/general\/$/, "Ghost doesn't require login this time");
test.assertUrlMatch(/ghost\/settings\/general\/$/, 'Ghost doesn\'t require login this time');
});
casper.then(function testNavItems() {
@ -400,22 +364,26 @@ CasperTest.begin('Admin navigation bar is correct', 28, function suite(test) {
test.assertEquals(this.getElementAttribute('a.ghost-logo', 'href'), '/', 'Ghost logo href is correct');
test.assertExists('#main-menu li.content a', 'Content nav item exists');
test.assertSelectorHasText('#main-menu li.content a', 'Content', 'Content nav item has correct text');
test.assertEquals(this.getElementAttribute('#main-menu li.content a', 'href'), '/ghost/', 'Content href is correct');
test.assertEval(function testContentIsNotActive() {
test.assertSelectorHasText('#main-menu li.content a', 'Content',
'Content nav item has correct text');
test.assertEquals(this.getElementAttribute('#main-menu li.content a', 'href'), '/ghost/',
'Content href is correct');
test.assertEval(function testContentIsNotActive() {
return !document.querySelector('#main-menu li.content').classList.contains('active');
}, 'Content nav item is not marked active');
test.assertExists('#main-menu li.editor a', 'Editor nav item exists');
test.assertSelectorHasText('#main-menu li.editor a', 'New Post', 'Editor nav item has correct text');
test.assertEquals(this.getElementAttribute('#main-menu li.editor a', 'href'), '/ghost/editor/', 'Editor href is correct');
test.assertEquals(this.getElementAttribute('#main-menu li.editor a', 'href'), '/ghost/editor/',
'Editor href is correct');
test.assertEval(function testEditorIsNotActive() {
return !document.querySelector('#main-menu li.editor').classList.contains('active');
}, 'Editor nav item is not marked active');
test.assertExists('#main-menu li.settings a', 'Settings nav item exists');
test.assertSelectorHasText('#main-menu li.settings a', 'Settings', 'Settings nav item has correct text');
test.assertEquals(this.getElementAttribute('#main-menu li.settings a', 'href'), '/ghost/settings/', 'Settings href is correct');
test.assertEquals(this.getElementAttribute('#main-menu li.settings a', 'href'), '/ghost/settings/',
'Settings href is correct');
test.assertEval(function testSettingsIsActive() {
return document.querySelector('#main-menu li.settings').classList.contains('active');
}, 'Settings nav item is marked active');
@ -431,15 +399,20 @@ CasperTest.begin('Admin navigation bar is correct', 28, function suite(test) {
test.assertVisible('#usermenu ul.overlay', 'User menu should be visible');
test.assertExists('#usermenu li.usermenu-profile a', 'Profile menu item exists');
test.assertSelectorHasText('#usermenu li.usermenu-profile a', 'Your Profile', 'Profile menu item has correct text');
test.assertEquals(this.getElementAttribute('#usermenu li.usermenu-profile a', 'href'), '/ghost/settings/user/', 'Profile href is correct');
test.assertSelectorHasText('#usermenu li.usermenu-profile a', 'Your Profile',
'Profile menu item has correct text');
test.assertEquals(this.getElementAttribute('#usermenu li.usermenu-profile a', 'href'), '/ghost/settings/user/',
'Profile href is correct');
test.assertExists('#usermenu li.usermenu-help a', 'Help menu item exists');
test.assertSelectorHasText('#usermenu li.usermenu-help a', 'Help / Support', 'Help menu item has correct text');
test.assertEquals(this.getElementAttribute('#usermenu li.usermenu-help a', 'href'), 'http://ghost.org/forum/', 'Help href is correct');
test.assertEquals(this.getElementAttribute('#usermenu li.usermenu-help a', 'href'), 'http://ghost.org/forum/',
'Help href is correct');
test.assertExists('#usermenu li.usermenu-signout a', 'Sign Out menu item exists');
test.assertSelectorHasText('#usermenu li.usermenu-signout a', 'Sign Out', 'Sign Out menu item has correct text');
test.assertEquals(this.getElementAttribute('#usermenu li.usermenu-signout a', 'href'), '/ghost/signout/', 'Sign Out href is correct');
});
test.assertSelectorHasText('#usermenu li.usermenu-signout a', 'Sign Out',
'Sign Out menu item has correct text');
test.assertEquals(this.getElementAttribute('#usermenu li.usermenu-signout a', 'href'), '/ghost/signout/',
'Sign Out href is correct');
}, casper.failOnTimeout(test, 'WaitForSelector #usermenu ul.overlay failed'));
});

View File

@ -77,6 +77,12 @@ casper.waitForOpaque = function (classname, then, timeout) {
}, then, timeout);
};
casper.failOnTimeout = function (test, message) {
return function onTimeout() {
test.fail(message);
};
};
// ## Debugging
// output all errors to the console
casper.on('remote.message', function (msg) {
@ -96,14 +102,14 @@ casper.captureScreenshot = function (filename, debugOnly) {
// If we are in debug mode, OR debugOnly is false
if (DEBUG || debugOnly === false) {
filename = filename || "casper_test_fail.png";
casper.then(function () {
casper.capture(new Date().getTime() + '_' + filename);
});
// casper.then(function () {
// casper.capture(new Date().getTime() + '_' + filename);
// });
}
};
// on failure, grab a screenshot
casper.test.on("fail", function captureFailure() {
casper.test.on("fail", function captureFailure(test) {
casper.captureScreenshot(casper.test.filename || "casper_test_fail.png", false);
});