mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
test: comprehensive analytics test suite — unit, API, E2E, air-gapped
This commit is contained in:
@@ -7,7 +7,7 @@ import { expect, test } from "@playwright/test";
|
||||
// If the container has analytics enabled, these tests will be skipped
|
||||
// automatically by checking the config endpoint first.
|
||||
|
||||
const BASE_URL = "http://localhost:1349";
|
||||
const BASE_URL = process.env.API_URL ?? "http://localhost:1349";
|
||||
|
||||
async function loginFresh(page: import("@playwright/test").Page) {
|
||||
await page.goto("/login");
|
||||
|
||||
@@ -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 });
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user