|
| 1 | +/** |
| 2 | + * The English interface (/en): copy, error messages and shortcut help. |
| 3 | + * The rest of the suite runs in Korean, the default locale. |
| 4 | + */ |
| 5 | +import { expect, test } from '@playwright/test'; |
| 6 | +import { headerButton, openPlayground, output, runAndWait, runButton, setEditor } from '../helpers'; |
| 7 | + |
| 8 | +test('UI copy is English and the document language is en', async ({ page }) => { |
| 9 | + await openPlayground(page, '', 'en'); |
| 10 | + await expect(page.locator('html')).toHaveAttribute('lang', 'en'); |
| 11 | + for (const name of ['Templates', 'History', 'Reference', 'Share']) await expect(headerButton(page, name)).toBeVisible(); |
| 12 | + await expect(runButton(page)).toContainText('Run'); |
| 13 | + await expect(output(page)).toContainText('Run your code to see the output here'); |
| 14 | + await expect(page.getByRole('list', { name: 'Open files' })).toBeVisible(); |
| 15 | + await setEditor(page, '출력("hello")\n'); |
| 16 | + await runAndWait(page); |
| 17 | + await expect(output(page)).toContainText('Finished'); |
| 18 | +}); |
| 19 | + |
| 20 | +test('compile errors are explained in English', async ({ page }) => { |
| 21 | + await openPlayground(page, '?fake=compile_error', 'en'); |
| 22 | + await runAndWait(page); |
| 23 | + await expect(output(page)).toContainText('Compile error'); |
| 24 | + await expect(output(page)).toContainText('Fix the problems listed below, then run again.'); |
| 25 | +}); |
| 26 | + |
| 27 | +test('rate limiting is explained in English with a countdown', async ({ page }) => { |
| 28 | + await openPlayground(page, '?fake=rate_limited', 'en'); |
| 29 | + await runAndWait(page); |
| 30 | + await expect(output(page).getByText('Too many runs in a short time').first()).toBeVisible(); |
| 31 | + await expect(output(page).getByRole('button', { name: /Try again \(\d+\)/ })).toBeDisabled(); |
| 32 | +}); |
| 33 | + |
| 34 | +test('the server-unavailable banner is in English', async ({ page }) => { |
| 35 | + await page.goto('/en?fake=unavailable'); |
| 36 | + await expect(page.getByText("Can't reach the playground server")).toBeVisible({ timeout: 30_000 }); |
| 37 | + await expect(page.getByRole('button', { name: 'Reconnect' })).toBeVisible(); |
| 38 | +}); |
| 39 | + |
| 40 | +test('shortcut help lists the keys in English', async ({ page }) => { |
| 41 | + await openPlayground(page, '', 'en'); |
| 42 | + await page.locator('body').press('?'); |
| 43 | + const dialog = page.getByRole('dialog', { name: 'Keyboard shortcuts' }); |
| 44 | + await expect(dialog).toBeVisible(); |
| 45 | + await expect(dialog).toContainText('Run code'); |
| 46 | + await expect(dialog).toContainText('Stop the run'); |
| 47 | + await expect(dialog).toContainText('Save a draft in this browser'); |
| 48 | + await page.keyboard.press('Escape'); |
| 49 | + await expect(dialog).toBeHidden(); |
| 50 | +}); |
| 51 | + |
| 52 | +test('switching the interface language keeps the page and its query', async ({ page }) => { |
| 53 | + await openPlayground(page, '?fake=compile_error'); |
| 54 | + await page.getByRole('button', { name: '메뉴 더 보기' }).click(); |
| 55 | + await page.getByRole('button', { name: 'English' }).click(); |
| 56 | + await expect(page).toHaveURL(/\/en\?fake=compile_error$/); |
| 57 | + await expect(runButton(page)).toContainText('Run'); |
| 58 | +}); |
| 59 | + |
| 60 | +test('the file context menu opens, works and closes with Escape or a click outside', async ({ page }) => { |
| 61 | + await openPlayground(page, '', 'en'); |
| 62 | + const mainTab = page.getByRole('list', { name: 'Open files' }).getByRole('button', { name: /^main\.ksj/ }); |
| 63 | + await mainTab.click({ button: 'right' }); |
| 64 | + const menu = page.locator('[popover][aria-label="main.ksj menu"]'); |
| 65 | + await expect(menu).toBeVisible(); |
| 66 | + await page.keyboard.press('Escape'); |
| 67 | + await expect(menu).toBeHidden(); |
| 68 | + await mainTab.click({ button: 'right' }); |
| 69 | + await expect(menu).toBeVisible(); |
| 70 | + await output(page).click({ position: { x: 10, y: 10 } }); |
| 71 | + await expect(menu).toBeHidden(); |
| 72 | + await mainTab.click({ button: 'right' }); |
| 73 | + await menu.getByRole('button', { name: 'Rename' }).click(); |
| 74 | + await expect(page.getByRole('textbox', { name: 'New name for main.ksj' })).toBeFocused(); |
| 75 | +}); |
0 commit comments