Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 

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