test: comprehensive analytics test suite — unit, API, E2E, air-gapped

This commit is contained in:
ashim-hq
2026-04-23 10:58:56 +08:00
parent de7b353871
commit fc059c751d
7 changed files with 583 additions and 3 deletions
+15 -2
View File
@@ -1,12 +1,25 @@
import path from "node:path";
import { expect, test as setup } from "@playwright/test";
import { authFile } from "../../playwright.docker.config";
const authFile =
// Support both playwright.docker.config and playwright.analytics.config
path.join(__dirname, "..", "..", "test-results", ".auth", "analytics-user.json");
setup("authenticate", async ({ page }) => {
await page.goto("/login");
await page.getByLabel("Username").fill("admin");
await page.getByLabel("Password").fill("admin");
await page.getByRole("button", { name: /login/i }).click();
await page.waitForURL("/", { timeout: 30_000 });
// After login, may land on "/" or "/analytics-consent" (fresh user)
await page.waitForURL(/\/(analytics-consent)?$/, { timeout: 30_000 });
// If redirected to consent page, accept analytics to proceed
if (page.url().includes("/analytics-consent")) {
await page.getByRole("button", { name: /sure, sounds good/i }).click();
await page.waitForURL("/", { timeout: 15_000 });
}
await expect(page).toHaveURL("/");
await page.context().storageState({ path: authFile });
});