puppeteer_lib: Remove wait_for_text.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2021-03-12 14:13:45 -08:00 committed by Steve Howell
parent 054f8f8151
commit 73ca1afc53
5 changed files with 16 additions and 22 deletions

View File

@ -197,15 +197,6 @@ class CommonUtils {
return texts.join("").trim(); 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> { async get_stream_id(page: Page, stream_name: string): Promise<number> {
return await page.evaluate( return await page.evaluate(
(stream_name: string) => zulip_test.get_stream_id(stream_name), (stream_name: string) => zulip_test.get_stream_id(stream_name),

View File

@ -97,7 +97,9 @@ async function navigation_tests(page: Page): Promise<void> {
await test_reload_hash(page); await test_reload_hash(page);
// Verify that we're narrowed to the target stream // 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); await common.log_out(page);
} }

View File

@ -36,12 +36,11 @@ async function test_change_new_stream_notifications_setting(page: Page): Promise
"verona", "verona",
); );
const verona_in_dropdown = const verona_in_dropdown = await page.waitForXPath(
"#realm_notifications_stream_id_widget .dropdown-list-body > li:nth-of-type(1)"; '//*[@id="realm_notifications_stream_id_widget"]//*[@class="dropdown-list-body"]/li[1]',
{visible: true},
await common.wait_for_text(page, verona_in_dropdown, "Verona"); );
await page.waitForSelector(verona_in_dropdown, {visible: true}); await verona_in_dropdown!.click();
await page.evaluate((selector: string) => $(selector).trigger("click"), verona_in_dropdown);
await submit_notifications_stream_settings(page); await submit_notifications_stream_settings(page);

View File

@ -29,10 +29,8 @@ async function test_mention(page: Page): Promise<void> {
assert(stream_size > threshold); assert(stream_size > threshold);
await page.click("#compose-send-button"); await page.click("#compose-send-button");
await common.wait_for_text( await page.waitForXPath(
page, '//*[@class="compose-all-everyone-msg" and contains(text(), "Are you sure you want to mention all")]',
".compose-all-everyone-msg",
"Are you sure you want to mention all",
); );
await page.click(".compose-all-everyone-confirm"); await page.click(".compose-all-everyone-confirm");
await page.waitForSelector(".compose-all-everyone-msg", {hidden: true}); await page.waitForSelector(".compose-all-everyone-msg", {hidden: true});

View File

@ -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"), await common.get_text_from_selector(page, "div#admin-add-profile-field-status"),
"Saved", "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( assert.strictEqual(
await common.get_text_from_selector(page, `${profile_field_row} span.profile_field_type`), await common.get_text_from_selector(page, `${profile_field_row} span.profile_field_type`),
"Short text", "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.click(`${profile_field_form} button.submit`);
await page.waitForSelector("#admin-profile-field-status img", {visible: true}); 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( assert.strictEqual(
await common.get_text_from_selector(page, `${profile_field_row} span.profile_field_type`), await common.get_text_from_selector(page, `${profile_field_row} span.profile_field_type`),
"Short text", "Short text",