- 移除不必要的挂单数量记录步骤 - 简化挂单流程,每个员工只挂单一次 - 使用 expect.soft 进行软断言,提高测试稳定性 - 优化员工选择和挂单校验的代码结构
56 lines
2.0 KiB
TypeScript
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';
|