puppeteer: Fix dropdown click flake in `admin.ts`.

The reason for the flake was we were not waiting enough
time for the dropdown to render search results when we
type `rome`

To fix this, We are waiting until the dropdown input value
evaluates to be `rome`.

We also update variable name from
`verona_in_dropdown` to correct `rome_in_dropdown`.
This commit is contained in:
Riken Shah 2022-09-09 18:21:32 +05:30 committed by Tim Abbott
parent 8da2eb58ec
commit 3176733914
1 changed files with 9 additions and 3 deletions

View File

@ -35,13 +35,19 @@ async function test_change_new_stream_notifications_setting(page: Page): Promise
"#realm_notifications_stream_id_widget .dropdown-search > input[type=text]", "#realm_notifications_stream_id_widget .dropdown-search > input[type=text]",
"rome", "rome",
); );
await page.waitForFunction(
() =>
$(
"#realm_notifications_stream_id_widget .dropdown-search > input[type=text]",
).val() === "rome",
);
const verona_in_dropdown = await page.waitForXPath( const rome_in_dropdown = await page.waitForXPath(
'//*[@id="realm_notifications_stream_id_widget"]//*[@class="dropdown-list-body"]/li[1]', '//*[@id="realm_notifications_stream_id_widget"]//*[@class="dropdown-list-body"]/li[1]',
{visible: true}, {visible: true},
); );
assert.ok(verona_in_dropdown); assert.ok(rome_in_dropdown);
await (verona_in_dropdown as ElementHandle<Element>).click(); await (rome_in_dropdown as ElementHandle<Element>).click();
await submit_notifications_stream_settings(page); await submit_notifications_stream_settings(page);