Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

puppeteer: Fix flaky click racing the users table presence re-render.

Sahil Batra50dd0dca7ae0
diff --git a/web/e2e-tests/user-deactivation.test.ts b/web/e2e-tests/user-deactivation.test.ts
index 1506f969ee3..e5f14408d51 100644
--- a/web/e2e-tests/user-deactivation.test.ts
+++ b/web/e2e-tests/user-deactivation.test.ts
@@ -46,8 +46,14 @@ async function test_deactivate_user(page: Page): Promise<void> {
const cordelia_user_row = await user_row(page, common.fullname.cordelia);
await page.waitForSelector(cordelia_user_row, {visible: true});
// Wait for the presence-data fetch in `settings_users.populate_users`
- // to complete and the table to re-render.
- await page.waitForSelector(cordelia_user_row + " .loading-placeholder", {hidden: true});
+ // to complete and the table to re-render. We check that the placeholder
+ // is removed, not hidden, because it has zero height (which Puppeteer
+ // treats as hidden) until its loading indicator is added.
+ await page.waitForFunction(
+ (selector: string) => document.querySelector(selector) === null,
+ {},
+ cordelia_user_row + " .loading-placeholder",
+ );
await page.waitForSelector(cordelia_user_row + " .zulip-icon-user-x", {visible: true});
await page.click(cordelia_user_row + " .deactivate");
await common.wait_for_micromodal_to_open(page);