Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
tests: Expand coverage for compare_by_pms in typeahead_helper.
Tanuj kinkara69157f25409
diff --git a/web/tests/typeahead_helper.test.cjs b/web/tests/typeahead_helper.test.cjsindex cb90ed214e9..9af87a11b5c 100644--- a/web/tests/typeahead_helper.test.cjs+++ b/web/tests/typeahead_helper.test.cjs@@ -1122,10 +1122,37 @@ test("compare_language", () => {assert.equal(th.compare_language("custom_a", "custom_b"), util.strcmp("custom_a", "custom_b"));});-// TODO: This is incomplete for testing this function, and-// should be filled out more. This case was added for codecov.test("compare_by_pms", () => {+ // Same user should return 0assert.equal(th.compare_by_pms(a_user, a_user), 0);++ // Alphabetical fallback when PM counts and partner status are equal+ assert.equal(+ th.compare_by_pms(a_user, b_user_1),+ util.strcmp(a_user.full_name, b_user_1.full_name),+ );++ // Reverse order should match strcmp behavior+ assert.equal(+ th.compare_by_pms(b_user_1, a_user),+ util.strcmp(b_user_1.full_name, a_user.full_name),+ );++ pm_conversations.set_partner(b_user_1.user_id);++ // PM count takes priority over partner status+ people.set_recipient_count_for_testing(a_user.user_id, 10);+ people.set_recipient_count_for_testing(b_user_1.user_id, 5);++ assert.equal(th.compare_by_pms(a_user, b_user_1), -1);+ assert.equal(th.compare_by_pms(b_user_1, a_user), 1);++ // Partner priority when counts are equal+ people.set_recipient_count_for_testing(a_user.user_id, 0);+ people.set_recipient_count_for_testing(b_user_1.user_id, 0);++ assert.equal(th.compare_by_pms(a_user, b_user_1), 1);+ assert.equal(th.compare_by_pms(b_user_1, a_user), -1);});test("sort_group_setting_options", ({override_rewire}) => {