WFDASH-WEBAPP/e2e/_helpers.ts
SJCoetz c4e1c62882 chore: standardize line endings and add full test + config scaffolding
Fix inconsistent line endings across all project files for cross-environment consistency.
Add complete unit test suite covering core utilities, API routes, and server services.
Add Playwright E2E test setup with smoke, auth, and agent API tests.
Update all project configuration files to match standardized formatting.
Fix MCP API error handling to properly propagate HTTP status codes and use correct JSON-RPC error codes.
Add VSCode workspace configuration, extensions, and example MCP config files.
Update .gitignore to exclude new test and build artifacts.
2026-06-11 20:30:02 +02:00

34 lines
1.2 KiB
TypeScript

import { test as base, expect, type Page } from "@playwright/test";
/**
* Whether the auth-required specs can actually run.
*
* They need:
* - PocketBase reachable at E2E_POCKETBASE_URL (so we can create a fixture user)
* - A test email/password supplied via env
*
* When any of those are missing we mark the relevant specs `test.skip` so the
* suite still runs the no-infra checks.
*/
export const HAS_AUTH_FIXTURE =
!!process.env.E2E_TEST_EMAIL && !!process.env.E2E_TEST_PASSWORD;
export const POCKETBASE_URL = process.env.E2E_POCKETBASE_URL ?? "http://127.0.0.1:8090";
/** Calls PocketBase's create-and-auth endpoint and stores the auth record in localStorage. */
export async function signIn(
page: Page,
email: string,
password: string
): Promise<void> {
// Trigger the actual client-side login path used by AuthProvider.
await page.goto("/login");
await page.getByLabel(/email/i).fill(email);
await page.getByLabel(/password/i).fill(password);
await page.getByRole("button", { name: /sign in|log in|login/i }).click();
// Wait for redirect into the protected area (or an error to surface).
await page.waitForURL((u) => !u.pathname.startsWith("/login"), { timeout: 10_000 });
}
export const test = base;
export { expect };