From 3f2bdae1e1ba18c0914e7d113b65b5095e6c6c43 Mon Sep 17 00:00:00 2001 From: Kevin Mehall Date: Thu, 13 Jun 2013 10:56:50 -0400 Subject: [PATCH] Casper tests: avoid races in 03-compose (imported from commit 42f47073b96e72831e6cf560b6b50f9862d5b4cd) --- zephyr/tests/frontend/tests/03-compose.js | 36 +++++++++++++++-------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/zephyr/tests/frontend/tests/03-compose.js b/zephyr/tests/frontend/tests/03-compose.js index 3cf04c7a65..fa03e2daa3 100644 --- a/zephyr/tests/frontend/tests/03-compose.js +++ b/zephyr/tests/frontend/tests/03-compose.js @@ -12,58 +12,68 @@ common.send_message('private', { recipient: "cordelia@humbughq.com", content: "And reply to this message" }); -casper.waitForText("And reply to this message"); -casper.then(function () { - // TODO: test correct events have fired - // Test opening the compose box from the left side buttons +casper.waitForText("And reply to this message", function () { + // TODO: Test opening the compose box from the left side buttons casper.click('body'); casper.page.sendEvent('keypress', "c"); - casper.test.assertVisible('#compose', 'Compose box appears after clicking side stream button'); +}); + +casper.waitUntilVisible('#compose', function () { casper.test.assertVisible('#stream', 'Stream input box visible'); common.check_form('#send_message_form', {stream: '', subject: ''}, "Stream empty on new compose"); casper.click('body'); casper.page.sendEvent('keypress', "C"); - casper.test.assertVisible('#private_message_recipient', 'Switching from stream compose to PM compose'); +}); + +casper.waitUntilVisible('#private_message_recipient', function () { common.check_form('#send_message_form', {recipient: ''}, "Recipient empty on new PM"); casper.click('body'); casper.page.sendEvent('keypress', 'c'); - casper.test.assertVisible('#stream', 'Switching from PM compose to stream compose'); +}); + +casper.waitUntilVisible('#stream', function () { common.check_form('#send_message_form', {stream: '', subject: ''}, "Stream empty on new compose"); // Check that when you reply to a message it pre-populates the stream and subject fields casper.click('body'); casper.clickLabel("We reply to this message"); - casper.test.assertVisible('#stream', 'Stream input box visible on reply'); +}); + +casper.waitUntilVisible('#stream', function () { common.check_form('#send_message_form', {stream: "Verona", subject: "Reply test"}, "Stream populated after reply by click"); // Or recipient field casper.click('body'); casper.clickLabel("And reply to this message"); +}); + +casper.waitUntilVisible('#private_message_recipient', function () { common.check_form('#send_message_form', {recipient: "cordelia@humbughq.com"}, "Recipient populated after PM click"); common.keypress(27); //escape casper.page.sendEvent('keypress', 'k'); casper.page.sendEvent('keypress', 'r'); +}); + +casper.waitUntilVisible('#stream', function () { common.check_form('#send_message_form', {stream: "Verona", subject: "Reply test"}, "Stream populated after reply with `r`"); // Test "closing" the compose box casper.click('body'); }); -casper.waitWhileVisible('#stream'); -casper.then(function () { +casper.waitWhileVisible('#stream', function () { casper.test.assertNotVisible('#stream', 'Close stream compose box'); casper.page.sendEvent('keypress', "C"); casper.click('body'); }); -casper.waitWhileVisible('#private-message'); -casper.then(function () { +casper.waitWhileVisible('#private-message', function () { casper.test.assertNotVisible('#private-message', 'Close PM compose box'); }); common.then_log_out(); casper.run(function () { - casper.test.done(17); + casper.test.done(); });