Creates test infrastructure to enable previously skipped e2e tests: - Onboarding user (no period data) for setup flow tests - Established user (period 14 days ago) for normal usage tests - Calendar user (with calendarToken) for ICS feed tests - Garmin user (valid tokens) for connected state tests - Garmin expired user (expired tokens) for expiry warning tests Also fixes ICS feed route to strip .ics suffix from Next.js dynamic route param, adds calendarToken to /api/user response, and sets viewRule on users collection for unauthenticated ICS access. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
64 lines
2.0 KiB
TypeScript
64 lines
2.0 KiB
TypeScript
// ABOUTME: Playwright E2E test configuration for browser-based testing.
|
|
// ABOUTME: Configures Chromium-only headless testing with automatic dev server startup.
|
|
import { defineConfig, devices } from "@playwright/test";
|
|
|
|
export default defineConfig({
|
|
// Test directory for E2E tests
|
|
testDir: "./e2e",
|
|
|
|
// Global setup/teardown for PocketBase harness
|
|
globalSetup: "./e2e/global-setup.ts",
|
|
globalTeardown: "./e2e/global-teardown.ts",
|
|
|
|
// Exclude vitest test files
|
|
testIgnore: ["**/pocketbase-harness.test.ts"],
|
|
|
|
// Run tests in parallel
|
|
fullyParallel: true,
|
|
|
|
// Fail the build on CI if you accidentally left test.only in the source code
|
|
forbidOnly: !!process.env.CI,
|
|
|
|
// Retry failed tests on CI only
|
|
retries: process.env.CI ? 2 : 0,
|
|
|
|
// Run tests sequentially since all tests share the same test user
|
|
// Parallel execution causes race conditions when tests modify user state
|
|
workers: 1,
|
|
|
|
// Reporter configuration
|
|
reporter: [["html", { open: "never" }], ["list"]],
|
|
|
|
// Shared settings for all projects
|
|
use: {
|
|
// Base URL for navigation actions like page.goto('/')
|
|
baseURL: "http://localhost:3000",
|
|
|
|
// Collect trace on first retry for debugging
|
|
trace: "on-first-retry",
|
|
|
|
// Take screenshot on failure
|
|
screenshot: "only-on-failure",
|
|
},
|
|
|
|
// Configure projects - Chromium only per requirements
|
|
projects: [{ name: "chromium", use: { ...devices["Desktop Chrome"] } }],
|
|
|
|
// Run dev server before starting tests
|
|
// Note: POCKETBASE_URL is set for the test PocketBase instance on port 8091
|
|
// We never reuse existing servers to ensure the correct PocketBase URL is used
|
|
webServer: {
|
|
command: "pnpm dev",
|
|
url: "http://localhost:3000",
|
|
reuseExistingServer: false,
|
|
timeout: 120 * 1000, // 2 minutes for Next.js to start
|
|
env: {
|
|
// Use the test PocketBase instance (port 8091)
|
|
NEXT_PUBLIC_POCKETBASE_URL: "http://127.0.0.1:8091",
|
|
POCKETBASE_URL: "http://127.0.0.1:8091",
|
|
// Required for Garmin token encryption
|
|
ENCRYPTION_KEY: "e2e-test-encryption-key-32chars",
|
|
},
|
|
},
|
|
});
|