Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
puppeteer: Fix `subscribe_toogle.ts` long pending flake.
Riken Shah624260227608
diff --git a/frontend_tests/puppeteer_tests/subscribe_toggle.ts b/frontend_tests/puppeteer_tests/subscribe_toggle.tsindex df67a561dfa..cd5d8143c7d 100644--- a/frontend_tests/puppeteer_tests/subscribe_toggle.ts+++ b/frontend_tests/puppeteer_tests/subscribe_toggle.ts@@ -9,10 +9,16 @@ async function test_subscription_button(page: Page): Promise<void> {const unsubscribed_selector = `${button_selector}:not(.checked)`;async function subscribed(): Promise<ElementHandle | null> {+ await page.waitForFunction(+ () => $(".stream_settings_header .sub_unsub_button").text().trim() === "Unsubscribe",+ );return await page.waitForSelector(subscribed_selector, {visible: true});}async function unsubscribed(): Promise<ElementHandle | null> {+ await page.waitForFunction(+ () => $(".stream_settings_header .sub_unsub_button").text().trim() === "Subscribe",+ );return await page.waitForSelector(unsubscribed_selector, {visible: true});}@@ -20,6 +26,8 @@ async function test_subscription_button(page: Page): Promise<void> {await page.waitForSelector(stream_selector, {visible: true});await page.waitForSelector(button_selector, {visible: true});+ await page.click(stream_selector);+// Note that we intentionally re-find the button after each click, since// the live-update code may replace the whole row.let button;@@ -28,20 +36,12 @@ async function test_subscription_button(page: Page): Promise<void> {// should happen immediately.button = await subscribed();- // Toggle subscriptions several times. This test code has been known- // to flake, so we add console statements. It appears that the console- // statements help prevent the flake, which is probably caused by some- // subtle race condition. We will hopefully diagnose the root cause of- // the flake, but I am confident that the test will mostly catch actual- // bugs in the real code, so as long as the console.info statements help- // here, we should just leave them in.+ // Toggle subscriptions several times.for (let i = 0; i < 10; i += 1) {- console.info(`\n unsubscribe/subscribe loop ${i}\n\n`);await button!.click();button = await unsubscribed();await button!.click();button = await subscribed();- console.info(`\n end loop ${i}\n\n`);}}