|
| 1 | +# 03 — E2E tests for interscript.org website |
| 2 | + |
| 3 | +## Priority: P0 |
| 4 | + |
| 5 | +## Problem |
| 6 | +The website has integration tests (Vitest) that test individual modules, |
| 7 | +but no browser-based E2E tests that validate the actual user experience: |
| 8 | +loading pages, typing in transliteration inputs, seeing output. |
| 9 | + |
| 10 | +## Solution: Playwright |
| 11 | + |
| 12 | +### Setup |
| 13 | +```bash |
| 14 | +cd interscript.org |
| 15 | +npm install -D @playwright/test |
| 16 | +npx playwright install |
| 17 | +``` |
| 18 | + |
| 19 | +### Structure |
| 20 | +``` |
| 21 | +e2e/ |
| 22 | + playwright.config.ts |
| 23 | + home.spec.ts # Landing page loads, CTA works |
| 24 | + detect.spec.ts # Detect panel: input → system suggestion |
| 25 | + compare.spec.ts # Compare two systems side by side |
| 26 | + batch.spec.ts # Batch transliteration |
| 27 | + maps.spec.ts # Browse maps, search, filter |
| 28 | + api-docs.spec.ts # API documentation interactive |
| 29 | + worker.spec.ts # Web Worker loads and transliterates |
| 30 | +``` |
| 31 | + |
| 32 | +### Key Test Cases |
| 33 | + |
| 34 | +#### Worker transliteration (critical path) |
| 35 | +```typescript |
| 36 | +test("worker transliterates Ukrainian", async ({ page }) => { |
| 37 | + await page.goto("/") |
| 38 | + const input = page.locator("[data-testid='translit-input']") |
| 39 | + const output = page.locator("[data-testid='translit-output']") |
| 40 | + await input.fill("Антон") |
| 41 | + await expect(output).toContainText("Anton") |
| 42 | +}) |
| 43 | +``` |
| 44 | + |
| 45 | +#### Map browser |
| 46 | +```typescript |
| 47 | +test("browse maps by script", async ({ page }) => { |
| 48 | + await page.goto("/maps") |
| 49 | + await page.click("text=Cyrillic") |
| 50 | + await expect(page.locator(".map-card")).toHaveCount.greaterThan(10) |
| 51 | +}) |
| 52 | +``` |
| 53 | + |
| 54 | +#### API playground |
| 55 | +```typescript |
| 56 | +test("API playground returns JSON", async ({ page }) => { |
| 57 | + await page.goto("/api") |
| 58 | + await page.fill("[data-testid='api-input']", '{"system":"bgnpcgn-ukr-Cyrl-Latn-2019","input":"Київ"}') |
| 59 | + await page.click("[data-testid='api-run']") |
| 60 | + await expect(page.locator("[data-testid='api-output']")).toContainText("Kyiv") |
| 61 | +}) |
| 62 | +``` |
| 63 | + |
| 64 | +### CI Integration |
| 65 | +```yaml |
| 66 | +# .github/workflows/e2e.yml |
| 67 | +- name: Build site |
| 68 | + run: npm run build |
| 69 | +- name: Run Playwright |
| 70 | + run: npx playwright test |
| 71 | +- name: Upload report |
| 72 | + if: always() |
| 73 | + uses: actions/upload-artifact@v3 |
| 74 | + with: |
| 75 | + name: playwright-report |
| 76 | + path: playwright-report/ |
| 77 | +``` |
0 commit comments