From 425c99423f2cb2f794a3689d4c97140c635974da Mon Sep 17 00:00:00 2001 From: Sebastian Gierlinger Date: Mon, 20 Oct 2014 22:05:41 +0200 Subject: [PATCH] Test improvements refs #4309 - replace waitForResource with waitForSelector to prevent UI timing issues. --- core/test/functional/client/content_test.js | 13 ++++------- core/test/functional/client/psm_test.js | 24 ++++++++++----------- 2 files changed, 15 insertions(+), 22 deletions(-) diff --git a/core/test/functional/client/content_test.js b/core/test/functional/client/content_test.js index 5738cd34d1..712ceb2d91 100644 --- a/core/test/functional/client/content_test.js +++ b/core/test/functional/client/content_test.js @@ -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 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 casper.thenClick('.content-preview .featured'); - casper.waitForResource(/\/posts\/\d+\/\?include=tags/, function waitForSuccess(resource) { - test.assert(resource.status < 400); - }); - - casper.then(function untoggledFeaturedTest() { - test.assertDoesntExist('.content-preview .featured', 'Untoggled featured.'); + casper.waitWhileSelector('.content-preview .featured', function onSuccess() { test.assertDoesntExist('.content-list-content li.featured:first-of-type'); }, function onTimeout() { - test.assert(false, 'Couldn\'t unfeature post.'); - }); + casper.test.fail('Couldn\'t unfeature post.'); + }, 2000); }); diff --git a/core/test/functional/client/psm_test.js b/core/test/functional/client/psm_test.js index 0f1cae4d01..f6c794351f 100644 --- a/core/test/functional/client/psm_test.js +++ b/core/test/functional/client/psm_test.js @@ -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 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.waitForResource(/\/posts\/\d+\/\?include=tags/, function waitForSuccess(resource) { - test.assert(resource.status < 400); + casper.waitForSelector('.post-setting-static-page:checked', function onSuccess() { + 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.thenClick('label[for=static-page]'); - - 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'); - }); + casper.waitForSelector('.post-setting-static-page:not(checked)', function onSuccess() { + return; + }, function onTimeout() { + casper.test.fail('Static page was not changed to post.'); + }, 2000); }); CasperTest.begin('Post url input is reset from all whitespace back to original value', 3, function suite(test) {