|
| 1 | +/** |
| 2 | + * E2E test: the /demo page transliteration Explorer. |
| 3 | + * |
| 4 | + * This is the critical user-facing path: the TS runtime loads maps from |
| 5 | + * /public/maps and transliterates input in real-time via interscript-ts. |
| 6 | + * |
| 7 | + * If this test passes, the entire Ruby→IR→TS pipeline works end-to-end. |
| 8 | + */ |
| 9 | +import { test, expect } from "@playwright/test" |
| 10 | + |
| 11 | +test.describe("demo page — transliteration explorer", () => { |
| 12 | + test("page loads with system selector and input", async ({ page }) => { |
| 13 | + await page.goto("/demo") |
| 14 | + await expect(page.locator("h1")).toContainText(/Type/i) |
| 15 | + |
| 16 | + // Engine status shows loading or ready (not "missing") |
| 17 | + const status = page.locator(".rail-status") |
| 18 | + await expect(status).toBeVisible() |
| 19 | + |
| 20 | + // System selector has options |
| 21 | + const select = page.locator("select.field-input") |
| 22 | + await expect(select).toBeVisible() |
| 23 | + const options = select.locator("option") |
| 24 | + await expect(options).toHaveCount(5) |
| 25 | + }) |
| 26 | + |
| 27 | + test("default system is BGN/PCGN Ukrainian", async ({ page }) => { |
| 28 | + await page.goto("/demo") |
| 29 | + const select = page.locator("select.field-input") |
| 30 | + await expect(select).toHaveValue("bgnpcgn-ukr-Cyrl-Latn-2019") |
| 31 | + }) |
| 32 | + |
| 33 | + test("transliterates Ukrainian Cyrillic to Latin", async ({ page }) => { |
| 34 | + await page.goto("/demo") |
| 35 | + |
| 36 | + // Wait for engine to be ready (loads all systems + their deps) |
| 37 | + const status = page.locator(".rail-status") |
| 38 | + await expect(status).toContainText("ready", { timeout: 20000 }) |
| 39 | + |
| 40 | + // Type Cyrillic input |
| 41 | + const textarea = page.locator("textarea.pane-body") |
| 42 | + await textarea.fill("Антон") |
| 43 | + |
| 44 | + // Wait for output to contain "Anton" |
| 45 | + const output = page.locator(".pane-result") |
| 46 | + await expect(output).toContainText("Anton", { timeout: 10000 }) |
| 47 | + }) |
| 48 | + |
| 49 | + test("transliterates ODNI Russian", async ({ page }) => { |
| 50 | + await page.goto("/demo") |
| 51 | + |
| 52 | + const status = page.locator(".rail-status") |
| 53 | + await expect(status).toContainText("ready", { timeout: 20000 }) |
| 54 | + |
| 55 | + // Change system and type |
| 56 | + const select = page.locator("select.field-input") |
| 57 | + await select.selectOption("odni-rus-Cyrl-Latn-2015") |
| 58 | + |
| 59 | + const textarea = page.locator("textarea.pane-body") |
| 60 | + await textarea.fill("привет мир") |
| 61 | + |
| 62 | + const output = page.locator(".pane-result") |
| 63 | + await expect(output).toContainText("privet mir", { timeout: 10000 }) |
| 64 | + }) |
| 65 | + |
| 66 | + test("transliterates BGN/PCGN German", async ({ page }) => { |
| 67 | + await page.goto("/demo") |
| 68 | + |
| 69 | + const status = page.locator(".rail-status") |
| 70 | + await expect(status).toContainText("ready", { timeout: 20000 }) |
| 71 | + |
| 72 | + const select = page.locator("select.field-input") |
| 73 | + await select.selectOption("bgnpcgn-deu-Latn-Latn-2000") |
| 74 | + |
| 75 | + const textarea = page.locator("textarea.pane-body") |
| 76 | + await textarea.fill("Tschüß!") |
| 77 | + |
| 78 | + const output = page.locator(".pane-result") |
| 79 | + await expect(output).toContainText("Tschueß", { timeout: 10000 }) |
| 80 | + }) |
| 81 | + |
| 82 | + test("transliterates UN Tamil", async ({ page }) => { |
| 83 | + await page.goto("/demo") |
| 84 | + |
| 85 | + const status = page.locator(".rail-status") |
| 86 | + await expect(status).toContainText("ready", { timeout: 20000 }) |
| 87 | + |
| 88 | + const select = page.locator("select.field-input") |
| 89 | + await select.selectOption("un-tam-Taml-Latn-1972") |
| 90 | + |
| 91 | + const textarea = page.locator("textarea.pane-body") |
| 92 | + await textarea.fill("தமிழ்") |
| 93 | + |
| 94 | + // Tamil output should be non-empty and different from input |
| 95 | + const output = page.locator(".pane-result") |
| 96 | + await page.waitForTimeout(1000) |
| 97 | + const text = (await output.textContent())?.trim() |
| 98 | + expect(text?.length ?? 0).toBeGreaterThan(0) |
| 99 | + }) |
| 100 | + |
| 101 | + test("transliterates ALA-LC Amharic", async ({ page }) => { |
| 102 | + await page.goto("/demo") |
| 103 | + |
| 104 | + const status = page.locator(".rail-status") |
| 105 | + await expect(status).toContainText("ready", { timeout: 20000 }) |
| 106 | + |
| 107 | + const select = page.locator("select.field-input") |
| 108 | + await select.selectOption("alalc-amh-Ethi-Latn-2011") |
| 109 | + |
| 110 | + const textarea = page.locator("textarea.pane-body") |
| 111 | + await textarea.fill("ኢትዮጵያ") |
| 112 | + |
| 113 | + const output = page.locator(".pane-result") |
| 114 | + await page.waitForTimeout(1000) |
| 115 | + const text = (await output.textContent())?.trim() |
| 116 | + expect(text?.length ?? 0).toBeGreaterThan(0) |
| 117 | + }) |
| 118 | + |
| 119 | + test("handles empty input gracefully", async ({ page }) => { |
| 120 | + await page.goto("/demo") |
| 121 | + |
| 122 | + const textarea = page.locator("textarea.pane-body") |
| 123 | + await textarea.fill("") |
| 124 | + await page.waitForTimeout(200) |
| 125 | + |
| 126 | + const output = page.locator(".pane-result") |
| 127 | + const text = await output.textContent() |
| 128 | + // Empty input should produce empty output or a dash |
| 129 | + expect(text).toBeTruthy() |
| 130 | + }) |
| 131 | + |
| 132 | + test("no error banner appears during normal use", async ({ page }) => { |
| 133 | + await page.goto("/demo") |
| 134 | + |
| 135 | + const status = page.locator(".rail-status") |
| 136 | + await expect(status).toContainText(/ready|loading/, { timeout: 10000 }) |
| 137 | + |
| 138 | + const textarea = page.locator("textarea.pane-body") |
| 139 | + await textarea.fill("Антон") |
| 140 | + await page.waitForTimeout(500) |
| 141 | + |
| 142 | + const errorBanner = page.locator(".error-banner") |
| 143 | + await expect(errorBanner).not.toBeVisible() |
| 144 | + }) |
| 145 | +}) |
0 commit comments