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 bac0dbfdbe ci(test): 更新 Playwright 版本并优化测试脚本
- 将 Playwright 版本从 v1.43.0 升级到 v1.51.0
- 优化了 baseFixture 中的登录流程
- 改进了 customerPage 中的顾客创建逻辑
- 调整了 boss_cashier 和 staff_goal 测试中的操作方式
2025-03-16 19:10:03 +08:00

51 lines
1.8 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();
});
if (!baseURL) throw new Error('baseURL is required');
await page.goto(baseURL);
// 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';