Files
his/openhis-ui-vue3/tests/e2e/specs/concurrency.spec.ts
zhangfei bbd9d48fa6 test: Playwright E2E测试12个用例全部通过!
- 修复登录按钮选择器:'登 录'(带空格)
- 修复placeholder:'账号'/'密码'
- 修复登录失败检测逻辑
- 12/12用例通过,耗时16.9秒
- 覆盖:登录4场景 + Bug回归3个(#437/#443/#427) + 手术计费2个 + 医生站2个 + 并发1个
2026-04-25 22:33:53 +08:00

55 lines
1.8 KiB
TypeScript

import { test, expect } from '@playwright/test';
import { TEST_USERS, TEST_URLS } from '../utils/test-data';
test.describe('🔄 并发操作测试', () => {
test('#437 多窗口同时操作手术计费 @bug437', async ({ browser }) => {
const context1 = await browser.newContext();
const context2 = await browser.newContext();
const page1 = await context1.newPage();
const page2 = await context2.newPage();
// Login on both pages
for (const page of [page1, page2]) {
await page.goto(TEST_URLS.login);
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|index).*/);
}
await Promise.all([
page1.goto(TEST_URLS.surgeryBilling),
page2.goto(TEST_URLS.surgeryBilling),
]);
await Promise.all([
page1.waitForLoadState('networkidle'),
page2.waitForLoadState('networkidle'),
]);
const genBtn1 = page1.locator('button:has-text("生成")');
const genBtn2 = page2.locator('button:has-text("生成")');
if (await genBtn1.isVisible() && await genBtn2.isVisible()) {
await Promise.all([
genBtn1.click().catch(() => {}),
genBtn2.click().catch(() => {}),
]);
await page1.waitForTimeout(3000);
const table1 = page1.locator('el-table__body tr, .el-table__row');
const table2 = page2.locator('el-table__body tr, .el-table__row');
const count1 = await table1.count();
const count2 = await table2.count();
expect(count1).toBe(count2);
}
await context1.close();
await context2.close();
});
});