Scheduling infrastructure for absolutely everyone.
fix: make flaky E2E tests more stable (#26844)
Keith Williamsec383f6eef6f
diff --git a/apps/web/components/apps/routing-forms/SingleForm.tsx b/apps/web/components/apps/routing-forms/SingleForm.tsxindex 51514e743ee..2414a94aac8 100644--- a/apps/web/components/apps/routing-forms/SingleForm.tsx+++ b/apps/web/components/apps/routing-forms/SingleForm.tsx@@ -132,6 +132,8 @@ function SingleForm({}, [form]);const mutation = trpc.viewer.appRoutingForms.formMutation.useMutation({onSuccess() {+ const currentValues = hookForm.getValues();+ hookForm.reset(currentValues);showToast(t("form_updated_successfully"), "success");},onError(e) {diff --git a/apps/web/playwright/change-theme.e2e.ts b/apps/web/playwright/change-theme.e2e.tsindex adee17b3906..174f62c6efb 100644--- a/apps/web/playwright/change-theme.e2e.ts+++ b/apps/web/playwright/change-theme.e2e.ts@@ -17,8 +17,7 @@ test.describe("Change App Theme Test", () => {const darkModeClass = await page.getAttribute("html", "class");expect(darkModeClass).toContain("dark");- const themeValue = await page.evaluate(() => localStorage.getItem("app-theme"));- expect(themeValue).toBe("dark");+ await page.waitForFunction(() => localStorage.getItem("app-theme") === "dark");});test("change app theme to light", async ({ page, users }) => {@@ -35,8 +34,7 @@ test.describe("Change App Theme Test", () => {const darkModeClass = await page.getAttribute("html", "class");expect(darkModeClass).toContain("light");- const themeValue = await page.evaluate(() => localStorage.getItem("app-theme"));- expect(themeValue).toBe("light");+ await page.waitForFunction(() => localStorage.getItem("app-theme") === "light");});test("change app theme to system", async ({ page, users }) => {@@ -54,10 +52,7 @@ test.describe("Change App Theme Test", () => {await page.click('[data-testid="update-app-theme-btn"]');const toast2 = await page.waitForSelector('[data-testid="toast-success"]');expect(toast2).toBeTruthy();-- await page.waitForTimeout(3000);- const themeValue = await page.evaluate(() => localStorage.getItem("app-theme"));- expect(themeValue).toBe("light");+ await page.waitForFunction(() => localStorage.getItem("app-theme") === "light");const systemTheme = await page.evaluate(() => {return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";