Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
compose-closed-ui: Add assert for inbox or recent view.
Lauryn Menard139fe3768b1d
diff --git a/web/src/compose_closed_ui.ts b/web/src/compose_closed_ui.tsindex 2b385c0b92d..961366eea73 100644--- a/web/src/compose_closed_ui.ts+++ b/web/src/compose_closed_ui.ts@@ -1,15 +1,18 @@import $ from "jquery";+import assert from "minimalistic-assert";import render_reply_recipient_label from "../templates/reply_recipient_label.hbs";import * as compose_actions from "./compose_actions.ts";import {$t} from "./i18n.ts";+import * as inbox_util from "./inbox_util.ts";import * as message_lists from "./message_lists.ts";import * as message_store from "./message_store.ts";import * as message_util from "./message_util.ts";import * as narrow_state from "./narrow_state.ts";import {page_params} from "./page_params.ts";import * as people from "./people.ts";+import * as recent_view_util from "./recent_view_util.ts";import * as stream_data from "./stream_data.ts";import * as util from "./util.ts";@@ -43,7 +46,8 @@ export function get_recipient_label(recipient_information?: ReplyRecipientInformation,): RecipientLabel | undefined {if (recipient_information !== undefined) {- // If we're in either the Inbox or Recent Conversations view,+ assert(recent_view_util.is_visible() || inbox_util.is_visible());+ // When we're in either the Inbox or Recent Conversations view,// we try to update the closed compose box button label with// information about the reply target from the focused row in// the view.diff --git a/web/tests/compose_closed_ui.test.cjs b/web/tests/compose_closed_ui.test.cjsindex fb930686bf4..440aaa3c378 100644--- a/web/tests/compose_closed_ui.test.cjs+++ b/web/tests/compose_closed_ui.test.cjs@@ -10,6 +10,7 @@ const $ = require("./lib/zjquery.cjs");// Mocking and stubbing thingsset_global("document", "document-stub");const message_lists = mock_esm("../src/message_lists");+const recent_view_util = mock_esm("../src/recent_view_util");function MessageListView() {return {maybe_rerender: noop,@@ -163,23 +164,40 @@ run_test("reply_label", () => {);});-run_test("test_custom_message_input", () => {+run_test("empty_narrow", () => {+ message_lists.current.visibly_empty = () => true;+ compose_closed_ui.update_recipient_text_for_reply_button();+ const label = $("#left_bar_compose_reply_button_big").text();+ assert.equal(label, "translated: Compose message");+});++run_test("test_non_message_list_input", () => {+ message_lists.current = undefined;+ recent_view_util.is_visible = () => true;const stream = {subscribed: true,name: "stream test",stream_id: 10,};stream_data.add_sub(stream);++ // Channel and topic row.compose_closed_ui.update_recipient_text_for_reply_button({stream_id: stream.stream_id,topic: "topic test",});test_reply_label("#stream test > topic test");-});-run_test("empty_narrow", () => {- message_lists.current.visibly_empty = () => true;- compose_closed_ui.update_recipient_text_for_reply_button();+ // Direct message row.+ compose_closed_ui.update_recipient_text_for_reply_button({+ display_reply_to: "some user",+ });+ test_reply_label("some user");++ // Invalid data for a the reply button text.+ compose_closed_ui.update_recipient_text_for_reply_button({+ invalid_field: "something unexpected",+ });const label = $("#left_bar_compose_reply_button_big").text();assert.equal(label, "translated: Compose message");});