2020-07-15 01:29:15 +02:00
|
|
|
var common = require("../casper_lib/common.js");
|
2013-03-07 19:30:42 +01:00
|
|
|
|
2013-03-05 20:52:54 +01:00
|
|
|
common.start_and_log_in();
|
2013-03-07 19:30:42 +01:00
|
|
|
|
2017-06-07 07:59:51 +02:00
|
|
|
var msgs_qty;
|
|
|
|
|
|
|
|
casper.then(function () {
|
|
|
|
casper.waitUntilVisible("#zhome");
|
|
|
|
});
|
|
|
|
|
|
|
|
casper.then(function () {
|
|
|
|
msgs_qty = this.evaluate(function () {
|
2020-07-15 01:29:15 +02:00
|
|
|
return $("#zhome .message_row").length;
|
2017-06-07 07:59:51 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2013-06-11 23:08:11 +02:00
|
|
|
// Send a message to try replying to
|
2014-03-07 23:05:39 +01:00
|
|
|
common.then_send_many([
|
2020-07-15 00:34:28 +02:00
|
|
|
{stream: "Verona", subject: "Reply test", content: "We reply to this message"},
|
|
|
|
{recipient: "cordelia@zulip.com", content: "And reply to this message"},
|
2014-03-07 23:05:39 +01:00
|
|
|
]);
|
2013-06-11 23:08:11 +02:00
|
|
|
|
2017-06-07 07:59:51 +02:00
|
|
|
casper.then(function () {
|
|
|
|
casper.waitFor(function check_length() {
|
|
|
|
return casper.evaluate(function (expected_length) {
|
2020-07-15 01:29:15 +02:00
|
|
|
return $("#zhome .message_row").length === expected_length;
|
2017-06-07 07:59:51 +02:00
|
|
|
}, msgs_qty + 2);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
casper.then(function () {
|
2013-06-13 16:56:50 +02:00
|
|
|
// TODO: Test opening the compose box from the left side buttons
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.click("body");
|
|
|
|
casper.page.sendEvent("keypress", "c");
|
2013-06-13 16:56:50 +02:00
|
|
|
});
|
|
|
|
|
2018-11-13 17:16:02 +01:00
|
|
|
function check_compose_is_cleared() {
|
|
|
|
common.check_form(
|
2020-07-15 01:29:15 +02:00
|
|
|
"#send_message_form",
|
2018-11-13 17:16:02 +01:00
|
|
|
{
|
2020-07-15 01:29:15 +02:00
|
|
|
stream_message_recipient_stream: "",
|
|
|
|
stream_message_recipient_topic: "",
|
2018-11-13 17:16:02 +01:00
|
|
|
},
|
|
|
|
"Stream empty on new compose"
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2016-09-08 14:10:41 +02:00
|
|
|
casper.then(function () {
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.waitUntilVisible("#compose", function () {
|
|
|
|
casper.test.assertVisible("#stream-message", "Stream input box visible");
|
2018-11-13 17:16:02 +01:00
|
|
|
check_compose_is_cleared();
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.click("body");
|
|
|
|
casper.page.sendEvent("keypress", "x");
|
2016-09-08 14:10:41 +02:00
|
|
|
});
|
2013-06-13 16:56:50 +02:00
|
|
|
});
|
|
|
|
|
2016-09-08 14:10:41 +02:00
|
|
|
casper.then(function () {
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.waitUntilVisible("#private_message_recipient", function () {
|
2018-03-06 15:07:55 +01:00
|
|
|
common.pm_recipient.expect("");
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.click("body");
|
|
|
|
casper.page.sendEvent("keypress", "c");
|
2016-09-08 14:10:41 +02:00
|
|
|
});
|
2013-06-13 16:56:50 +02:00
|
|
|
});
|
|
|
|
|
2016-09-08 14:10:41 +02:00
|
|
|
casper.then(function () {
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.waitUntilVisible("#stream-message", function () {
|
2018-11-13 17:16:02 +01:00
|
|
|
check_compose_is_cleared();
|
2013-06-11 23:08:11 +02:00
|
|
|
|
2016-09-08 14:10:41 +02:00
|
|
|
// Check that when you reply to a message it pre-populates the stream and subject fields
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.click("body");
|
2016-09-08 14:10:41 +02:00
|
|
|
});
|
2013-07-15 23:44:59 +02:00
|
|
|
});
|
|
|
|
|
2016-09-08 14:10:41 +02:00
|
|
|
casper.then(function () {
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.waitWhileVisible("#stream-message", function () {
|
2016-09-08 14:10:41 +02:00
|
|
|
casper.clickLabel("We reply to this message");
|
|
|
|
});
|
2013-06-13 16:56:50 +02:00
|
|
|
});
|
|
|
|
|
2016-09-08 14:10:41 +02:00
|
|
|
casper.then(function () {
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.waitUntilVisible("#stream-message", function () {
|
2018-11-13 17:16:02 +01:00
|
|
|
common.check_form(
|
2020-07-15 01:29:15 +02:00
|
|
|
"#send_message_form",
|
2018-11-13 17:16:02 +01:00
|
|
|
{
|
|
|
|
stream_message_recipient_stream: "Verona",
|
|
|
|
stream_message_recipient_topic: "Reply test",
|
|
|
|
},
|
|
|
|
"Stream populated after reply by click"
|
|
|
|
);
|
2016-09-08 14:10:41 +02:00
|
|
|
// Or recipient field
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.click("body");
|
2016-09-08 14:10:41 +02:00
|
|
|
casper.clickLabel("And reply to this message");
|
|
|
|
});
|
2013-06-13 16:56:50 +02:00
|
|
|
});
|
|
|
|
|
2016-09-08 14:10:41 +02:00
|
|
|
casper.then(function () {
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.waitUntilVisible("#private_message_recipient", function () {
|
2018-03-06 15:07:55 +01:00
|
|
|
common.pm_recipient.expect("cordelia@zulip.com");
|
2013-06-11 23:08:11 +02:00
|
|
|
|
2016-09-08 14:10:41 +02:00
|
|
|
common.keypress(27); //escape
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.page.sendEvent("keypress", "k");
|
|
|
|
casper.page.sendEvent("keypress", "r");
|
2016-09-08 14:10:41 +02:00
|
|
|
});
|
2013-06-13 16:56:50 +02:00
|
|
|
});
|
|
|
|
|
2016-09-08 14:10:41 +02:00
|
|
|
casper.then(function () {
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.waitUntilVisible("#stream-message", function () {
|
2018-11-13 17:16:02 +01:00
|
|
|
common.check_form(
|
2020-07-15 01:29:15 +02:00
|
|
|
"#send_message_form",
|
2018-11-13 17:16:02 +01:00
|
|
|
{
|
|
|
|
stream_message_recipient_stream: "Verona",
|
|
|
|
stream_message_recipient_topic: "Reply test",
|
|
|
|
},
|
|
|
|
"Stream populated after reply with `r`"
|
|
|
|
);
|
2013-03-07 19:30:42 +01:00
|
|
|
|
2016-09-08 14:10:41 +02:00
|
|
|
// Test "closing" the compose box
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.click("body");
|
2016-09-08 14:10:41 +02:00
|
|
|
});
|
2013-03-07 19:30:42 +01:00
|
|
|
});
|
|
|
|
|
2016-09-08 14:10:41 +02:00
|
|
|
casper.then(function () {
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.waitWhileVisible("#stream-message", function () {
|
|
|
|
casper.test.assertNotVisible("#stream-message", "Close stream compose box");
|
|
|
|
casper.page.sendEvent("keypress", "x");
|
|
|
|
casper.click("body");
|
2016-09-08 14:10:41 +02:00
|
|
|
});
|
2013-03-07 19:30:42 +01:00
|
|
|
});
|
|
|
|
|
2016-09-08 14:10:41 +02:00
|
|
|
casper.then(function () {
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.waitWhileVisible("#private-message", function () {
|
|
|
|
casper.test.assertNotVisible("#private-message", "Close PM compose box");
|
2016-09-08 14:10:41 +02:00
|
|
|
});
|
2013-03-07 19:30:42 +01:00
|
|
|
});
|
|
|
|
|
2013-07-15 23:44:59 +02:00
|
|
|
// Test focus after narrowing to PMs with a user and typing 'c'
|
|
|
|
casper.then(function () {
|
|
|
|
casper.click('*[title="Narrow to your private messages with Cordelia Lear"]');
|
|
|
|
});
|
2020-01-27 16:42:48 +01:00
|
|
|
|
|
|
|
casper.then(function () {
|
2020-07-15 01:29:15 +02:00
|
|
|
var cordelia_user_id = common.get_user_id("cordelia@zulip.com");
|
2020-07-15 00:34:28 +02:00
|
|
|
var pm_li =
|
|
|
|
'li[data-user-ids-string="' +
|
|
|
|
cordelia_user_id +
|
|
|
|
'"].expanded_private_message.active-sub-filter';
|
2020-01-27 16:42:48 +01:00
|
|
|
|
|
|
|
casper.waitUntilVisible(pm_li, function () {
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.page.sendEvent("keypress", "c");
|
2020-01-27 16:42:48 +01:00
|
|
|
});
|
2013-07-15 23:44:59 +02:00
|
|
|
});
|
2016-09-08 14:10:41 +02:00
|
|
|
|
|
|
|
casper.then(function () {
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.waitUntilVisible("#compose", function () {
|
2016-09-08 14:10:41 +02:00
|
|
|
casper.test.assertEval(function () {
|
2020-07-15 00:34:28 +02:00
|
|
|
return (
|
|
|
|
document.activeElement === $(".compose_table #stream_message_recipient_stream")[0]
|
|
|
|
);
|
2020-07-15 01:29:15 +02:00
|
|
|
}, "Stream box focused after narrowing to PMs with a user and pressing `c`");
|
2016-09-08 14:10:41 +02:00
|
|
|
});
|
2013-07-15 23:44:59 +02:00
|
|
|
});
|
|
|
|
|
2013-07-26 00:54:25 +02:00
|
|
|
// Make sure multiple PM recipients display properly.
|
2020-07-15 01:29:15 +02:00
|
|
|
var recipients = ["cordelia@zulip.com", "othello@zulip.com"];
|
2013-07-26 00:54:25 +02:00
|
|
|
casper.then(function () {
|
2020-07-16 23:29:01 +02:00
|
|
|
common.keypress(27); // escape to dismiss compose box
|
2013-07-26 00:54:25 +02:00
|
|
|
});
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.waitWhileVisible(".message_comp");
|
|
|
|
common.then_send_message("private", {
|
|
|
|
recipient: recipients.join(","),
|
2020-03-26 12:25:10 +01:00
|
|
|
outside_view: true,
|
2020-07-15 01:29:15 +02:00
|
|
|
content: "A huddle to check spaces",
|
2020-03-26 12:25:10 +01:00
|
|
|
});
|
|
|
|
|
2014-03-07 20:55:33 +01:00
|
|
|
casper.then(function () {
|
2020-07-16 23:29:01 +02:00
|
|
|
common.keypress(27); // escape to dismiss compose box
|
2014-03-07 20:55:33 +01:00
|
|
|
});
|
|
|
|
casper.then(function () {
|
2013-07-26 00:54:25 +02:00
|
|
|
common.un_narrow();
|
|
|
|
});
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.waitUntilVisible("#zhome", function () {
|
|
|
|
casper.clickLabel("A huddle to check spaces");
|
2013-07-26 00:54:25 +02:00
|
|
|
});
|
2016-09-08 14:10:41 +02:00
|
|
|
|
|
|
|
casper.then(function () {
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.waitUntilVisible("#compose", function () {
|
|
|
|
common.pm_recipient.expect(recipients.join(","));
|
2013-07-26 00:54:25 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2016-08-29 22:37:27 +02:00
|
|
|
casper.then(function () {
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.waitUntilVisible("#markdown_preview", function () {
|
|
|
|
casper.test.assertNotVisible("#undo_markdown_preview", "Write button is hidden");
|
2016-08-29 22:37:27 +02:00
|
|
|
casper.click("#markdown_preview");
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
casper.then(function () {
|
|
|
|
casper.waitWhileVisible("#markdown_preview", function () {
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.test.assertVisible("#undo_markdown_preview", "Write button is visible");
|
2020-07-15 00:34:28 +02:00
|
|
|
casper.test.assertEquals(
|
|
|
|
casper.getHTML("#preview_content"),
|
|
|
|
"Nothing to preview",
|
|
|
|
"Nothing to preview"
|
|
|
|
);
|
2016-08-29 22:37:27 +02:00
|
|
|
casper.click("#undo_markdown_preview");
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
casper.then(function () {
|
|
|
|
casper.waitWhileVisible("#undo_markdown_preview", function () {
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.test.assertVisible("#markdown_preview", "Preview button is visible.");
|
|
|
|
casper.test.assertNotVisible("#undo_markdown_preview", "Write button is hidden.");
|
2020-07-15 00:34:28 +02:00
|
|
|
casper.test.assertEquals(
|
|
|
|
casper.getHTML("#preview_content"),
|
|
|
|
"",
|
|
|
|
"Markdown preview area is empty"
|
|
|
|
);
|
2016-08-29 22:37:27 +02:00
|
|
|
|
2020-07-15 00:34:28 +02:00
|
|
|
casper.fill(
|
|
|
|
'form[action^="/json/messages"]',
|
|
|
|
{
|
|
|
|
content: "**Markdown Preview** >> Test for markdown preview",
|
|
|
|
},
|
|
|
|
false
|
|
|
|
);
|
2016-08-29 22:37:27 +02:00
|
|
|
|
|
|
|
casper.click("#markdown_preview");
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
casper.then(function () {
|
2017-02-01 02:37:56 +01:00
|
|
|
casper.waitForSelectorTextChange("#preview_content", function () {
|
2020-07-15 00:34:28 +02:00
|
|
|
casper.test.assertEquals(
|
|
|
|
casper.getHTML("#preview_content"),
|
|
|
|
"<p><strong>Markdown Preview</strong> >> Test for markdown preview</p>",
|
|
|
|
"Check markdown is previewed properly"
|
|
|
|
);
|
2016-08-29 22:37:27 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2013-03-05 20:52:54 +01:00
|
|
|
common.then_log_out();
|
2013-03-07 19:30:42 +01:00
|
|
|
|
|
|
|
casper.run(function () {
|
2013-06-13 16:56:50 +02:00
|
|
|
casper.test.done();
|
2013-03-05 20:52:54 +01:00
|
|
|
});
|