Files
dashboard/e2e/helpers/fixtures.ts
Maycon Santos 7653e3411c Merge NetBird cloud edition into the dashboard (#674)
Brings the unified dashboard into the open-source repo. Premium features
ship in the open code, gated at runtime via NETBIRD_CLOUD and
NETBIRD_LICENSED, with upgrade prompts for unlicensed self-hosted
deployments. Adds the cloud-only feature areas (billing, integrations,
MSP, traffic events, notifications) and the Playwright e2e suite.
2026-06-21 16:01:08 +02:00

50 lines
1.4 KiB
TypeScript

/**
* Custom Playwright fixtures that provide pre-authenticated pages.
*
* Usage:
* import { test, expect } from "../helpers/fixtures";
* test.describe.serial("My Feature", () => {
* test("first test", async ({ dashboardAsOwner }) => { ... });
* });
*
* `dashboardAsOwner` logs in once (via OIDC redirect) and reuses the same
* browser page for every test in the worker — no per-test login overhead.
*/
import { test as base, type Page, type BrowserContext } from "@playwright/test";
import { loginToApp, type TestUser } from "./auth";
type Fixtures = {
dashboardAsOwner: Page;
dashboardAsUser: Page;
};
export const test = base.extend<{}, Fixtures>({
dashboardAsOwner: [
async ({ browser }, use) => {
const context = await browser.newContext({
storageState: "e2e/fixtures/auth/owner.json",
});
const page = await context.newPage();
await loginToApp(page, "owner");
await use(page);
await context.close();
},
{ scope: "worker" },
],
dashboardAsUser: [
async ({ browser }, use) => {
const context = await browser.newContext({
storageState: "e2e/fixtures/auth/user.json",
});
const page = await context.newPage();
await loginToApp(page, "user");
await use(page);
await context.close();
},
{ scope: "worker" },
],
});
export { expect } from "@playwright/test";