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.

compose fade: Add test for want_normal_display.

evykassirer0a33598f6558
diff --git a/web/tests/compose_fade.test.js b/web/tests/compose_fade.test.js
index 51363cb3692..92e75114c77 100644
--- a/web/tests/compose_fade.test.js
+++ b/web/tests/compose_fade.test.js
@@ -91,3 +91,52 @@ run_test("set_focused_recipient", ({override_rewire}) => {
assert.ok(!compose_fade_helper.should_fade_message(good_msg));
assert.ok(compose_fade_helper.should_fade_message(bad_msg));
});
+
+run_test("want_normal_display", () => {
+ const stream_id = 110;
+ const sub = {
+ stream_id,
+ name: "display testing",
+ subscribed: true,
+ };
+
+ stream_data.clear_subscriptions();
+
+ // No focused recipient.
+ compose_fade_helper.set_focused_recipient(undefined);
+ assert.ok(compose_fade_helper.want_normal_display());
+
+ // Focused recipient is a sub that doesn't exist.
+ compose_fade_helper.set_focused_recipient({
+ type: "stream",
+ stream_id,
+ topic: "",
+ });
+ assert.ok(compose_fade_helper.want_normal_display());
+
+ // Focused recipient is a valid stream with no topic set
+ stream_data.add_sub(sub);
+ assert.ok(compose_fade_helper.want_normal_display());
+
+ // If we're focused to a topic, then we do want to fade.
+ compose_fade_helper.set_focused_recipient({
+ type: "stream",
+ stream_id,
+ topic: "lunch",
+ });
+ assert.ok(!compose_fade_helper.want_normal_display());
+
+ // Private message with no recipient.
+ compose_fade_helper.set_focused_recipient({
+ type: "private",
+ reply_to: "",
+ });
+ assert.ok(compose_fade_helper.want_normal_display());
+
+ // Private message with a recipient.
+ compose_fade_helper.set_focused_recipient({
+ type: "private",
+ reply_to: "[email protected]",
+ });
+ assert.ok(!compose_fade_helper.want_normal_display());
+});