import { captureScreenshot, expect, test } from './fixtures' const serviceChecks = [ { name: 'Web 登录入口', path: '/login', contentType: /text\/html/i }, { name: '公开系统配置接口', path: '/api/auth/v1/system-config/public', contentType: /application\/json/i }, { name: 'API 健康检查', path: '/api/v1/health', contentType: /application\/json/i }, ] as const test('预检:Web、Web 代理与 API 健康检查均可用', async ({ request }) => { for (const service of serviceChecks) { await test.step(service.name, async () => { const response = await request.get(service.path) expect(response.ok(), `${service.name} 请求失败:HTTP ${response.status()}`).toBeTruthy() expect(response.headers()['content-type'] ?? '', `${service.name} 返回类型异常`) .toMatch(service.contentType) }) } }) test('预检:登录页展示四种身份入口并截图', async ({ page }, testInfo) => { await page.goto('/login') await expect(page.getByRole('heading', { name: '登录数字人平台', exact: true })).toBeVisible() const expectedRoles = [ { code: 'administrative', label: '行政' }, { code: 'teacher', label: '教员' }, { code: 'student', label: '学员' }, { code: 'admin', label: '管理员' }, ] as const const roleButtons = page.locator('.login-role-options > button') await expect(roleButtons).toHaveCount(expectedRoles.length) for (const role of expectedRoles) { await expect(page.locator(`[data-role-code="${role.code}"]`)).toBeVisible() await expect(page.locator(`[data-role-code="${role.code}"]`)).toContainText(role.label) } await captureScreenshot(page, testInfo, 'preflight-login-four-identities') })