This repository has been archived on 2025-04-22. You can view files and clone it, but cannot push or open issues or pull requests.
hlk_autotest/tests/fixtures/baseFixture.ts
LingandRX d44f457d86 test(boss_cashier): 优化挂单测试流程
- 移除不必要的挂单数量记录步骤
- 简化挂单流程,每个员工只挂单一次
- 使用 expect.soft 进行软断言,提高测试稳定性
- 优化员工选择和挂单校验的代码结构
2025-03-23 11:54:08 +08:00

56 lines
2.0 KiB
TypeScript

import { test as base, expect } from '@playwright/test';
import { HomeNavigation } from '@/pages/homeNavigationPage';
import { firstAccount, secondAccount, AuthAccount } from '@/common/auth';
type MyFixture = {
homeNavigation: HomeNavigation;
billSet: Set<string>;
};
export const test = base.extend<MyFixture>({
page: async ({ page, baseURL }, use) => {
await page.addLocatorHandler(page.locator('.left_img > .close_btn > .close_icon > svg'), async () => {
await page.locator('.left_img > .close_btn > .close_icon > svg').click();
await expect(page.locator('.versionModal_main_content')).toBeVisible();
});
try {
await page.goto(baseURL!, { timeout: 90 * 1000 });
} catch (error) {
console.log(error);
// await page.screenshot({ path: 'error.png' });
await page.reload();
}
// await page.getByRole('button', { name: /开\s单/ }).waitFor();
await expect(page.getByRole('button', { name: /开\s单/ })).toBeEnabled();
await page.reload();
await page.getByRole('button', { name: /开\s单/ }).click();
// await page.getByRole('button', { name: /开\s单/ }).waitFor();
await expect(page.getByRole('button', { name: '创建会员' })).toBeEnabled();
await page.locator('.top > .anticon').first().click();
await expect(page.getByRole('button', { name: '创建会员' })).not.toBeVisible();
await expect(page.getByRole('button', { name: /开\s单/ })).toBeInViewport();
await use(page);
},
/**
* 首页导航
*/
homeNavigation: async ({ page }, use) => {
const homeNavigation = new HomeNavigation(page);
await use(homeNavigation);
},
/**
* 流水单据集合(无重复水单)
*/
billSet: async ({ page }, use) => {
const billSet = new Set<string>();
await use(billSet);
},
});
export { expect } from '@playwright/test';