From 912c5a28f299a8953f5ccb312bc67dc2e8b94679 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Fri, 19 Feb 2021 21:51:39 -0800 Subject: [PATCH] puppeteer_tests: Replace deprecated jQuery event trigger shorthand. Signed-off-by: Anders Kaseorg --- frontend_tests/puppeteer_lib/common.js | 2 +- .../puppeteer_tests/02-message-basics.js | 6 ++++-- .../puppeteer_tests/07-navigation.js | 2 +- frontend_tests/puppeteer_tests/08-admin.js | 20 +++++++++---------- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/frontend_tests/puppeteer_lib/common.js b/frontend_tests/puppeteer_lib/common.js index 2711ef36e3..f344f56bea 100644 --- a/frontend_tests/puppeteer_lib/common.js +++ b/frontend_tests/puppeteer_lib/common.js @@ -34,7 +34,7 @@ class CommonUtils { }); await page.evaluate(() => { - $(".typeahead-menu .active a:visible").click(); + $(".typeahead-menu .active a:visible").trigger("click"); }); }, diff --git a/frontend_tests/puppeteer_tests/02-message-basics.js b/frontend_tests/puppeteer_tests/02-message-basics.js index 3e391cf410..469994bd7c 100644 --- a/frontend_tests/puppeteer_tests/02-message-basics.js +++ b/frontend_tests/puppeteer_tests/02-message-basics.js @@ -87,7 +87,7 @@ async function un_narrow_by_clicking_org_icon(page) { async function test_navigations_from_home(page) { console.log("Narrowing by clicking stream"); - await page.evaluate(() => $(`*[title='Narrow to stream "Verona"']`).click()); + await page.evaluate(() => $(`*[title='Narrow to stream "Verona"']`).trigger("click")); await expect_verona_stream(page); assert.strictEqual(await page.title(), "Verona - Zulip Dev - Zulip"); @@ -103,7 +103,9 @@ async function test_navigations_from_home(page) { console.log("Narrowing by clicking group personal header"); await page.evaluate(() => - $('*[title="Narrow to your private messages with Cordelia Lear, King Hamlet"]').click(), + $('*[title="Narrow to your private messages with Cordelia Lear, King Hamlet"]').trigger( + "click", + ), ); await expect_huddle(page); diff --git a/frontend_tests/puppeteer_tests/07-navigation.js b/frontend_tests/puppeteer_tests/07-navigation.js index 9f23d3b998..a3dd2d5b42 100644 --- a/frontend_tests/puppeteer_tests/07-navigation.js +++ b/frontend_tests/puppeteer_tests/07-navigation.js @@ -85,7 +85,7 @@ async function navigation_tests(page) { // Hardcoded this instead of using `navigate_to` // as Puppeteer cannot click hidden elements. - await page.evaluate(() => $("a[href='#message_feed_container]'").click()); + await page.evaluate(() => $("a[href='#message_feed_container]'").trigger("click")); await wait_for_tab(page, "message_feed_container"); await navigate_to_subscriptions(page); diff --git a/frontend_tests/puppeteer_tests/08-admin.js b/frontend_tests/puppeteer_tests/08-admin.js index 188e953b3c..06f68af318 100644 --- a/frontend_tests/puppeteer_tests/08-admin.js +++ b/frontend_tests/puppeteer_tests/08-admin.js @@ -41,7 +41,7 @@ async function test_change_new_stream_notifications_setting(page) { await common.wait_for_text(page, verona_in_dropdown, "Verona"); await page.waitForSelector(verona_in_dropdown, {visible: true}); - await page.evaluate((selector) => $(selector).click(), verona_in_dropdown); + await page.evaluate((selector) => $(selector).trigger("click"), verona_in_dropdown); await submit_notifications_stream_settings(page); @@ -103,42 +103,42 @@ async function submit_stream_permissions_change(page) { async function test_set_create_streams_to_admins_only(page) { console.log("Test setting create streams policy to 'admins only'."); await page.waitForSelector("#id_realm_create_stream_policy", {visible: true}); - await page.evaluate(() => $("#id_realm_create_stream_policy").val(2).change()); + await page.evaluate(() => $("#id_realm_create_stream_policy").val(2).trigger("change")); await submit_stream_permissions_change(page); } async function test_set_create_streams_to_members_and_admins(page) { console.log("Test setting create streams policy to 'members and admins'."); await page.waitForSelector("#id_realm_create_stream_policy", {visible: true}); - await page.evaluate(() => $("#id_realm_create_stream_policy").val(1).change()); + await page.evaluate(() => $("#id_realm_create_stream_policy").val(1).trigger("change")); await submit_stream_permissions_change(page); } async function test_set_create_streams_policy_to_full_members(page) { console.log("Test setting create streams policy to 'full members'."); await page.waitForSelector("#id_realm_create_stream_policy", {visible: true}); - await page.evaluate(() => $("#id_realm_create_stream_policy").val(3).change()); + await page.evaluate(() => $("#id_realm_create_stream_policy").val(3).trigger("change")); await submit_stream_permissions_change(page); } async function test_set_invite_to_streams_policy_to_admins_only(page) { console.log("Test setting invite to streams policy to 'admins only'."); await page.waitForSelector("#id_realm_invite_to_stream_policy", {visible: true}); - await page.evaluate(() => $("#id_realm_invite_to_stream_policy").val(2).change()); + await page.evaluate(() => $("#id_realm_invite_to_stream_policy").val(2).trigger("change")); await submit_stream_permissions_change(page); } async function test_set_invite_to_streams_policy_to_members_and_admins(page) { console.log("Test setting invite to streams policy to 'members and admins'."); await page.waitForSelector("#id_realm_invite_to_stream_policy", {visible: true}); - await page.evaluate(() => $("#id_realm_invite_to_stream_policy").val(1).change()); + await page.evaluate(() => $("#id_realm_invite_to_stream_policy").val(1).trigger("change")); await submit_stream_permissions_change(page); } async function test_set_invite_to_streams_policy_to_full_members(page) { console.log("Test setting invite to streams policy to 'full members'."); await page.waitForSelector("#id_realm_invite_to_stream_policy", {visible: true}); - await page.evaluate(() => $("#id_realm_invite_to_stream_policy").val(3).change()); + await page.evaluate(() => $("#id_realm_invite_to_stream_policy").val(3).trigger("change")); await submit_stream_permissions_change(page); } @@ -167,14 +167,14 @@ async function submit_joining_organization_change(page) { async function test_set_new_user_threshold_to_three_days(page) { console.log("Test setting new user threshold to three days."); await page.waitForSelector("#id_realm_waiting_period_setting", {visible: true}); - await page.evaluate(() => $("#id_realm_waiting_period_setting").val("three_days").change()); + await page.evaluate(() => $("#id_realm_waiting_period_setting").val("three_days").trigger("change")); await submit_joining_organization_change(page); } async function test_set_new_user_threshold_to_N_days(page) { console.log("Test setting new user threshold to three days."); await page.waitForSelector("#id_realm_waiting_period_setting", {visible: true}); - await page.evaluate(() => $("#id_realm_waiting_period_setting").val("custom_days").change()); + await page.evaluate(() => $("#id_realm_waiting_period_setting").val("custom_days").trigger("change")); const N = 10; await page.evaluate((N) => $("#id_realm_waiting_period_threshold").val(N), N); @@ -337,7 +337,7 @@ async function test_change_organization_default_language(page) { await page.click("li[data-section='organization-settings']"); await page.waitForSelector("#id_realm_default_language", {visible: true}); - await page.evaluate(() => $("#id_realm_default_language").val("de").change()); + await page.evaluate(() => $("#id_realm_default_language").val("de").trigger("change")); await submit_default_user_settings(page); }