869b5774fb
* Initial plan * Add Playwright E2E testing infrastructure - Add @playwright/test dependency - Create playwright.config.ts with best practices configuration - Create e2e test structure with fixtures and auth setup - Add E2E tests for auth, dashboard, medications, and settings pages - Add npm scripts for running E2E tests - Update .gitignore for Playwright artifacts - Add E2E test job to CI workflow - Update vite.config.ts to support BACKEND_URL env variable - Update biome.json to include e2e files in linting Co-authored-by: DanielVolz <3275994+DanielVolz@users.noreply.github.com> * Remove waitForTimeout anti-pattern from E2E tests Replace hard-coded timeouts with proper Playwright waiting strategies: - Use waitForLoadState('networkidle') for page load - Use element.waitFor() for dynamic elements - Use expect assertions for state verification Co-authored-by: DanielVolz <3275994+DanielVolz@users.noreply.github.com> * Remove E2E tests from CI workflow E2E tests will only be run locally as requested. Co-authored-by: DanielVolz <3275994+DanielVolz@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: DanielVolz <3275994+DanielVolz@users.noreply.github.com> Co-authored-by: Daniel Volz <mail@danielvolz.org>
149 lines
3.2 KiB
TypeScript
149 lines
3.2 KiB
TypeScript
import { defineConfig, devices } from "@playwright/test";
|
|
|
|
/**
|
|
* Playwright E2E Testing Configuration
|
|
*
|
|
* Run E2E tests with:
|
|
* npm run test:e2e - Run tests in headless mode
|
|
* npm run test:e2e:ui - Run tests with Playwright UI
|
|
* npm run test:e2e:headed - Run tests in headed mode
|
|
*
|
|
* Before running tests, ensure both backend and frontend are running:
|
|
* docker compose -f docker-compose.dev.yml up
|
|
*
|
|
* Or run them separately:
|
|
* cd backend && npm run dev
|
|
* cd frontend && npm run dev
|
|
*/
|
|
|
|
// Base URL for the frontend dev server
|
|
const baseURL = process.env.PLAYWRIGHT_BASE_URL || "http://localhost:5173";
|
|
|
|
export default defineConfig({
|
|
// Directory containing test files
|
|
testDir: "./e2e",
|
|
|
|
// Test file pattern
|
|
testMatch: "**/*.spec.ts",
|
|
|
|
// Maximum time one test can run
|
|
timeout: 30 * 1000,
|
|
|
|
// Maximum time to wait for expect assertions
|
|
expect: {
|
|
timeout: 5000,
|
|
},
|
|
|
|
// 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 (more retries on CI)
|
|
retries: process.env.CI ? 2 : 0,
|
|
|
|
// Opt out of parallel tests on CI
|
|
workers: process.env.CI ? 1 : undefined,
|
|
|
|
// Reporter configuration
|
|
reporter: process.env.CI
|
|
? [["html", { outputFolder: "playwright-report" }], ["github"]]
|
|
: [["html", { outputFolder: "playwright-report" }], ["list"]],
|
|
|
|
// Shared settings for all projects
|
|
use: {
|
|
// Base URL for page.goto() calls
|
|
baseURL,
|
|
|
|
// Collect trace on first retry
|
|
trace: "on-first-retry",
|
|
|
|
// Capture screenshot on failure
|
|
screenshot: "only-on-failure",
|
|
|
|
// Record video on first retry
|
|
video: "on-first-retry",
|
|
|
|
// Default viewport size
|
|
viewport: { width: 1280, height: 720 },
|
|
|
|
// Wait for network idle before considering navigation complete
|
|
navigationTimeout: 10000,
|
|
|
|
// Accept cookies and local storage
|
|
actionTimeout: 5000,
|
|
},
|
|
|
|
// Configure projects for multiple browsers
|
|
projects: [
|
|
// Setup project for authentication state
|
|
{
|
|
name: "setup",
|
|
testMatch: /.*\.setup\.ts/,
|
|
},
|
|
|
|
// Desktop browsers
|
|
{
|
|
name: "chromium",
|
|
use: {
|
|
...devices["Desktop Chrome"],
|
|
},
|
|
dependencies: ["setup"],
|
|
},
|
|
|
|
{
|
|
name: "firefox",
|
|
use: {
|
|
...devices["Desktop Firefox"],
|
|
},
|
|
dependencies: ["setup"],
|
|
},
|
|
|
|
{
|
|
name: "webkit",
|
|
use: {
|
|
...devices["Desktop Safari"],
|
|
},
|
|
dependencies: ["setup"],
|
|
},
|
|
|
|
// Mobile browsers (optional)
|
|
{
|
|
name: "mobile-chrome",
|
|
use: {
|
|
...devices["Pixel 5"],
|
|
},
|
|
dependencies: ["setup"],
|
|
},
|
|
|
|
{
|
|
name: "mobile-safari",
|
|
use: {
|
|
...devices["iPhone 12"],
|
|
},
|
|
dependencies: ["setup"],
|
|
},
|
|
],
|
|
|
|
// Directory for test output files (screenshots, traces, videos)
|
|
outputDir: "test-results/",
|
|
|
|
// Web server configuration - automatically start dev server if not running
|
|
// Commented out by default as you typically run the dev servers separately
|
|
// webServer: [
|
|
// {
|
|
// command: 'cd ../backend && npm run dev',
|
|
// url: 'http://localhost:3000/health',
|
|
// reuseExistingServer: !process.env.CI,
|
|
// timeout: 120 * 1000,
|
|
// },
|
|
// {
|
|
// command: 'npm run dev',
|
|
// url: 'http://localhost:5173',
|
|
// reuseExistingServer: !process.env.CI,
|
|
// timeout: 120 * 1000,
|
|
// },
|
|
// ],
|
|
});
|