mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 05:23:35 +00:00
recent_topics: Explicitly override is_visible & is_in_focus in tests.
Previously, the tests relied on `recent_topics_util.is_visible`
returning false unless we used override to return true, this is
because `recent_topics_util.is_viible` would return
`$("#recent_topics_view").is(":visible");` which would always be false
since we don't create a stub for `$("#recent_topics_view")`.
This would cause the tests to fail if we changed how `is_visible`
found it's return value, which we want to do for performance reasons,
and as such, this commit adds explicit overrides where needed.
Further more, even when we do override `is_visible` as override(rt,
"is_in_focus", ...) we do not override the `is_visible` used in
`recent_topics_uttil.is_in_focus`, and so our tests stil rely on that
`is_visible` always returning false. This commit address that by also
adding explicit overrides for `is_in_focus` where needed.
This commit is contained in:
@@ -414,6 +414,7 @@ test("test_filter_all", ({override, mock_template}) => {
|
||||
row_data = generate_topic_data([[1, "topic-1", 0, false, true]]);
|
||||
i = row_data.length;
|
||||
rt.set_default_focus();
|
||||
override(rt, "is_in_focus", () => false);
|
||||
assert.equal(rt.inplace_rerender("1:topic-1"), true);
|
||||
});
|
||||
|
||||
@@ -464,6 +465,7 @@ test("test_filter_unread", ({override, mock_template}) => {
|
||||
|
||||
stub_out_filter_buttons();
|
||||
rt.process_messages(messages);
|
||||
override(rt, "is_in_focus", () => false);
|
||||
assert.equal(rt.inplace_rerender("1:topic-1"), true);
|
||||
|
||||
$("#recent_topics_filter_buttons").removeClass("btn-recent-selected");
|
||||
@@ -571,6 +573,7 @@ test("test_filter_participated", ({override, mock_template}) => {
|
||||
expected_filter_participated = false;
|
||||
rt.process_messages(messages);
|
||||
|
||||
override(rt, "is_in_focus", () => false);
|
||||
assert.equal(rt.inplace_rerender("1:topic-4"), true);
|
||||
|
||||
// Set muted filter
|
||||
@@ -630,7 +633,8 @@ test("test_filter_participated", ({override, mock_template}) => {
|
||||
rt.set_filter("all");
|
||||
});
|
||||
|
||||
test("test_update_unread_count", () => {
|
||||
test("test_update_unread_count", ({override}) => {
|
||||
override(rt, "is_visible", () => false);
|
||||
rt.clear_for_tests();
|
||||
stub_out_filter_buttons();
|
||||
rt.set_filter("all");
|
||||
@@ -758,6 +762,7 @@ test("basic assertions", ({override, mock_template}) => {
|
||||
// update_topic_is_muted now relies on external libraries completely
|
||||
// so we don't need to check anythere here.
|
||||
generate_topic_data([[1, topic1, 0, false, true]]);
|
||||
override(rt, "is_in_focus", () => false);
|
||||
assert.equal(rt.update_topic_is_muted(stream1, topic1), true);
|
||||
// a topic gets muted which we are not tracking
|
||||
assert.equal(rt.update_topic_is_muted(stream1, "topic-10"), false);
|
||||
@@ -816,6 +821,7 @@ test("test_reify_local_echo_message", ({override, mock_template}) => {
|
||||
});
|
||||
|
||||
test("test_delete_messages", ({override}) => {
|
||||
override(rt, "is_visible", () => false);
|
||||
rt.clear_for_tests();
|
||||
stub_out_filter_buttons();
|
||||
rt.set_filter("all");
|
||||
@@ -855,6 +861,7 @@ test("test_delete_messages", ({override}) => {
|
||||
|
||||
test("test_topic_edit", ({override}) => {
|
||||
override(all_messages_data, "all_messages", () => messages);
|
||||
override(rt, "is_visible", () => false);
|
||||
|
||||
// NOTE: This test should always run in the end as it modified the messages data.
|
||||
rt.clear_for_tests();
|
||||
|
||||
Reference in New Issue
Block a user