Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 

40 lignes
1.7 KiB

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