Test improvements

refs #4309
- replace waitForResource with waitForSelector to prevent UI timing
issues.
This commit is contained in:
Sebastian Gierlinger 2014-10-20 22:05:41 +02:00
parent 7e123c8665
commit 425c99423f
2 changed files with 15 additions and 22 deletions

View File

@ -109,7 +109,7 @@ CasperTest.begin('Content list shows correct post status', 5, function testStati
// }); // });
// }); // });
CasperTest.begin('Posts can be marked as featured', 8, function suite(test) { CasperTest.begin('Posts can be marked as featured', 6, function suite(test) {
// Create a sample post // Create a sample post
CasperTest.Routines.createTestPost.run(false); CasperTest.Routines.createTestPost.run(false);
@ -140,14 +140,9 @@ CasperTest.begin('Posts can be marked as featured', 8, function suite(test) {
// Mark as not featured // Mark as not featured
casper.thenClick('.content-preview .featured'); casper.thenClick('.content-preview .featured');
casper.waitForResource(/\/posts\/\d+\/\?include=tags/, function waitForSuccess(resource) { casper.waitWhileSelector('.content-preview .featured', function onSuccess() {
test.assert(resource.status < 400);
});
casper.then(function untoggledFeaturedTest() {
test.assertDoesntExist('.content-preview .featured', 'Untoggled featured.');
test.assertDoesntExist('.content-list-content li.featured:first-of-type'); test.assertDoesntExist('.content-list-content li.featured:first-of-type');
}, function onTimeout() { }, function onTimeout() {
test.assert(false, 'Couldn\'t unfeature post.'); casper.test.fail('Couldn\'t unfeature post.');
}); }, 2000);
}); });

View File

@ -117,7 +117,7 @@ CasperTest.begin('Post published date can be changed', 4, function suite(test) {
}); });
}); });
CasperTest.begin('Post can be changed to static page', 6, function suite(test) { CasperTest.begin('Post can be changed to static page', 2, function suite(test) {
// Create a sample post // Create a sample post
CasperTest.Routines.createTestPost.run(false); CasperTest.Routines.createTestPost.run(false);
@ -135,19 +135,17 @@ CasperTest.begin('Post can be changed to static page', 6, function suite(test) {
casper.thenClick('label[for=static-page]'); casper.thenClick('label[for=static-page]');
casper.waitForResource(/\/posts\/\d+\/\?include=tags/, function waitForSuccess(resource) { casper.waitForSelector('.post-setting-static-page:checked', function onSuccess() {
test.assert(resource.status < 400); casper.click('label[for=static-page]');
}, function onTimeout() {
casper.test.fail('Post was not changed to static page.');
}, 2000);
test.assertExists('.post-setting-static-page:checked', 'can turn on static page'); casper.waitForSelector('.post-setting-static-page:not(checked)', function onSuccess() {
}); return;
}, function onTimeout() {
casper.thenClick('label[for=static-page]'); casper.test.fail('Static page was not changed to post.');
}, 2000);
casper.waitForResource(/\/posts\/\d+\/\?include=tags/, function waitForSuccess(resource) {
test.assert(resource.status < 400);
test.assertDoesntExist('.post-setting-static-page:checked', 'can turn off static page');
});
}); });
CasperTest.begin('Post url input is reset from all whitespace back to original value', 3, function suite(test) { CasperTest.begin('Post url input is reset from all whitespace back to original value', 3, function suite(test) {