mirror of https://github.com/zulip/zulip.git
compose.js: Prevent sending empty messages in preview mode.
This commit specifically addresses the issue when in preview mode, while "enter sends" is enabled. Previously the messages were just sent, now they must pass validation. Fixes #5574.
This commit is contained in:
parent
6551640c67
commit
f7d1abaa25
|
@ -540,6 +540,8 @@ people.add(bob);
|
|||
}());
|
||||
|
||||
(function test_enter_with_preview_open() {
|
||||
// Test sending a message with content.
|
||||
$("#new_message_content").val('message me');
|
||||
$("#new_message_content").hide();
|
||||
$("#undo_markdown_preview").show();
|
||||
$("#preview_message_area").show();
|
||||
|
@ -560,6 +562,17 @@ people.add(bob);
|
|||
$("#new_message_content").blur();
|
||||
compose.enter_with_preview_open();
|
||||
assert($("#new_message_content").is_focused());
|
||||
|
||||
// Test sending a message without content.
|
||||
$("#new_message_content").val('');
|
||||
$("#preview_message_area").show();
|
||||
$("#enter_sends").prop("checked", true);
|
||||
page_params.enter_sends = true;
|
||||
|
||||
compose.enter_with_preview_open();
|
||||
|
||||
assert($("#enter_sends").prop("checked"));
|
||||
assert.equal($("#error-msg").html(), i18n.t('You have nothing to send!'));
|
||||
}());
|
||||
|
||||
(function test_finish() {
|
||||
|
|
|
@ -360,8 +360,8 @@ exports.send_message = function send_message(request) {
|
|||
exports.enter_with_preview_open = function () {
|
||||
exports.clear_preview_area();
|
||||
if (page_params.enter_sends) {
|
||||
// If enter_sends is enabled, we just send the message
|
||||
exports.send_message();
|
||||
// If enter_sends is enabled, we attempt to send the message
|
||||
exports.finish();
|
||||
} else {
|
||||
// Otherwise, we return to the compose box and focus it
|
||||
$("#new_message_content").focus();
|
||||
|
|
Loading…
Reference in New Issue