Add self-contained e2e test harness with ephemeral PocketBase
Previously, 15 e2e tests were skipped because TEST_USER_EMAIL and TEST_USER_PASSWORD env vars weren't set. Now the test harness: - Starts a fresh PocketBase instance in /tmp on port 8091 - Creates admin user, collections, and API rules automatically - Seeds test user with period data for authenticated tests - Cleans up temp directory after tests complete Also fixes: - Override toggle tests now use checkbox role (not button) - Adds proper wait for OVERRIDES section before testing toggles - Suppresses document.cookie lint warning with explanation Test results: 64 e2e tests pass, 1014 unit tests pass Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
32
e2e/global-setup.ts
Normal file
32
e2e/global-setup.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
// ABOUTME: Playwright global setup - starts PocketBase and sets test environment variables.
|
||||
// ABOUTME: Runs before all e2e tests to provide a fresh database with test data.
|
||||
import * as fs from "node:fs";
|
||||
import * as path from "node:path";
|
||||
import { DEFAULT_CONFIG, start } from "./pocketbase-harness";
|
||||
|
||||
const STATE_FILE = path.join(__dirname, ".harness-state.json");
|
||||
|
||||
export default async function globalSetup(): Promise<void> {
|
||||
console.log("Starting PocketBase for e2e tests...");
|
||||
|
||||
const state = await start(DEFAULT_CONFIG);
|
||||
|
||||
// Save state for teardown
|
||||
fs.writeFileSync(
|
||||
STATE_FILE,
|
||||
JSON.stringify({
|
||||
dataDir: state.dataDir,
|
||||
url: state.url,
|
||||
pid: state.process.pid,
|
||||
}),
|
||||
);
|
||||
|
||||
// Set environment variables for the test process
|
||||
process.env.NEXT_PUBLIC_POCKETBASE_URL = state.url;
|
||||
process.env.POCKETBASE_URL = state.url;
|
||||
process.env.TEST_USER_EMAIL = DEFAULT_CONFIG.testUserEmail;
|
||||
process.env.TEST_USER_PASSWORD = DEFAULT_CONFIG.testUserPassword;
|
||||
|
||||
console.log(`PocketBase running at ${state.url}`);
|
||||
console.log(`Test user: ${DEFAULT_CONFIG.testUserEmail}`);
|
||||
}
|
||||
Reference in New Issue
Block a user