mirror of
https://github.com/zulip/zulip.git
synced 2025-11-11 01:16:19 +00:00
Add casper tests to check that the subject/stream/recipient fields are populated when replying
(imported from commit 7a0337467c6e7a1ed3118e07d2b4ad904719e093)
This commit is contained in:
@@ -88,6 +88,17 @@ exports.enable_page_console = function () {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
exports.check_form = function (form_selector, expected, test_name) {
|
||||||
|
var values = casper.getFormValues(form_selector);
|
||||||
|
var k;
|
||||||
|
for (k in expected) {
|
||||||
|
if (expected.hasOwnProperty(k)) {
|
||||||
|
casper.test.assertEqual(values[k], expected[k],
|
||||||
|
test_name ? (test_name + ": " + k) : undefined);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
exports.send_message = function (type, params) {
|
exports.send_message = function (type, params) {
|
||||||
casper.waitForSelector('#new_message_content', function () {
|
casper.waitForSelector('#new_message_content', function () {
|
||||||
if(type === "stream") {
|
if(type === "stream") {
|
||||||
|
|||||||
@@ -2,18 +2,49 @@ var common = require('../common.js').common;
|
|||||||
|
|
||||||
common.start_and_log_in();
|
common.start_and_log_in();
|
||||||
|
|
||||||
|
// Send a message to try replying to
|
||||||
|
common.send_message('stream', {
|
||||||
|
stream: 'Verona',
|
||||||
|
subject: 'Reply test',
|
||||||
|
content: "We reply to this message"
|
||||||
|
});
|
||||||
|
common.send_message('private', {
|
||||||
|
recipient: "cordelia@humbughq.com",
|
||||||
|
content: "And reply to this message"
|
||||||
|
});
|
||||||
|
casper.waitForText("And reply to this message");
|
||||||
|
|
||||||
casper.then(function () {
|
casper.then(function () {
|
||||||
// TODO: test correct events have fired
|
// TODO: test correct events have fired
|
||||||
// Test opening the compose box from the left side buttons
|
// Test opening the compose box from the left side buttons
|
||||||
|
casper.click('body');
|
||||||
casper.page.sendEvent('keypress', "c");
|
casper.page.sendEvent('keypress', "c");
|
||||||
casper.test.assertVisible('#compose', 'Compose box appears after clicking side stream button');
|
casper.test.assertVisible('#compose', 'Compose box appears after clicking side stream button');
|
||||||
casper.test.assertVisible('#stream', 'Stream input box visible');
|
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.click('body');
|
||||||
casper.page.sendEvent('keypress', "C");
|
casper.page.sendEvent('keypress', "C");
|
||||||
casper.test.assertVisible('#private_message_recipient', 'Switching from stream compose to PM compose');
|
casper.test.assertVisible('#private_message_recipient', 'Switching from stream compose to PM compose');
|
||||||
|
common.check_form('#send_message_form', {recipient: ''}, "Recipient empty on new PM");
|
||||||
casper.click('body');
|
casper.click('body');
|
||||||
casper.page.sendEvent('keypress', 'c');
|
casper.page.sendEvent('keypress', 'c');
|
||||||
casper.test.assertVisible('#stream', 'Switching from PM compose to stream compose');
|
casper.test.assertVisible('#stream', 'Switching from PM compose to stream compose');
|
||||||
|
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');
|
||||||
|
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");
|
||||||
|
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');
|
||||||
|
common.check_form('#send_message_form', {stream: "Verona", subject: "Reply test"}, "Stream populated after reply with `r`");
|
||||||
|
|
||||||
// Test "closing" the compose box
|
// Test "closing" the compose box
|
||||||
casper.click('body');
|
casper.click('body');
|
||||||
@@ -34,5 +65,5 @@ casper.then(function () {
|
|||||||
common.then_log_out();
|
common.then_log_out();
|
||||||
|
|
||||||
casper.run(function () {
|
casper.run(function () {
|
||||||
casper.test.done(6);
|
casper.test.done(17);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user