26 lines
664 B
TypeScript
26 lines
664 B
TypeScript
import { test, expect } from '@playwright/test';
|
|
|
|
test.describe('未登录用户权限验证', () => {
|
|
|
|
test('未登录用户重定向到登录页', async ({ page }) => {
|
|
|
|
await test.step('访问受保护页面应重定向', async () => {
|
|
const protectedPages = [
|
|
'/members',
|
|
'/courses',
|
|
'/statistics',
|
|
'/users',
|
|
'/roles'
|
|
];
|
|
|
|
for (const path of protectedPages) {
|
|
await page.goto(path);
|
|
await page.waitForLoadState('networkidle');
|
|
// 未登录用户应被重定向到登录页
|
|
const url = page.url();
|
|
expect(url).toContain('login');
|
|
}
|
|
});
|
|
});
|
|
});
|