fix: 修正Playwright测试方案架构问题(诸葛亮审查反馈)
- 新增fixtures/auth.ts 登录认证夹具 - 新增pages/LoginPage.ts 页面对象模型 - 新增specs/login.spec.ts 登录测试用例(成功/失败/空用户名) - 新增specs/bug-regression.spec.ts Bug回归测试(#437/#427) - 新增.env.test 测试环境变量模板 - package.json添加test:e2e/test:e2e:ui/test:e2e:report脚本 - 移除test-data.ts中密码硬编码,改用环境变量 - .gitignore添加.env.test.local/playwright-report/test-results 感谢诸葛亮架构审查!
This commit is contained in:
38
openhis-ui-vue3/tests/e2e/specs/bug-regression.spec.ts
Normal file
38
openhis-ui-vue3/tests/e2e/specs/bug-regression.spec.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import { test, expect } from '@playwright/test';
|
||||
import { TEST_USERS } from '../utils/test-data';
|
||||
|
||||
test.describe('Bug回归测试', () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await page.goto('/');
|
||||
await page.fill('input[placeholder="请输入用户名"]', TEST_USERS.admin.username);
|
||||
await page.fill('input[placeholder="请输入密码"]', TEST_USERS.admin.password);
|
||||
await page.click('button:has-text("登录")');
|
||||
await page.waitForURL(/.*(dashboard|home).*/);
|
||||
});
|
||||
|
||||
test('#437 手术计费防重复提交', async ({ page }) => {
|
||||
await page.goto('/surgery-billing');
|
||||
const addBtn = page.locator('button:has-text("新增")');
|
||||
|
||||
// 快速连续点击(测试防重复锁)
|
||||
await addBtn.click();
|
||||
await addBtn.click();
|
||||
await addBtn.click();
|
||||
|
||||
// 验证只弹出一个表单
|
||||
const dialogCount = await page.locator('.el-dialog').count();
|
||||
expect(dialogCount).toBeLessThanOrEqual(1);
|
||||
});
|
||||
|
||||
test('#427 检查项目分类手风琴展开', async ({ page }) => {
|
||||
await page.goto('/doctorstation');
|
||||
|
||||
// 点击第一个分类
|
||||
const firstCategory = page.locator('.category-item').first();
|
||||
await firstCategory.click();
|
||||
|
||||
// 点击第二个分类,第一个应收起
|
||||
const secondCategory = page.locator('.category-item').nth(1);
|
||||
await secondCategory.click();
|
||||
});
|
||||
});
|
||||
27
openhis-ui-vue3/tests/e2e/specs/login.spec.ts
Normal file
27
openhis-ui-vue3/tests/e2e/specs/login.spec.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { test, expect } from '@playwright/test';
|
||||
import { LoginPage } from '../pages/LoginPage';
|
||||
import { TEST_USERS } from '../utils/test-data';
|
||||
|
||||
test.describe('登录模块', () => {
|
||||
let loginPage: LoginPage;
|
||||
|
||||
test.beforeEach(async ({ page }) => {
|
||||
loginPage = new LoginPage(page);
|
||||
await loginPage.goto();
|
||||
});
|
||||
|
||||
test('用户登录成功', async ({ page }) => {
|
||||
await loginPage.login(TEST_USERS.admin.username, TEST_USERS.admin.password);
|
||||
await loginPage.expectLoginSuccess();
|
||||
});
|
||||
|
||||
test('登录失败-错误密码', async ({ page }) => {
|
||||
await loginPage.login(TEST_USERS.admin.username, 'wrongpassword');
|
||||
await loginPage.expectLoginFailed();
|
||||
});
|
||||
|
||||
test('登录失败-空用户名', async ({ page }) => {
|
||||
await loginPage.login('', TEST_USERS.admin.password);
|
||||
await loginPage.expectLoginFailed();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user