Casper tests: avoid races in 03-compose

(imported from commit 42f47073b96e72831e6cf560b6b50f9862d5b4cd)
This commit is contained in:
Kevin Mehall 2013-06-13 10:56:50 -04:00
parent 878094aad3
commit 3f2bdae1e1
1 changed files with 23 additions and 13 deletions

View File

@ -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();
});