recent_view: Fix the muted topic being tested in spectator view.

The "test_filter_all" includes tests for muted and not muted topics,
but the 'is_spectator' field is set to 'true'.

Logically, it is incorrect because a topic can't have a
visibility policy set in spectator view.

This commit fixes the incorrect behavior and adds a separate test
for the case 'is_spectator=true'.

The issue was introduced in d0a697f.
This commit is contained in:
Prakhar Pratyush 2023-10-01 10:19:03 +05:30 committed by Tim Abbott
parent ba4c45aa90
commit ef16f1cb23
1 changed files with 35 additions and 3 deletions

View File

@ -449,9 +449,7 @@ test("test_recent_view_show", ({mock_template, override}) => {
assert.equal(rt.inplace_rerender("stream_unknown:topic_unknown"), false);
});
test("test_filter_all", ({mock_template}) => {
// Just tests inplace rerender of a message
// in All topics filter.
test("test_filter_is_spectator", ({mock_template}) => {
page_params.is_spectator = true;
const expected = {
filter_participated: false,
@ -474,6 +472,40 @@ test("test_filter_all", ({mock_template}) => {
return "<recent_view row stub>";
});
row_data = generate_topic_data([[1, "topic-1", 0, false]]);
i = row_data.length;
rt.clear_for_tests();
stub_out_filter_buttons();
recent_view_util.set_visible(true);
rt.set_filter("all");
rt.process_messages([messages[0]]);
});
test("test_filter_all", ({mock_template}) => {
// Just tests inplace rerender of a message
// in All topics filter.
page_params.is_spectator = false;
const expected = {
filter_participated: false,
filter_unread: false,
filter_muted: false,
filter_pm: false,
search_val: "",
is_spectator: false,
};
let row_data;
let i;
mock_template("recent_view_table.hbs", false, (data) => {
assert.deepEqual(data, expected);
});
mock_template("recent_view_row.hbs", false, (data) => {
i -= 1;
assert.deepEqual(data, row_data[i]);
return "<recent_view row stub>";
});
// topic is not muted
row_data = generate_topic_data([[1, "topic-1", 0, false]]);
i = row_data.length;