Files
cal.diy/apps/web/playwright/apps/analytics/analyticsApps.e2e.ts
T
b83f8dd6b8 fix: improve E2E test stability and reduce flakiness (#25897)
* fix: improve E2E test stability and reduce flakiness

- Replace hardcoded waits with proper Playwright waitFor assertions in slot selection
- Add explicit waits for calendar and time slot elements to be visible before clicking
- Replace fixed 2s wait in gotoRoutingLink with networkidle wait
- Replace fixed 5s email wait with retry logic (10 retries, 500ms intervals)
- Use unique usernames with timestamps to avoid parallel test collisions
- Use features fixture instead of direct prisma calls for feature flag mutations
- Fix login.e2e.ts to use unique username instead of hardcoded 'pro'
- Fix signup.e2e.ts to use unique usernames and proper feature flag handling
- Remove unused 'users' parameter from tests that don't need it

Co-Authored-By: Volnei Munhoz <volnei.munhoz@gmail.com>

* perf: replace waitForTimeout with smart waits for faster E2E tests

- Replace 30 waitForTimeout calls with proper Playwright waits
- Use waitFor({ state: 'visible' }) for element visibility
- Use waitForLoadState('networkidle') for page load completion
- Use waitForFunction for localStorage state changes

Performance improvements:
- limit-tab.e2e.ts: 10s fixed wait -> element visibility wait
- booking-duplicate-api-calls.e2e.ts: 5s fixed wait -> networkidle
- change-theme.e2e.ts: 3s fixed wait -> localStorage state check
- team-invitation.e2e.ts: multiple 500ms-3s waits -> element waits
- booking-seats.e2e.ts: 2s waits -> dropdown visibility waits
- embed-code-generator.e2e.ts: 1s waits -> iframe visibility waits
- organization-privacy.e2e.ts: 500ms waits -> element/networkidle waits
- organization-invitation.e2e.ts: 500ms-1s waits -> element waits
- analyticsApps.e2e.ts: 1s wait -> networkidle
- integrations.e2e.ts: 1s wait -> calendar element wait
- fixtures/apps.ts: 1s waits -> element visibility waits

Co-Authored-By: Volnei Munhoz <volnei.munhoz@gmail.com>

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2025-12-15 20:19:47 -03:00

47 lines
1.7 KiB
TypeScript

import { test } from "../../lib/fixtures";
const ALL_APPS = ["fathom", "matomo", "plausible", "ga4", "gtm", "metapixel"];
test.describe.configure({ mode: "parallel" });
test.afterEach(({ users }) => users.deleteAll());
test.describe("check analytics Apps", () => {
test.describe("check analytics apps by skipping the configure step", () => {
ALL_APPS.forEach((app) => {
test(`check analytics app: ${app} by skipping the configure step`, async ({
appsPage,
page,
users,
}) => {
const user = await users.create();
await user.apiLogin();
await page.goto("apps/categories/analytics");
await appsPage.installAnalyticsAppSkipConfigure(app);
// Wait for navigation to complete instead of fixed 1s wait
await page.waitForLoadState("networkidle");
await page.goto("/event-types");
await appsPage.goToEventType("30 min");
await appsPage.goToAppsTab();
await appsPage.verifyAppsInfo(0);
await appsPage.activeApp(app);
await appsPage.verifyAppsInfo(1);
});
});
});
test.describe("check analytics apps using the new flow", () => {
ALL_APPS.forEach((app) => {
test(`check analytics app: ${app}`, async ({ appsPage, page, users }) => {
const user = await users.create();
await user.apiLogin();
const eventTypes = await user.getUserEventsAsOwner();
const eventTypesIds = eventTypes.map((item) => item.id).slice(0, 3);
await page.goto("/apps/categories/analytics");
await appsPage.installAnalyticsApp(app, eventTypesIds);
for (const id of eventTypesIds) {
await appsPage.verifyAppsInfoNew(app, id);
}
});
});
});
});