2015-10-14 00:21:23 +02:00
|
|
|
var common = require('../casper_lib/common.js').common;
|
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
|
|
|
|
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([
|
|
|
|
{ stream: 'Verona',
|
|
|
|
subject: 'Reply test',
|
|
|
|
content: "We reply to this message"
|
|
|
|
},
|
|
|
|
{ recipient: "cordelia@zulip.com",
|
|
|
|
content: "And reply to this message"
|
|
|
|
}
|
|
|
|
]);
|
2013-06-11 23:08:11 +02:00
|
|
|
|
2013-06-13 16:56:50 +02:00
|
|
|
casper.waitForText("And reply to this message", function () {
|
|
|
|
// TODO: Test opening the compose box from the left side buttons
|
2013-06-11 23:08:11 +02:00
|
|
|
casper.click('body');
|
2013-05-15 20:06:06 +02:00
|
|
|
casper.page.sendEvent('keypress', "c");
|
2013-06-13 16:56:50 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
casper.waitUntilVisible('#compose', function () {
|
2013-03-07 19:30:42 +01:00
|
|
|
casper.test.assertVisible('#stream', 'Stream input box visible');
|
2013-06-11 23:08:11 +02:00
|
|
|
common.check_form('#send_message_form', {stream: '', subject: ''}, "Stream empty on new compose");
|
2013-05-15 20:06:06 +02:00
|
|
|
casper.click('body');
|
|
|
|
casper.page.sendEvent('keypress', "C");
|
2013-06-13 16:56:50 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
casper.waitUntilVisible('#private_message_recipient', function () {
|
2013-06-11 23:08:11 +02:00
|
|
|
common.check_form('#send_message_form', {recipient: ''}, "Recipient empty on new PM");
|
2013-05-15 20:06:06 +02:00
|
|
|
casper.click('body');
|
|
|
|
casper.page.sendEvent('keypress', 'c');
|
2013-06-13 16:56:50 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
casper.waitUntilVisible('#stream', function () {
|
2013-06-11 23:08:11 +02:00
|
|
|
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');
|
2013-07-15 23:44:59 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
casper.waitWhileVisible('#stream', function () {
|
2013-06-11 23:08:11 +02:00
|
|
|
casper.clickLabel("We reply to this message");
|
2013-06-13 16:56:50 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
casper.waitUntilVisible('#stream', function () {
|
2013-06-11 23:08:11 +02:00
|
|
|
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");
|
2013-06-13 16:56:50 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
casper.waitUntilVisible('#private_message_recipient', function () {
|
2013-07-24 20:41:09 +02:00
|
|
|
common.check_form('#send_message_form', {recipient: "cordelia@zulip.com"}, "Recipient populated after PM click");
|
2013-06-11 23:08:11 +02:00
|
|
|
|
|
|
|
common.keypress(27); //escape
|
|
|
|
casper.page.sendEvent('keypress', 'k');
|
|
|
|
casper.page.sendEvent('keypress', 'r');
|
2013-06-13 16:56:50 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
casper.waitUntilVisible('#stream', function () {
|
2013-06-11 23:08:11 +02:00
|
|
|
common.check_form('#send_message_form', {stream: "Verona", subject: "Reply test"}, "Stream populated after reply with `r`");
|
2013-03-07 19:30:42 +01:00
|
|
|
|
2013-05-03 22:16:52 +02:00
|
|
|
// Test "closing" the compose box
|
|
|
|
casper.click('body');
|
2013-03-07 19:30:42 +01:00
|
|
|
});
|
|
|
|
|
2013-06-13 16:56:50 +02:00
|
|
|
casper.waitWhileVisible('#stream', function () {
|
2013-05-03 22:16:52 +02:00
|
|
|
casper.test.assertNotVisible('#stream', 'Close stream compose box');
|
2013-05-15 20:06:06 +02:00
|
|
|
casper.page.sendEvent('keypress', "C");
|
2013-05-03 22:16:52 +02:00
|
|
|
casper.click('body');
|
2013-03-07 19:30:42 +01:00
|
|
|
});
|
|
|
|
|
2013-06-13 16:56:50 +02:00
|
|
|
casper.waitWhileVisible('#private-message', function () {
|
2013-05-03 22:16:52 +02:00
|
|
|
casper.test.assertNotVisible('#private-message', 'Close PM compose box');
|
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"]');
|
|
|
|
});
|
|
|
|
casper.waitUntilVisible('#tab_list li.private_message', function () {
|
|
|
|
casper.page.sendEvent('keypress', 'c');
|
|
|
|
});
|
|
|
|
casper.waitUntilVisible('#compose', function () {
|
|
|
|
casper.test.assertEval(function () {
|
|
|
|
return document.activeElement === $('#stream')[0];
|
|
|
|
}, 'Stream box focused after narrowing to PMs with a user and pressing `c`');
|
|
|
|
});
|
|
|
|
|
2013-07-26 00:54:25 +02:00
|
|
|
// Make sure multiple PM recipients display properly.
|
|
|
|
var recipients = ['cordelia@zulip.com', 'othello@zulip.com'];
|
|
|
|
casper.then(function () {
|
|
|
|
common.keypress(27); // escape to dismiss compose box
|
|
|
|
});
|
2014-03-07 20:58:18 +01:00
|
|
|
casper.waitWhileVisible('.message_comp');
|
2014-03-07 20:59:30 +01:00
|
|
|
common.then_send_many([
|
2014-03-07 20:58:18 +01:00
|
|
|
{ recipient: recipients.join(','),
|
|
|
|
content: 'A huddle to check spaces' }]);
|
2014-03-07 20:55:33 +01:00
|
|
|
|
|
|
|
casper.then(function () {
|
|
|
|
common.keypress(27); // escape to dismiss compose box
|
|
|
|
});
|
|
|
|
casper.then(function () {
|
2013-07-26 00:54:25 +02:00
|
|
|
common.un_narrow();
|
|
|
|
});
|
2014-03-07 20:55:33 +01:00
|
|
|
casper.waitUntilVisible('#zhome', function () {
|
2013-07-26 00:54:25 +02:00
|
|
|
casper.clickLabel('A huddle to check spaces');
|
|
|
|
});
|
|
|
|
casper.waitUntilVisible('#compose', function () {
|
|
|
|
// It may be possible to get the textbox contents with CasperJS,
|
|
|
|
// but it's easier to just evaluate jQuery in page context here.
|
|
|
|
var displayed_recipients = casper.evaluate(function () {
|
|
|
|
return $('#private_message_recipient').val();
|
|
|
|
});
|
|
|
|
casper.test.assertEquals(displayed_recipients, recipients.join(', '),
|
|
|
|
'Recipients are displayed correctly in a huddle reply');
|
|
|
|
});
|
|
|
|
|
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
|
|
|
});
|