puppeteer_test: Wait for 100ms after typing each char to avoid flake.

The reason for this flake is it missed clicking on the Set
All button (`.subs_set_all_users`) because it calculated
its position before/during it starts scrolling.

There are two scrolling events caused by typing `ot`,

* First is due to internal focus call before typing
which scrolled down the page to bring input in the view.

* Second is after it typed `ot` the user list is updated to
one value, which caused the modal height to decrease rapidly.

Note: It theory, there is three scrolling event,
First is of course internal focus then, after it typed `o`
the list is updated to two values and one is after `t` the
list is updated to a single value.
But as puppeteer is very quick it directly jumped to the
scrolling event after it typed `ot`.

For a more detailed explanation read,
https://chat.zulip.org/#narrow/stream/43-automated-testing/topic/master.20failing/near/1173996.

This commit just temporarily fixes this flake, it's not the
best approach to use time-based delays as they can't be
robust (e.g If the machine is super slow then time-based
delays can fail.).
This commit is contained in:
Riken Shah
2021-05-11 13:14:51 +00:00
committed by Tim Abbott
parent 96565ee1d1
commit f7baa3c388

View File

@@ -129,8 +129,13 @@ async function test_user_filter_ui(
// Desdemona should be checked by default
await wait_for_checked(page, "desdemona", true);
await common.fill_form(page, "form#stream_creation_form", {user_list_filter: "ot"});
await page.type(`form#stream_creation_form [name="user_list_filter"]`, "ot", {delay: 100});
await page.waitForSelector("#user-checkboxes", {visible: true});
// Wait until filtering is completed.
await page.waitForFunction(
() => document.querySelectorAll("#user-checkboxes label").length === 1,
);
await page.waitForSelector(cordelia_checkbox, {hidden: true});
await page.waitForSelector(othello_checkbox, {visible: true});