Compare commits

...

2 Commits

Author SHA1 Message Date
evykassirer
1d0e5b1b4e compose fade: Add test for want_normal_display. 2023-10-26 17:35:41 -07:00
evykassirer
5c77244fb0 buddy list: Simplify argument to get_data_from_keys. 2023-10-26 17:35:41 -07:00
3 changed files with 52 additions and 7 deletions

View File

@@ -35,8 +35,7 @@ class BuddyListConf {
return Number.parseInt(opts.$li.expectOne().attr("data-user-id"), 10);
}
get_data_from_keys(opts) {
const keys = opts.keys;
get_data_from_keys(keys) {
const data = buddy_data.get_items_for_users(keys);
return data;
}
@@ -80,9 +79,7 @@ export class BuddyList extends BuddyListConf {
return;
}
const items = this.get_data_from_keys({
keys: more_keys,
});
const items = this.get_data_from_keys(more_keys);
const html = this.items_to_html({
items,

View File

@@ -57,8 +57,7 @@ run_test("basics", ({override}) => {
const buddy_list = new BuddyList();
init_simulated_scrolling();
override(buddy_list, "get_data_from_keys", (opts) => {
const keys = opts.keys;
override(buddy_list, "get_data_from_keys", (keys) => {
assert.deepEqual(keys, [alice.user_id]);
return "data-stub";
});

View File

@@ -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: "hello@zulip.com",
});
assert.ok(!compose_fade_helper.want_normal_display());
});