bd4b2a579e
e2e 8 用例:users/menus/groups 三页面经壳层挂载、根路由跳首个可见页、菜单激活态、 面包屑(分组->页面) 与 404 兜底的真实浏览器断言。
65 lines
3.0 KiB
TypeScript
65 lines
3.0 KiB
TypeScript
import { expect, test, type Page } from '@playwright/test'
|
|
|
|
async function gotoRoute(page: Page, path: string) {
|
|
await page.goto(path)
|
|
}
|
|
|
|
test('test_task_019_first_batch_mount_normal_primary_path', async ({ page }) => {
|
|
await gotoRoute(page, '/admin-vue/account/users')
|
|
await expect(page.locator('main h2')).toHaveText('用户管理')
|
|
await expect(page.locator('.admin-topbar h1')).toHaveText('用户管理')
|
|
})
|
|
|
|
test('test_task_019_first_batch_mount_normal_variant_input', async ({ page }) => {
|
|
await gotoRoute(page, '/admin-vue/account/menus')
|
|
await expect(page.locator('main h2')).toHaveText('菜单管理')
|
|
await expect(page.locator('.admin-topbar h1')).toHaveText('菜单管理')
|
|
})
|
|
|
|
test('test_task_019_first_batch_mount_normal_repeated_operation_is_idempotent', async ({ page }) => {
|
|
await gotoRoute(page, '/admin-vue/account/groups')
|
|
await expect(page.locator('main h2')).toHaveText('数据权限分组')
|
|
await gotoRoute(page, '/admin-vue/account/users')
|
|
await expect(page.locator('main h2')).toHaveText('用户管理')
|
|
await gotoRoute(page, '/admin-vue/account/groups')
|
|
await expect(page.locator('main h2')).toHaveText('数据权限分组')
|
|
})
|
|
|
|
test('test_task_019_first_batch_mount_boundary_empty_input', async ({ page }) => {
|
|
// 根路由跳转到首个可见页面(用户管理)。
|
|
await gotoRoute(page, '/admin-vue/')
|
|
await expect(page.locator('main h2')).toHaveText('用户管理')
|
|
await expect(page).toHaveURL(/\/account\/users$/)
|
|
})
|
|
|
|
test('test_task_019_first_batch_mount_boundary_single_item', async ({ page }) => {
|
|
await gotoRoute(page, '/admin-vue/account/menus')
|
|
await expect(page.locator('main h2')).toHaveText('菜单管理')
|
|
const active = page.locator('.el-menu-item.is-active')
|
|
await expect(active).toHaveText('菜单管理')
|
|
})
|
|
|
|
test('test_task_019_first_batch_mount_boundary_limit_or_missing_field', async ({ page }) => {
|
|
// 三个页面均可从侧边栏导航切换(挂载于同一壳层实例)。
|
|
await gotoRoute(page, '/admin-vue/account/users')
|
|
await expect(page.locator('main h2')).toHaveText('用户管理')
|
|
await page.getByText('菜单管理', { exact: true }).first().click()
|
|
await expect(page.locator('main h2')).toHaveText('菜单管理')
|
|
await page.getByText('数据权限分组', { exact: true }).first().click()
|
|
await expect(page.locator('main h2')).toHaveText('数据权限分组')
|
|
})
|
|
|
|
test('test_task_019_first_batch_mount_invalid_input_rejected', async ({ page }) => {
|
|
await gotoRoute(page, '/admin-vue/no-such-page')
|
|
await expect(page.locator('.not-found')).toBeVisible()
|
|
await expect(page.locator('.admin-topbar h1')).toHaveText('页面不存在')
|
|
})
|
|
|
|
test('test_task_019_first_batch_mount_dependency_failure_returns_actionable_message', async ({ page }) => {
|
|
// 分组内页面展示 分组->页面 两级面包屑。
|
|
await gotoRoute(page, '/admin-vue/account/users')
|
|
await expect(page.locator('.admin-breadcrumb')).toBeVisible()
|
|
await expect(page.locator('.admin-breadcrumb')).toContainText('账号权限')
|
|
await expect(page.locator('.admin-breadcrumb')).toContainText('用户管理')
|
|
})
|