You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

69 rivejä
3.6 KiB

  1. import { expect, test } from './fixtures'
  2. import { TeachingContractMock } from './teaching-contract-mock'
  3. test.describe('教学运行页 P1 安全边界', () => {
  4. test('observe/readOnly 强制本人学员进入只读观察', async ({ page }) => {
  5. const contract = new TeachingContractMock('studentLeader')
  6. await contract.install(page)
  7. await page.goto('/teaching/confrontation/runs/run-confrontation?observe=1')
  8. await expect(page.getByText('只读观察', { exact: true })).toBeVisible()
  9. await expect(page.getByRole('button', { name: /提交岗位动作|完成当前岗位动作|提交团队结果/ })).toHaveCount(0)
  10. await page.goto('/teaching/confrontation/runs/run-confrontation?readOnly=1')
  11. await expect(page.getByText('只读观察', { exact: true })).toBeVisible()
  12. await expect(page.getByRole('button', { name: /提交岗位动作|完成当前岗位动作|提交团队结果/ })).toHaveCount(0)
  13. expect(contract.requests.filter((item) => ['PUT', 'POST', 'DELETE'].includes(item.method))).toHaveLength(0)
  14. })
  15. test('正式考核提交后清空执行投影并卸载 Three 场景', async ({ page }) => {
  16. const contract = new TeachingContractMock('studentLeader')
  17. await contract.install(page)
  18. await page.goto('/teaching/exams/runs/run-exam')
  19. await expect(page.locator('.runtime-scene-window canvas')).toBeVisible()
  20. await page.getByRole('button', { name: '完成当前步骤', exact: true }).click()
  21. await expect(page.getByRole('heading', { name: /第 2 步/ })).toBeVisible()
  22. await page.getByRole('button', { name: '完成当前步骤', exact: true }).click()
  23. await page.getByRole('button', { name: '提交正式考核', exact: true }).click()
  24. const dialog = page.locator('.el-dialog:visible').last()
  25. await dialog.getByRole('button', { name: '确认提交', exact: true }).click()
  26. await expect(page.getByText('正式考核执行场景已关闭', { exact: true })).toBeVisible()
  27. await expect(page.locator('.runtime-scene-window canvas')).toHaveCount(0)
  28. await expect(page.getByRole('button', { name: /过程记录/ })).toHaveCount(0)
  29. await expect(page.locator('.runtime-event-card')).toHaveCount(0)
  30. })
  31. test('共享对抗缺少岗位声明时只允许成员 ID 最小的本人', async ({ page }) => {
  32. const contract = new TeachingContractMock('studentOperator')
  33. const task = contract.assignments.get('assignment-confrontation') as Record<string, unknown>
  34. const definition = task.definitionSnapshot as { steps: Array<Record<string, unknown>>; modeConfig: Record<string, unknown> }
  35. definition.steps.forEach((step) => {
  36. delete step.allowedPositions
  37. delete step.requiredPositions
  38. delete step.positionCodes
  39. delete step.positionCode
  40. delete step.positionActions
  41. delete step.submitPositions
  42. })
  43. delete definition.modeConfig.submitPositions
  44. const runtime = contract.runs.get('run-confrontation') as Record<string, unknown>
  45. const members = runtime.members as Array<Record<string, unknown>>
  46. const leader = members.find((member) => member.userId === '4')!
  47. const operator = members.find((member) => member.userId === '5')!
  48. leader.id = '9'
  49. operator.id = '2'
  50. runtime.member = leader
  51. await contract.install(page)
  52. await page.goto('/teaching/confrontation/runs/run-confrontation')
  53. await expect(page.getByRole('button', { name: '提交岗位动作', exact: true })).toBeEnabled()
  54. contract.setIdentity('studentLeader')
  55. await page.reload()
  56. await expect(page.getByRole('button', { name: '提交岗位动作', exact: true })).toBeDisabled()
  57. await expect(page.getByText(/此动作需由.*运行成员 ID 最小/)).toBeVisible()
  58. })
  59. })