更新 Playwright 配置以保留失败时的追踪信息,重构测试用例以提高可读性和结构清晰度
This commit is contained in:
parent
af98ccd0b8
commit
44a701cbed
@ -41,7 +41,7 @@ module.exports = defineConfig({
|
|||||||
'Accept-Language': 'zh-CN,zh;q=0.9',
|
'Accept-Language': 'zh-CN,zh;q=0.9',
|
||||||
},
|
},
|
||||||
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
|
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
|
||||||
trace: 'on-first-retry',
|
trace: 'retain-on-failure',
|
||||||
},
|
},
|
||||||
|
|
||||||
/* Configure projects for major browsers */
|
/* Configure projects for major browsers */
|
||||||
|
|||||||
@ -8,8 +8,11 @@ test.describe
|
|||||||
const customer = new Customer(1, 1, { phone: phone });
|
const customer = new Customer(1, 1, { phone: phone });
|
||||||
console.log(`${customer.phone}-${customer.username}`);
|
console.log(`${customer.phone}-${customer.username}`);
|
||||||
|
|
||||||
test('登录touch和h5,创建顾客购买会员卡', async ({ touchPage, touchCustomerPage }) => {
|
test('创建顾客', async ({ touchCustomerPage }) => {
|
||||||
await touchCustomerPage.createCustomer(customer);
|
await touchCustomerPage.createCustomer(customer);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('登录touch和h5,创建顾客购买会员卡', async ({ touchPage }) => {
|
||||||
await test.step('在touch页面购买会员卡', async () => {
|
await test.step('在touch页面购买会员卡', async () => {
|
||||||
await touchPage.getByText('去开单').click();
|
await touchPage.getByText('去开单').click();
|
||||||
await touchPage.locator('.more > .icon > svg').click();
|
await touchPage.locator('.more > .icon > svg').click();
|
||||||
|
|||||||
@ -23,15 +23,15 @@ test('csv', async ({ zhbPage }, workerInfo) => {
|
|||||||
console.log({ name, phone });
|
console.log({ name, phone });
|
||||||
const customer = new Customer({ name: name, phone: name });
|
const customer = new Customer({ name: name, phone: name });
|
||||||
|
|
||||||
// 使用房间名称
|
/**@type {string} 房间名称 */
|
||||||
let useRoomName;
|
let useRoomName;
|
||||||
await test.step('购买商品', async () => {
|
await test.step('购买商品', async () => {
|
||||||
await zhbPage.locator('#tab_main li').filter({ hasText: '营业' }).click();
|
await zhbPage.locator('#tab_main li').filter({ hasText: '营业' }).click();
|
||||||
const $emptyRoom = $$room
|
const $emptyRoom = $$room
|
||||||
.filter({ has: zhbPage.getByText('空房') })
|
.filter({ has: zhbPage.getByText('空房') })
|
||||||
.nth(workerInfo.workerIndex % 3);
|
.nth(workerInfo.workerIndex % 3);
|
||||||
|
await $emptyRoom.locator('.roomName').waitFor();
|
||||||
useRoomName = await $emptyRoom.locator('.roomName').innerText();
|
useRoomName = await $emptyRoom.locator('.roomName').innerText();
|
||||||
expect(useRoomName).not.toBeNull();
|
|
||||||
await $emptyRoom.click();
|
await $emptyRoom.click();
|
||||||
await expect(async () => {
|
await expect(async () => {
|
||||||
if (await zhbPage.locator('.close > .iconfont').first().isVisible()) {
|
if (await zhbPage.locator('.close > .iconfont').first().isVisible()) {
|
||||||
@ -66,21 +66,22 @@ test('csv', async ({ zhbPage }, workerInfo) => {
|
|||||||
.first()
|
.first()
|
||||||
.click();
|
.click();
|
||||||
await zhbPage.getByRole('button', { name: '完成开单' }).click();
|
await zhbPage.getByRole('button', { name: '完成开单' }).click();
|
||||||
await expect(zhbPage.getByRole('button', { name: '结账' })).toBeVisible({ timeout: 30_000 });
|
await expect(zhbPage.getByRole('button', { name: '结账' })).toBeVisible();
|
||||||
await zhbPage.getByRole('button', { name: '结账' }).click();
|
await zhbPage.getByRole('button', { name: '结账' }).click();
|
||||||
await zhbPage.locator('#page_footBathPay').getByText('结算签字').click();
|
await zhbPage.locator('#page_footBathPay').getByText('结算签字').click();
|
||||||
|
|
||||||
await expect(async () => {
|
await expect(async () => {
|
||||||
await zhbPage.locator('#page_footBathPay li').filter({ hasText: '现金' }).click();
|
await zhbPage.locator('#page_footBathPay li').filter({ hasText: '现金' }).click();
|
||||||
await expect(zhbPage.locator('#page_footBathPay li').filter({ hasText: '现金' })).toHaveClass(
|
await expect(zhbPage.locator('#page_footBathPay li').filter({ hasText: '现金' })).toHaveClass(
|
||||||
/selected/
|
/selected/,
|
||||||
|
{ timeout: 2000 }
|
||||||
);
|
);
|
||||||
await zhbPage
|
|
||||||
.locator('#page_footBathPay span')
|
|
||||||
.filter({ hasText: /结\s算/ })
|
|
||||||
.click();
|
|
||||||
await expect(zhbPage.getByText('顾客满意度点评')).toBeVisible({ timeout: 2000 });
|
|
||||||
}).toPass();
|
}).toPass();
|
||||||
|
await zhbPage
|
||||||
|
.locator('#page_footBathPay span')
|
||||||
|
.filter({ hasText: /结\s算/ })
|
||||||
|
.click();
|
||||||
|
await expect(zhbPage.getByText('顾客满意度点评')).toBeVisible({ timeout: 2000 });
|
||||||
|
|
||||||
await zhbPage.getByText('不想评价').click();
|
await zhbPage.getByText('不想评价').click();
|
||||||
await zhbPage.locator('#page_footBathPay').getByText('立即返回').click();
|
await zhbPage.locator('#page_footBathPay').getByText('立即返回').click();
|
||||||
|
|||||||
Reference in New Issue
Block a user