Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
puppeteer_lib: Remove wait_for_text.
Anders Kaseorg73ca1afc530e
diff --git a/frontend_tests/puppeteer_lib/common.ts b/frontend_tests/puppeteer_lib/common.tsindex e3f19ad478a..a25c81e26f4 100644--- a/frontend_tests/puppeteer_lib/common.ts+++ b/frontend_tests/puppeteer_lib/common.ts@@ -197,15 +197,6 @@ class CommonUtils {return texts.join("").trim();}- async wait_for_text(page: Page, selector: string, text: string): Promise<void> {- await page.waitForFunction(- (selector: string, text: string) => $(selector).text().includes(text),- {},- selector,- text,- );- }-async get_stream_id(page: Page, stream_name: string): Promise<number> {return await page.evaluate((stream_name: string) => zulip_test.get_stream_id(stream_name),diff --git a/frontend_tests/puppeteer_tests/07-navigation.ts b/frontend_tests/puppeteer_tests/07-navigation.tsindex 7f782b03af3..ff732e3ba8a 100644--- a/frontend_tests/puppeteer_tests/07-navigation.ts+++ b/frontend_tests/puppeteer_tests/07-navigation.ts@@ -97,7 +97,9 @@ async function navigation_tests(page: Page): Promise<void> {await test_reload_hash(page);// Verify that we're narrowed to the target stream- await common.wait_for_text(page, "#message_view_header .stream", "Verona");+ await page.waitForXPath(+ '//*[@id="message_view_header"]//*[@class="stream" and normalize-space()="Verona"]',+ );await common.log_out(page);}diff --git a/frontend_tests/puppeteer_tests/08-admin.ts b/frontend_tests/puppeteer_tests/08-admin.tsindex 811a2d7ceab..b696fc5daed 100644--- a/frontend_tests/puppeteer_tests/08-admin.ts+++ b/frontend_tests/puppeteer_tests/08-admin.ts@@ -36,12 +36,11 @@ async function test_change_new_stream_notifications_setting(page: Page): Promise"verona",);- const verona_in_dropdown =- "#realm_notifications_stream_id_widget .dropdown-list-body > li:nth-of-type(1)";-- await common.wait_for_text(page, verona_in_dropdown, "Verona");- await page.waitForSelector(verona_in_dropdown, {visible: true});- await page.evaluate((selector: string) => $(selector).trigger("click"), verona_in_dropdown);+ const verona_in_dropdown = await page.waitForXPath(+ '//*[@id="realm_notifications_stream_id_widget"]//*[@class="dropdown-list-body"]/li[1]',+ {visible: true},+ );+ await verona_in_dropdown!.click();await submit_notifications_stream_settings(page);diff --git a/frontend_tests/puppeteer_tests/09-mention.ts b/frontend_tests/puppeteer_tests/09-mention.tsindex b0d1fdf75bd..11da37732ca 100644--- a/frontend_tests/puppeteer_tests/09-mention.ts+++ b/frontend_tests/puppeteer_tests/09-mention.ts@@ -29,10 +29,8 @@ async function test_mention(page: Page): Promise<void> {assert(stream_size > threshold);await page.click("#compose-send-button");- await common.wait_for_text(- page,- ".compose-all-everyone-msg",- "Are you sure you want to mention all",+ await page.waitForXPath(+ '//*[@class="compose-all-everyone-msg" and contains(text(), "Are you sure you want to mention all")]',);await page.click(".compose-all-everyone-confirm");await page.waitForSelector(".compose-all-everyone-msg", {hidden: true});diff --git a/frontend_tests/puppeteer_tests/10-custom-profile.ts b/frontend_tests/puppeteer_tests/10-custom-profile.tsindex cb0148541eb..96197e99e7f 100644--- a/frontend_tests/puppeteer_tests/10-custom-profile.ts+++ b/frontend_tests/puppeteer_tests/10-custom-profile.ts@@ -21,7 +21,9 @@ async function test_add_new_profile_field(page: Page): Promise<void> {await common.get_text_from_selector(page, "div#admin-add-profile-field-status"),"Saved",);- await common.wait_for_text(page, `${profile_field_row} span.profile_field_name`, "Teams");+ await page.waitForXPath(+ '//*[@id="admin_profile_fields_table"]//tr[last()-1]/td[normalize-space()="Teams"]',+ );assert.strictEqual(await common.get_text_from_selector(page, `${profile_field_row} span.profile_field_type`),"Short text",@@ -37,7 +39,9 @@ async function test_edit_profile_field(page: Page): Promise<void> {await page.click(`${profile_field_form} button.submit`);await page.waitForSelector("#admin-profile-field-status img", {visible: true});- await common.wait_for_text(page, `${profile_field_row} span.profile_field_name`, "team");+ await page.waitForXPath(+ '//*[@id="admin_profile_fields_table"]//tr[last()-1]/td[normalize-space()="team"]',+ );assert.strictEqual(await common.get_text_from_selector(page, `${profile_field_row} span.profile_field_type`),"Short text",