08ea5fbe98
添加用户管理视图、API和状态管理文件
71 lines
2.1 KiB
TypeScript
71 lines
2.1 KiB
TypeScript
import { test, expect } from '@playwright/test';
|
|
import { MockManager } from './mock-manager';
|
|
|
|
test('调试 - 测试mock是否正常工作', async ({ page }) => {
|
|
const mockManager = new MockManager({
|
|
enabled: true,
|
|
mode: 'full',
|
|
mockPaths: [],
|
|
delay: 0,
|
|
logCalls: true,
|
|
validateResponses: true,
|
|
dataSource: 'memory'
|
|
});
|
|
|
|
mockManager.presetTestData({
|
|
menus: [
|
|
{
|
|
id: 1,
|
|
name: '仪表盘',
|
|
code: 'dashboard',
|
|
path: '/dashboard',
|
|
icon: 'DashboardOutlined',
|
|
sortOrder: 1,
|
|
status: 'active',
|
|
parentId: 0,
|
|
component: 'views/Dashboard.vue',
|
|
createBy: 'system',
|
|
updateBy: 'system',
|
|
createdAt: '2024-01-01T00:00:00.000Z',
|
|
updatedAt: '2024-01-01T00:00:00.000Z',
|
|
children: []
|
|
}
|
|
]
|
|
});
|
|
|
|
await mockManager.interceptAPIRequest(page);
|
|
|
|
page.on('console', msg => {
|
|
console.log(`📱 Page Console [${msg.type()}]: ${msg.text()}`);
|
|
});
|
|
|
|
await page.goto('/login');
|
|
|
|
const usernameInput = page.locator('input[placeholder="请输入用户名"]');
|
|
const passwordInput = page.locator('input[placeholder="请输入密码"]');
|
|
const loginButton = page.locator('button[type="submit"]');
|
|
|
|
await usernameInput.waitFor({ state: 'visible', timeout: 10000 });
|
|
await passwordInput.waitFor({ state: 'visible', timeout: 10000 });
|
|
await loginButton.waitFor({ state: 'visible', timeout: 10000 });
|
|
|
|
await usernameInput.fill('admin');
|
|
await passwordInput.fill('admin123');
|
|
|
|
console.log('🔵 点击登录按钮');
|
|
await loginButton.click();
|
|
|
|
console.log('🔵 等待5秒查看页面状态');
|
|
await page.waitForTimeout(5000);
|
|
|
|
console.log('🔵 当前URL:', page.url());
|
|
console.log('🔵 页面标题:', await page.title());
|
|
|
|
const status = await mockManager.getMockStatus();
|
|
console.log('🔵 Mock状态:', JSON.stringify(status, null, 2));
|
|
|
|
const callHistory = mockManager.getCallHistory();
|
|
console.log('🔵 调用历史:', JSON.stringify(callHistory, null, 2));
|
|
|
|
await page.screenshot({ path: 'debug-login-screenshot.png' });
|
|
}); |