Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 
 

81 rader
4.8 KiB

  1. import { captureScreenshot, expect, test } from './fixtures'
  2. import { loginAsAdmin } from './helpers'
  3. const pages = [
  4. ['/system/users', '用户管理', 'system-users', '.users-table .el-table__body-wrapper .el-table__row'],
  5. ['/system/departments', '部门管理', 'system-departments', '.department-table .el-table__body-wrapper .el-table__row'],
  6. ['/system/roles', '角色管理', 'system-roles', '.roles-table .el-table__body-wrapper .el-table__row'],
  7. ['/system/menus', '菜单管理', 'system-menus', '.menu-table-panel .el-table__body-wrapper .el-table__row'],
  8. ['/system/audit', '审计日志', 'system-audit', '.el-table__body-wrapper .el-table__row'],
  9. ['/system/interfaces', '平台服务配置', 'system-interfaces', '.interfaces-table .el-table__body-wrapper .el-table__row'],
  10. ] as const
  11. test('系统管理页面均可加载且权限配置收口到角色抽屉', async ({ page }, testInfo) => {
  12. await loginAsAdmin(page)
  13. for (const [path, heading, screenshotLabel, readySelector] of pages) {
  14. await test.step(heading, async () => {
  15. await page.goto(path)
  16. await expect(page).toHaveURL(new RegExp(`${path.replaceAll('/', '\\/')}(?:\\?|$)`))
  17. // 系统管理页面已去掉 SystemPageHeader,页面身份由页面标签栏承担
  18. await expect(page.locator('.system-page-header')).toHaveCount(0)
  19. await expect(page.getByRole('tab', { name: heading, exact: true })).toBeVisible()
  20. await expect(page.locator(readySelector).first()).toBeVisible({ timeout: 15_000 })
  21. await expect(page.locator('.system-page .el-loading-mask:visible')).toHaveCount(0)
  22. if (['/system/users', '/system/departments', '/system/roles', '/system/menus', '/system/audit', '/system/interfaces'].includes(path)) {
  23. await expect(page.getByRole('button', { name: '搜索', exact: true })).toBeVisible()
  24. await expect(page.getByRole('button', { name: '重置', exact: true })).toBeVisible()
  25. // 关键词框统一 260px
  26. const keywordWidth = await page.locator('.system-list-toolbar .el-input').first()
  27. .evaluate((element) => element.getBoundingClientRect().width)
  28. expect(keywordWidth).toBeGreaterThan(230)
  29. expect(keywordWidth).toBeLessThanOrEqual(270)
  30. }
  31. // 页级动作落在工具条右端,不再出现在页头
  32. for (const [actionPath, actionName] of [
  33. ['/system/users', '新增用户'],
  34. ['/system/departments', '新增部门'],
  35. ['/system/roles', '新增角色'],
  36. ['/system/audit', '导出日志'],
  37. ] as const) {
  38. if (path !== actionPath) continue
  39. const action = page.locator('.system-list-toolbar').getByRole('button', { name: actionName, exact: true })
  40. await expect(action).toBeVisible()
  41. const [toolbarBox, actionBox] = await Promise.all([
  42. page.locator('.system-list-toolbar').first().boundingBox(),
  43. action.boundingBox(),
  44. ])
  45. expect(actionBox!.x + actionBox!.width).toBeGreaterThan(toolbarBox!.x + toolbarBox!.width - 40)
  46. }
  47. if (path === '/system/departments') {
  48. await expect(page.locator('.department-stats')).toHaveCount(0)
  49. await expect(page.getByTestId('department-inline-statistics')).toContainText('个部门')
  50. await expect(page.getByTestId('department-inline-statistics')).toContainText('启用')
  51. }
  52. if (path === '/system/roles') {
  53. await expect(page.locator('.role-statistics')).toHaveCount(0)
  54. await expect(page.getByTestId('role-inline-statistics')).toContainText('个角色')
  55. await expect(page.getByTestId('role-inline-statistics')).toContainText('内置')
  56. const permissionButton = page.locator('.roles-table .role-table-actions').first().getByRole('button', { name: '配置权限' })
  57. await permissionButton.click()
  58. await expect(page.locator('.role-permission-drawer')).toBeVisible()
  59. await page.locator('.role-permission-drawer .el-drawer__close-btn').click()
  60. }
  61. if (path === '/system/menus') {
  62. await expect(page.locator('.menu-statistics')).toHaveCount(0)
  63. await expect(page.getByTestId('menu-inline-statistics')).toContainText('个节点')
  64. await expect(page.getByTestId('menu-inline-statistics')).toContainText('页面')
  65. }
  66. if (path === '/system/interfaces') {
  67. // 卡片式展示已改为搜索栏 + 表格 + 分页
  68. await expect(page.locator('.interface-card')).toHaveCount(0)
  69. await expect(page.locator('.interfaces-table')).toHaveClass(/el-table--border/)
  70. await expect(page.locator('.interfaces-table')).toHaveClass(/el-table--striped/)
  71. await expect(page.getByTestId('interface-inline-statistics')).toContainText('个服务')
  72. await expect(page.locator('.system-pagination-total')).toBeVisible()
  73. }
  74. await captureScreenshot(page, testInfo, screenshotLabel)
  75. })
  76. }
  77. })