Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
tests: Use existing zjquery find method.
Anders Kaseorgc02eac619771
diff --git a/web/tests/pill_typeahead.test.cjs b/web/tests/pill_typeahead.test.cjsindex 2e92186942c..898eab5052b 100644--- a/web/tests/pill_typeahead.test.cjs+++ b/web/tests/pill_typeahead.test.cjs@@ -169,7 +169,7 @@ run_test("set_up_user", ({mock_template, override, override_rewire}) => {$fake_input.before = noop;const $container = $.create(".pill-container");- $container.find = () => $fake_input;+ $container.set_find_results(".input", $fake_input);const $pill_widget = input_pill.create({$container,@@ -261,7 +261,7 @@ run_test("set_up_stream", ({mock_template, override, override_rewire}) => {$fake_input.before = noop;const $container = $.create(".pill-container");- $container.find = () => $fake_input;+ $container.set_find_results(".input", $fake_input);const $pill_widget = input_pill.create({$container,@@ -354,7 +354,7 @@ run_test("set_up_user_group", ({mock_template, override, override_rewire}) => {$fake_input.before = noop;const $container = $.create(".pill-container");- $container.find = () => $fake_input;+ $container.set_find_results(".input", $fake_input);const $pill_widget = input_pill.create({$container,@@ -446,7 +446,7 @@ run_test("set_up_combined", ({mock_template, override, override_rewire}) => {$fake_input.before = noop;const $container = $.create(".pill-container");- $container.find = () => $fake_input;+ $container.set_find_results(".input", $fake_input);const $pill_widget = input_pill.create({$container,@@ -703,7 +703,7 @@ run_test("set_up_group_setting_typeahead", ({mock_template, override, override_r$fake_input.before = noop;const $container = $.create(".pill-container");- $container.find = () => $fake_input;+ $container.set_find_results(".input", $fake_input);const $pill_widget = input_pill.create({$container,diff --git a/web/tests/reactions.test.cjs b/web/tests/reactions.test.cjsindex cb6eee539cc..51c19c21081 100644--- a/web/tests/reactions.test.cjs+++ b/web/tests/reactions.test.cjs@@ -932,12 +932,18 @@ test("insert_new_reaction (me w/unicode emoji)", ({mock_template}) => {const $message_reactions = stub_reactions(message_id);const $reaction_button = $.create("reaction-button-stub");- $message_reactions.find = () => $reaction_button;+ $message_reactions.set_find_results(".reaction_button", $reaction_button);const $message_reactions_count = $.create("message-reaction-count-stub");- $reaction_button.find = (selector) => {- assert.equal(selector, ".message_reaction_count");- return $message_reactions_count;- };+ const $reaction = $.create("reaction-stub");+ $reaction.set_find_results(".message_reaction_count", $message_reactions_count);+ $message_reactions.set_find_results(+ `[data-reaction-id='${CSS.escape("unicode_emoji,1f44d")}']`,+ $reaction,+ );+ $message_reactions.set_find_results(+ `[data-reaction-id='${CSS.escape("unicode_emoji,1f3b1")}']`,+ $reaction,+ );mock_template("message_reaction.hbs", false, (data) => {assert.deepEqual(data, {@@ -1002,12 +1008,18 @@ test("insert_new_reaction (them w/zulip emoji)", ({mock_template}) => {const $message_reactions = stub_reactions(message_id);const $reaction_button = $.create("reaction-button-stub");- $message_reactions.find = () => $reaction_button;+ $message_reactions.set_find_results(".reaction_button", $reaction_button);const $message_reactions_count = $.create("message-reaction-count-stub");- $reaction_button.find = (selector) => {- assert.equal(selector, ".message_reaction_count");- return $message_reactions_count;- };+ const $reaction = $.create("reaction-stub");+ $reaction.set_find_results(".message_reaction_count", $message_reactions_count);+ $message_reactions.set_find_results(+ `[data-reaction-id='${CSS.escape("unicode_emoji,1f44d")}']`,+ $reaction,+ );+ $message_reactions.set_find_results(+ `[data-reaction-id='${CSS.escape("unicode_emoji,1f3b1")}']`,+ $reaction,+ );mock_template("message_reaction.hbs", false, (data) => {assert.deepEqual(data, {@@ -1175,8 +1187,8 @@ test("remove_reaction_from_view (me)", () => {const $message_reactions = stub_reaction(message_id, "unicode_emoji,1f3b1");$message_reactions.addClass("reacted");- const $reaction_button = $.create("reaction-button-stub");- $message_reactions.find = () => $reaction_button;+ const $message_reactions_count = $.create("message-reaction-count-stub");+ $message_reactions.set_find_results(".message_reaction_count", $message_reactions_count);const message = {id: message_id,@@ -1222,8 +1234,8 @@ test("remove_reaction_from_view (them)", () => {const $message_reactions = stub_reaction(message_id, "unicode_emoji,1f3b1");$message_reactions.addClass("reacted");- const $reaction_button = $.create("reaction-button-stub");- $message_reactions.find = () => $reaction_button;+ const $message_reactions_count = $.create("message-reaction-count-stub");+ $message_reactions.set_find_results(".message_reaction_count", $message_reactions_count);const message = {id: message_id,@@ -1313,7 +1325,10 @@ test("remove_reaction_from_view (last reaction)", () => {// Create a stub for the specific reactionconst $specific_reaction = $.create("specific-reaction-stub");- $message_reactions.find = () => $specific_reaction;+ $message_reactions.set_find_results(+ `[data-reaction-id='${CSS.escape("unicode_emoji,1f3b1")}']`,+ $specific_reaction,+ );let removed = false;$message_reactions.remove = () => {