From e073cbd5ea54d59cd8a2bfa8e0287587d5aa692c Mon Sep 17 00:00:00 2001 From: Romit <85230081+romitg2@users.noreply.github.com> Date: Wed, 25 Mar 2026 14:19:35 +0530 Subject: [PATCH] fix: resolve flaky team-management E2E test (#28575) * fix: resolve flaky team-management E2E test Fix two failure modes in the 'Can create teams via Wizard' test: 1. Strict mode violation: locator('[data-testid=new-team-btn]') resolves to 2 elements during Next.js streaming/hydration. Fixed by using .first(). 2. Race condition in disband assertion: raw .count() check doesn't wait for UI to update after team deletion. Replaced with Playwright's auto-retrying toBeHidden() assertion with a 10s timeout. Co-Authored-By: romitgabani1 * chore: remove explanatory comments per review feedback Co-Authored-By: romitgabani1 --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- apps/web/playwright/organization/team-management.e2e.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/apps/web/playwright/organization/team-management.e2e.ts b/apps/web/playwright/organization/team-management.e2e.ts index c770645ef8..0ebca8d8f5 100644 --- a/apps/web/playwright/organization/team-management.e2e.ts +++ b/apps/web/playwright/organization/team-management.e2e.ts @@ -29,8 +29,7 @@ test.describe("Teams", () => { await page.goto("/teams"); await test.step("Can create team", async () => { - // Click the new team button - await page.locator("[data-testid=new-team-btn]").click(); + await page.locator("[data-testid=new-team-btn]").first().click(); await page.waitForLoadState("networkidle"); // Fill team name input (new onboarding-v3 style flow) await page.locator('[data-testid="team-name-input"]').fill(`${user.username}'s Team`); @@ -63,7 +62,7 @@ test.describe("Teams", () => { await page.getByTestId("disband-team-button").click(); await page.getByTestId("dialog-confirmation").click(); await page.waitForURL("/teams"); - expect(await page.locator(`text=${user.username}'s Team`).count()).toEqual(0); + await expect(page.locator(`text=${user.username}'s Team`)).toBeHidden({ timeout: 10000 }); // Cleanup the invited user since they were created without our fixtures const invitedUser = await prisma.user.findUnique({ where: { email: inviteeEmail } });