2015-10-14 00:21:23 +02:00
|
|
|
var common = require('../casper_lib/common.js').common;
|
2013-08-20 18:20:10 +02:00
|
|
|
|
|
|
|
common.start_and_log_in();
|
|
|
|
|
|
|
|
function then_edit_last_message() {
|
|
|
|
casper.then(function () {
|
|
|
|
casper.evaluate(function () {
|
|
|
|
var msg = $('#zhome .message_row:last');
|
|
|
|
msg.find('.info').click();
|
|
|
|
$('.popover_edit_message').click();
|
|
|
|
});
|
|
|
|
});
|
2017-02-10 07:58:24 +01:00
|
|
|
casper.then(function () {
|
|
|
|
casper.waitUntilVisible(".message_edit_content");
|
|
|
|
});
|
2013-08-20 18:20:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Send and edit a stream message
|
|
|
|
|
2014-03-07 20:59:30 +01:00
|
|
|
common.then_send_message('stream', {
|
2013-08-20 18:20:10 +02:00
|
|
|
stream: 'Verona',
|
|
|
|
subject: 'edits',
|
2016-12-03 23:18:30 +01:00
|
|
|
content: 'test editing',
|
2013-08-20 18:20:10 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
casper.waitForText("test editing");
|
2016-10-03 14:07:45 +02:00
|
|
|
common.wait_for_message_actually_sent();
|
2013-08-20 18:20:10 +02:00
|
|
|
|
|
|
|
then_edit_last_message();
|
|
|
|
|
|
|
|
casper.then(function () {
|
|
|
|
casper.evaluate(function () {
|
|
|
|
var msg = $('#zhome .message_row:last');
|
|
|
|
msg.find('.message_edit_topic').val("edited");
|
|
|
|
msg.find('.message_edit_content').val("test edited");
|
|
|
|
msg.find('.message_edit_save').click();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2016-06-30 01:52:09 +02:00
|
|
|
casper.waitWhileVisible("textarea.message_edit_content", function () {
|
2013-08-20 18:20:10 +02:00
|
|
|
casper.test.assertSelectorHasText(".last_message .message_content", "test edited");
|
|
|
|
});
|
|
|
|
|
2016-05-31 14:24:58 +02:00
|
|
|
common.then_send_message('stream', {
|
|
|
|
stream: 'Verona',
|
|
|
|
subject: 'edits',
|
2016-12-03 23:18:30 +01:00
|
|
|
content: '/me test editing one line with me',
|
2016-05-31 14:24:58 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
casper.waitForText("test editing one line with me");
|
2016-10-03 14:07:45 +02:00
|
|
|
common.wait_for_message_actually_sent();
|
2016-05-31 14:24:58 +02:00
|
|
|
|
|
|
|
then_edit_last_message();
|
|
|
|
|
|
|
|
casper.then(function () {
|
|
|
|
casper.evaluate(function () {
|
|
|
|
var msg = $('#zhome .message_row:last');
|
|
|
|
msg.find('.message_edit_topic').val("edited");
|
|
|
|
msg.find('.message_edit_content').val("/me test edited one line with me");
|
|
|
|
msg.find('.message_edit_save').click();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2016-06-30 01:52:09 +02:00
|
|
|
casper.waitWhileVisible("textarea.message_edit_content", function () {
|
2016-05-31 14:24:58 +02:00
|
|
|
casper.test.assertSelectorHasText(".last_message .sender-status", "test edited one line with me");
|
|
|
|
});
|
|
|
|
|
2014-03-07 20:59:30 +01:00
|
|
|
common.then_send_message('private', {
|
2013-08-20 18:20:10 +02:00
|
|
|
recipient: "cordelia@zulip.com",
|
2016-12-03 23:18:30 +01:00
|
|
|
content: "test editing pm",
|
2013-08-20 18:20:10 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
casper.waitForText("test editing pm");
|
2016-10-03 14:07:45 +02:00
|
|
|
common.wait_for_message_actually_sent();
|
2013-08-20 18:20:10 +02:00
|
|
|
then_edit_last_message();
|
|
|
|
|
|
|
|
casper.then(function () {
|
|
|
|
casper.evaluate(function () {
|
|
|
|
var msg = $('#zhome .message_row:last');
|
|
|
|
msg.find('.message_edit_content').val("test edited pm");
|
|
|
|
msg.find('.message_edit_save').click();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2016-11-23 05:06:34 +01:00
|
|
|
casper.then(function () {
|
|
|
|
casper.waitWhileVisible("textarea.message_edit_content", function () {
|
|
|
|
casper.test.assertSelectorHasText(".last_message .message_content", "test edited pm");
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
// test editing last own message
|
|
|
|
// 37 is left arrow key code
|
|
|
|
casper.then(function () {
|
|
|
|
casper.test.assertNotVisible('form.message_edit_form', 'Message edit box not visible');
|
|
|
|
|
|
|
|
common.keypress(37);
|
|
|
|
casper.waitUntilVisible("#message_edit_content", function () {
|
|
|
|
var fieldVal = common.get_form_field_value('#message_edit_content');
|
|
|
|
casper.test.assertEquals(fieldVal, "test edited pm", "Opened editing last own message");
|
|
|
|
casper.click('.message_edit_cancel');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
casper.then(function () {
|
|
|
|
casper.waitWhileVisible('.message_edit', function () {
|
|
|
|
casper.click('body');
|
|
|
|
casper.page.sendEvent('keypress', "c");
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
casper.then(function () {
|
|
|
|
casper.waitUntilVisible('#compose', function () {
|
|
|
|
casper.evaluate(function () {
|
|
|
|
$('#new_message_content').expectOne().focus();
|
|
|
|
$('#new_message_content').trigger($.Event('keydown', { which: 37 }));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
casper.then(function () {
|
|
|
|
casper.waitUntilVisible(".message_edit_form", function () {
|
|
|
|
casper.echo("Opened editing last own message");
|
|
|
|
casper.click('.message_edit_cancel');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
casper.then(function () {
|
|
|
|
casper.waitWhileVisible('.message_edit', function () {
|
|
|
|
casper.click('body');
|
|
|
|
casper.page.sendEvent('keypress', "c");
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
casper.then(function () {
|
|
|
|
casper.waitUntilVisible('#compose', function () {
|
|
|
|
casper.evaluate(function () {
|
|
|
|
$('#new_message_content').expectOne().focus().val('test');
|
|
|
|
$('#new_message_content').trigger($.Event('keydown', { which: 37 }));
|
|
|
|
});
|
|
|
|
casper.test.assertNotVisible('form.message_edit_form', "Last own message edit doesn't open if the compose box not empty");
|
|
|
|
});
|
2013-08-20 18:20:10 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
casper.run(function () {
|
|
|
|
casper.test.done();
|
|
|
|
});
|