083de31fc5
问题: - 按钮文本不匹配:测试查找"新建",实际是"新增角色" - 菜单结构不匹配:测试点击父菜单,实际需要点击子菜单 - 菜单名称不匹配:测试查找"系统监控",实际是"审计中心" - 重复登录逻辑:部分测试用例仍在尝试登录 修复: - admin-complete-workflow.spec.ts: 修复按钮文本 - audit-workflow.spec.ts: 修复菜单名称 - system-config-workflow.spec.ts: 修复菜单导航 - file-management-workflow.spec.ts: 修复菜单导航 - user-permission-boundary.spec.ts: 移除重复登录逻辑 优势: - 测试用例与实际页面匹配 - 提高测试稳定性 - 减少测试失败
82 lines
2.8 KiB
TypeScript
82 lines
2.8 KiB
TypeScript
import { test, expect } from '@playwright/test';
|
|
|
|
test.describe('文件管理工作流', () => {
|
|
test('文件上传流程', async ({ page }) => {
|
|
await test.step('导航到文件管理', async () => {
|
|
await page.goto('/dashboard');
|
|
await page.locator('text=文件管理').click();
|
|
await page.locator('text=文件列表').click();
|
|
});
|
|
|
|
await test.step('上传文件', async () => {
|
|
const uploadButton = page.locator('button:has-text("上传")');
|
|
if (await uploadButton.isVisible()) {
|
|
const fileInput = page.locator('input[type="file"]');
|
|
await fileInput.setInputFiles({
|
|
name: 'test-file.txt',
|
|
mimeType: 'text/plain',
|
|
buffer: Buffer.from('Test file content'),
|
|
});
|
|
await page.waitForTimeout(2000);
|
|
}
|
|
});
|
|
|
|
await test.step('验证文件上传成功', async () => {
|
|
const successMessage = page.locator('.el-message--success');
|
|
if (await successMessage.isVisible()) {
|
|
expect(await successMessage.textContent()).toContain('成功');
|
|
}
|
|
});
|
|
});
|
|
|
|
test('文件搜索和筛选', async ({ page }) => {
|
|
await test.step('导航到文件管理', async () => {
|
|
await page.goto('/dashboard');
|
|
await page.locator('text=系统管理').click();
|
|
await page.locator('text=文件管理').click();
|
|
});
|
|
|
|
await test.step('搜索文件', async () => {
|
|
const searchInput = page.locator('input[placeholder*="搜索"]');
|
|
if (await searchInput.isVisible()) {
|
|
await searchInput.fill('test');
|
|
await page.locator('button:has-text("搜索")').click();
|
|
await page.waitForTimeout(1000);
|
|
}
|
|
});
|
|
|
|
await test.step('按类型筛选', async () => {
|
|
const typeFilter = page.locator('.el-select:has-text("类型")');
|
|
if (await typeFilter.isVisible()) {
|
|
await typeFilter.click();
|
|
await page.locator('.el-select-dropdown__item').first().click();
|
|
await page.waitForTimeout(1000);
|
|
}
|
|
});
|
|
});
|
|
|
|
test('文件删除流程', async ({ page }) => {
|
|
await test.step('导航到文件管理', async () => {
|
|
await page.goto('/dashboard');
|
|
await page.locator('text=系统管理').click();
|
|
await page.locator('text=文件管理').click();
|
|
});
|
|
|
|
await test.step('选择文件', async () => {
|
|
const fileCheckbox = page.locator('.el-checkbox').first();
|
|
if (await fileCheckbox.isVisible()) {
|
|
await fileCheckbox.click();
|
|
}
|
|
});
|
|
|
|
await test.step('删除文件', async () => {
|
|
const deleteButton = page.locator('button:has-text("删除")');
|
|
if (await deleteButton.isVisible()) {
|
|
await deleteButton.click();
|
|
await page.locator('button:has-text("确定")').click();
|
|
await page.waitForTimeout(1000);
|
|
}
|
|
});
|
|
});
|
|
});
|