diff --git a/frontend_tests/node_tests/message_list_view.js b/frontend_tests/node_tests/message_list_view.js index fbfa80c465..0458c2d16c 100644 --- a/frontend_tests/node_tests/message_list_view.js +++ b/frontend_tests/node_tests/message_list_view.js @@ -44,6 +44,12 @@ mock_esm("../../static/js/rows", { }, }); +mock_esm("../../static/js/people", { + sender_is_bot: () => false, + sender_is_guest: () => false, + small_avatar_url: () => "fake/small/avatar/url", +}); + const {Filter} = zrequire("../js/filter"); const {MessageListView} = zrequire("../js/message_list_view"); const message_list = zrequire("message_list"); @@ -283,6 +289,11 @@ test("muted_message_vars", () => { // Sender is not muted. let result = calculate_variables(list, messages); + // sanity check on mocked values + assert.equal(result[1].sender_is_bot, false); + assert.equal(result[1].sender_is_guest, false); + assert.equal(result[1].small_avatar_url, "fake/small/avatar/url"); + // Check that `is_hidden` is false on all messages, and `include_sender` has not changed. assert.equal(result[0].is_hidden, false); assert.equal(result[1].is_hidden, false); diff --git a/static/js/message_list_view.js b/static/js/message_list_view.js index 74f464eba6..2d9740a6f0 100644 --- a/static/js/message_list_view.js +++ b/static/js/message_list_view.js @@ -295,6 +295,16 @@ export class MessageListView { message_container.include_sender = true; } + message_container.sender_is_bot = people.sender_is_bot(message_container.msg); + message_container.sender_is_guest = people.sender_is_guest(message_container.msg); + + message_container.small_avatar_url = people.small_avatar_url(message_container.msg); + if (message_container.msg.stream) { + message_container.background_color = stream_data.get_color( + message_container.msg.stream, + ); + } + this._maybe_format_me_message(message_container); // Once all other variables are updated this._add_msg_edited_vars(message_container); @@ -411,16 +421,6 @@ export class MessageListView { message_container.include_sender = false; } - message_container.sender_is_bot = people.sender_is_bot(message_container.msg); - message_container.sender_is_guest = people.sender_is_guest(message_container.msg); - - message_container.small_avatar_url = people.small_avatar_url(message_container.msg); - if (message_container.msg.stream) { - message_container.background_color = stream_data.get_color( - message_container.msg.stream, - ); - } - this.set_calculated_message_container_variables(message_container); prev = message_container;