08ea5fbe98
添加用户管理视图、API和状态管理文件
95 lines
3.1 KiB
TypeScript
95 lines
3.1 KiB
TypeScript
import { test, expect } from '@playwright/test';
|
|
import { MockManager } from './mock-manager';
|
|
|
|
test.describe('调试登出功能', () => {
|
|
test('详细调试登出流程', 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,
|
|
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('Browser Console:', msg.type(), msg.text());
|
|
});
|
|
|
|
page.on('pageerror', error => {
|
|
console.log('Browser Error:', error.message);
|
|
});
|
|
|
|
await page.goto('/login');
|
|
await page.waitForLoadState('networkidle');
|
|
|
|
const usernameInput = page.locator('input[placeholder="请输入用户名"]');
|
|
const passwordInput = page.locator('input[placeholder="请输入密码"]');
|
|
const loginButton = page.locator('button[type="submit"]');
|
|
|
|
await usernameInput.fill('admin');
|
|
await passwordInput.fill('admin123');
|
|
await loginButton.click();
|
|
|
|
await page.waitForURL(/.*dashboard/, { timeout: 15000 });
|
|
console.log('Successfully navigated to dashboard');
|
|
|
|
await page.waitForTimeout(2000);
|
|
|
|
const pageContent = await page.content();
|
|
console.log('Page HTML length:', pageContent.length);
|
|
|
|
const hasDropdownLink = await page.locator('.ant-dropdown-link').count();
|
|
console.log('Found .ant-dropdown-link elements:', hasDropdownLink);
|
|
|
|
const hasHeaderRight = await page.locator('.header-right').count();
|
|
console.log('Found .header-right elements:', hasHeaderRight);
|
|
|
|
const hasUserIcon = await page.locator('.anticon-user').count();
|
|
console.log('Found user icon elements:', hasUserIcon);
|
|
|
|
const allButtons = await page.locator('button').all();
|
|
console.log('Total buttons on page:', allButtons.length);
|
|
|
|
const allAnchors = await page.locator('a').all();
|
|
console.log('Total anchors on page:', allAnchors.length);
|
|
|
|
for (let i = 0; i < allAnchors.length; i++) {
|
|
const anchor = allAnchors[i];
|
|
const text = await anchor.textContent();
|
|
const className = await anchor.getAttribute('class');
|
|
console.log(`Anchor ${i}: text="${text}", class="${className}"`);
|
|
}
|
|
|
|
const allMenuItems = await page.locator('.ant-dropdown-menu-item').all();
|
|
console.log('Total dropdown menu items:', allMenuItems.length);
|
|
|
|
const logoutMenuItems = await page.locator('.ant-dropdown-menu-item').filter({ hasText: /退出/i }).all();
|
|
console.log('Found logout menu items:', logoutMenuItems.length);
|
|
|
|
await page.screenshot({ path: 'debug-logout-dashboard.png', fullPage: true });
|
|
});
|
|
}); |