Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

node tests: Broaden what FakeComposeBox.reset does.

Steve Howella6f2197091fe
diff --git a/web/tests/compose_validate.test.cjs b/web/tests/compose_validate.test.cjs
index ede5f0d1b3f..274374b00ae 100644
--- a/web/tests/compose_validate.test.cjs
+++ b/web/tests/compose_validate.test.cjs
@@ -3,6 +3,7 @@
const assert = require("node:assert/strict");
const {mock_banners} = require("./lib/compose_banner.cjs");
+const {FakeComposeBox} = require("./lib/compose_helpers.cjs");
const {$t} = require("./lib/i18n.cjs");
const {mock_esm, zrequire} = require("./lib/namespace.cjs");
const {run_test, noop} = require("./lib/test.cjs");
@@ -116,7 +117,11 @@ function stub_message_row($textarea) {
}
test_ui("validate_stream_message_address_info", ({mock_template}) => {
- mock_banners();
+ // For this test we basically only use FakeComposeBox
+ // to set up the DOM environment. We don't assert about
+ // any side effects on the DOM, since the scope of this
+ // test is mostly to make sure the template gets rendered.
+ new FakeComposeBox();
const party_sub = {
stream_id: 101,
@@ -128,7 +133,6 @@ test_ui("validate_stream_message_address_info", ({mock_template}) => {
party_sub.subscribed = false;
stream_data.add_sub(party_sub);
- $("#compose_banners .user_not_subscribed").length = 0;
let user_not_subscribed_rendered = false;
mock_template("compose_banner/compose_banner.hbs", true, (data, html) => {
assert.equal(data.classname, compose_banner.CLASSNAMES.user_not_subscribed);
@@ -142,7 +146,9 @@ test_ui("validate_stream_message_address_info", ({mock_template}) => {
party_sub.stream_id = 102;
stream_data.add_sub(party_sub);
user_not_subscribed_rendered = false;
+
assert.ok(!compose_validate.validate_stream_message_address_info(party_sub));
+
assert.ok(user_not_subscribed_rendered);
});
diff --git a/web/tests/lib/compose_helpers.cjs b/web/tests/lib/compose_helpers.cjs
index b1ac6e7edc4..b643648a6ff 100644
--- a/web/tests/lib/compose_helpers.cjs
+++ b/web/tests/lib/compose_helpers.cjs
@@ -17,7 +17,6 @@ class FakeComposeBox {
".message-limit-indicator",
$.create("limit-indicator-stub"),
);
- $("textarea#compose-textarea").toggleClass = noop;
const $message_row_stub = $.create("message_row_stub");
$("textarea#compose-textarea").closest = (selector) => {
@@ -26,13 +25,15 @@ class FakeComposeBox {
return $message_row_stub;
};
- $("textarea#compose-textarea").set_height(50);
- $("#compose .preview_message_area").css = noop;
-
this.reset();
}
reset() {
+ $("#compose_banners .user_not_subscribed").length = 0;
+
+ $("textarea#compose-textarea").toggleClass = noop;
+ $("textarea#compose-textarea").set_height(50);
+ $("#compose .preview_message_area").css = noop;
$("textarea#compose-textarea").val("default message");
$("textarea#compose-textarea").trigger("blur");
$(".compose-submit-button .loader").show();