Files
photo-live/apps/admin/e2e/locale-en.spec.ts
T
浅念 7385785504 feat(i18n): T15 full-stack language audit with coverage assertions
- viewer/admin 错误码→文案映射按契约 ErrorCodes 枚举全集登记(机器守护
  spec 遍历枚举断言无缺漏 + 映射键在 zh/en 词条均存在 + locale 键集
  递归相等);mobile 镜像补齐 DOWNLOAD_DISABLED(P4a 增补漏登)
- 漏译修复:viewer.photoRemoved en 侧缺失(审计测试捕获);
  DOWNLOAD_DISABLED 观众侧专属文案 + useDownload 专属提示接线;
  admin apiMsg 增 RATE_LIMITED/ALBUM_NOT_PUBLIC/DOWNLOAD_DISABLED/
  SYNC_AUTH_FAILED 四码词条
- 运行时抽查:admin 主旅程 en 版 e2e(登录→相册管理全英文 + 偏好
  持久);embed iframe lang=en 渲染与深链跟随 e2e(zh 侧既有用例覆盖)
- contracts 新增 ./errors 浏览器安全子路径(errors.ts 纯 TS);
  admin 增 @photo/contracts devDep(仅测试消费)

Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-09-20 23:44:27 +08:00

37 lines
2.1 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// T15(A12)运行时抽查(P4b Task 6):admin 主旅程 en 版。
// 模板 i18n zh/en 键集一致性 + 错误码映射枚举覆盖由 error.spec.ts 机器守护;
// 此处验证真实 DOM:登录页顶栏语言菜单(用户级设置,AuthTopBar)切 English →
// 登录表单/按钮英文文案 → 正确登录 → 相册管理列表页英文(菜单/新建按钮/
// 空态)。zh 版主旅程由既有 login/albums 系列覆盖;viewer en 旅程由
// viewer e2e 各 spec 覆盖;embed iframe lang 两语言见 viewer e2e/embed.spec.ts。
import { expect, test } from '@playwright/test'
import { adminCredentials } from './helpers'
test('en locale: admin 主旅程(登录 → 相册管理)全英文渲染', async ({ page }) => {
const { account, password } = adminCredentials()
await page.goto('/#/auth/login')
// 登录页右上语言菜单 → English(ElDropdown teleport 到 body)。
await page.locator('.language-btn').first().click()
await page.locator('.el-dropdown-menu__item', { hasText: 'English' }).click()
// 登录表单文案与占位符切换为英文。
await expect(page.getByText('Welcome back')).toBeVisible()
await expect(page.getByPlaceholder('Enter account')).toBeVisible()
await expect(page.getByPlaceholder('Please enter your password')).toBeVisible()
await expect(page.getByRole('button', { name: 'Login' })).toBeVisible()
// 英文凭据登录 → 落相册管理列表页,页面级文案英文。
await page.getByPlaceholder('Enter account').fill(account)
await page.getByPlaceholder('Please enter your password').fill(password)
await page.getByRole('button', { name: 'Login' }).click()
await expect(page).toHaveURL(/\/albums\/manage/, { timeout: 20_000 })
await expect(page.getByText('Album Management').first()).toBeVisible()
await expect(page.getByRole('button', { name: 'New Album' })).toBeVisible()
// 语言偏好已持久(用户级设置,刷新后仍英文)。
await page.reload()
await expect(page.getByText('Album Management').first()).toBeVisible()
await expect(page.getByRole('button', { name: 'New Album' })).toBeVisible()
})