From 39f632134d92fa4f307600acd8b1e8cb2f49858d Mon Sep 17 00:00:00 2001 From: Zev Benjamin Date: Fri, 7 Mar 2014 14:59:30 -0500 Subject: [PATCH] tests: Rename casper helpers for clarity send_message -> then_send_message send_many -> then_send_many wait_and_send -> then_wait_and_send Hopefully this makes it clearer that they should not be called inside of steps. (imported from commit 4fcc971817b25056100311ba55303da2c5527f0f) --- zerver/tests/frontend/common.js | 10 +++++----- zerver/tests/frontend/tests/01-site.js | 4 ++-- zerver/tests/frontend/tests/02-narrow.js | 2 +- zerver/tests/frontend/tests/03-compose.js | 6 +++--- zerver/tests/frontend/tests/07-stars.js | 2 +- zerver/tests/frontend/tests/09-edit.js | 4 ++-- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/zerver/tests/frontend/common.js b/zerver/tests/frontend/common.js index 6eaae60a4d..563d69f9b8 100644 --- a/zerver/tests/frontend/common.js +++ b/zerver/tests/frontend/common.js @@ -99,7 +99,7 @@ exports.check_form = function (form_selector, expected, test_name) { } }; -exports.send_message = function (type, params) { +exports.then_send_message = function (type, params) { casper.waitForSelector('#new_message_content', function () { if(type === "stream") { casper.page.sendEvent('keypress', "c"); @@ -121,9 +121,9 @@ exports.send_message = function (type, params) { }; // Wait for any previous send to finish, then send a message. -exports.wait_and_send = function (type, params) { +exports.then_wait_and_send = function (type, params) { casper.waitForSelector('#compose-send-button:enabled'); - exports.send_message(type, params); + exports.then_send_message(type, params); }; // Get message headings (recipient rows) and bodies out of the DOM. @@ -166,9 +166,9 @@ exports.keypress = function (code) { }; // Send a whole list of messages using wait_and_send. -exports.send_many = function (msgs) { +exports.then_send_many = function (msgs) { msgs.forEach(function (msg) { - exports.wait_and_send( + exports.then_wait_and_send( (msg.stream !== undefined) ? 'stream' : 'private', msg); }); diff --git a/zerver/tests/frontend/tests/01-site.js b/zerver/tests/frontend/tests/01-site.js index fc7887ee9e..9b2f57fabb 100644 --- a/zerver/tests/frontend/tests/01-site.js +++ b/zerver/tests/frontend/tests/01-site.js @@ -36,7 +36,7 @@ casper.then(function () { // Send some messages. -common.send_many([ +common.then_send_many([ { stream: 'Verona', subject: 'frontend test', content: 'test message A' }, @@ -73,7 +73,7 @@ common.wait_for_receive(function () { casper.test.info('Sending more messages'); }); -common.send_many([ +common.then_send_many([ { stream: 'Verona', subject: 'frontend test', content: 'test message D' }, diff --git a/zerver/tests/frontend/tests/02-narrow.js b/zerver/tests/frontend/tests/02-narrow.js index a489ad0f9a..7e49ca9948 100644 --- a/zerver/tests/frontend/tests/02-narrow.js +++ b/zerver/tests/frontend/tests/02-narrow.js @@ -10,7 +10,7 @@ casper.then(function () { casper.test.info('Sending messages'); }); -common.send_many([ +common.then_send_many([ { stream: 'Verona', subject: 'frontend test', content: 'test message A' }, diff --git a/zerver/tests/frontend/tests/03-compose.js b/zerver/tests/frontend/tests/03-compose.js index 2fccc2056e..289a329530 100644 --- a/zerver/tests/frontend/tests/03-compose.js +++ b/zerver/tests/frontend/tests/03-compose.js @@ -3,12 +3,12 @@ var common = require('../common.js').common; common.start_and_log_in(); // Send a message to try replying to -common.send_message('stream', { +common.then_send_message('stream', { stream: 'Verona', subject: 'Reply test', content: "We reply to this message" }); -common.send_message('private', { +common.then_send_message('private', { recipient: "cordelia@zulip.com", content: "And reply to this message" }); @@ -94,7 +94,7 @@ casper.then(function () { common.keypress(27); // escape to dismiss compose box }); casper.waitWhileVisible('.message_comp'); -common.send_many([ +common.then_send_many([ { recipient: recipients.join(','), content: 'A huddle to check spaces' }]); diff --git a/zerver/tests/frontend/tests/07-stars.js b/zerver/tests/frontend/tests/07-stars.js index 29e10ecba7..90025db18a 100644 --- a/zerver/tests/frontend/tests/07-stars.js +++ b/zerver/tests/frontend/tests/07-stars.js @@ -18,7 +18,7 @@ casper.then(function () { casper.test.info("Sending test message"); }); -common.send_message('stream', { +common.then_send_message('stream', { stream: 'Verona', subject: 'stars', content: 'test star' diff --git a/zerver/tests/frontend/tests/09-edit.js b/zerver/tests/frontend/tests/09-edit.js index b4c356beb8..b38739e582 100644 --- a/zerver/tests/frontend/tests/09-edit.js +++ b/zerver/tests/frontend/tests/09-edit.js @@ -16,7 +16,7 @@ function then_edit_last_message() { // Send and edit a stream message -common.send_message('stream', { +common.then_send_message('stream', { stream: 'Verona', subject: 'edits', content: 'test editing' @@ -39,7 +39,7 @@ casper.waitForSelector(".message_edit_notice", function () { casper.test.assertSelectorHasText(".last_message .message_content", "test edited"); }); -common.send_message('private', { +common.then_send_message('private', { recipient: "cordelia@zulip.com", content: "test editing pm" });