diff --git a/playwright.config.js b/playwright.config.js index 5cb9a12..6025cbb 100644 --- a/playwright.config.js +++ b/playwright.config.js @@ -41,7 +41,7 @@ module.exports = defineConfig({ 'Accept-Language': 'zh-CN,zh;q=0.9', }, /* 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 */ diff --git a/tests/hlk/demo.spec.js b/tests/hlk/demo.spec.js index 0fe93d7..6b6d4a1 100644 --- a/tests/hlk/demo.spec.js +++ b/tests/hlk/demo.spec.js @@ -8,8 +8,11 @@ test.describe const customer = new Customer(1, 1, { phone: phone }); console.log(`${customer.phone}-${customer.username}`); - test('登录touch和h5,创建顾客购买会员卡', async ({ touchPage, touchCustomerPage }) => { + test('创建顾客', async ({ touchCustomerPage }) => { await touchCustomerPage.createCustomer(customer); + }); + + test('登录touch和h5,创建顾客购买会员卡', async ({ touchPage }) => { await test.step('在touch页面购买会员卡', async () => { await touchPage.getByText('去开单').click(); await touchPage.locator('.more > .icon > svg').click(); diff --git a/tests/zhb/csv-demo.spec.js b/tests/zhb/csv-demo.spec.js index 1d17b73..2d6c93a 100644 --- a/tests/zhb/csv-demo.spec.js +++ b/tests/zhb/csv-demo.spec.js @@ -23,15 +23,15 @@ test('csv', async ({ zhbPage }, workerInfo) => { console.log({ name, phone }); const customer = new Customer({ name: name, phone: name }); - // 使用房间名称 + /**@type {string} 房间名称 */ let useRoomName; await test.step('购买商品', async () => { await zhbPage.locator('#tab_main li').filter({ hasText: '营业' }).click(); const $emptyRoom = $$room .filter({ has: zhbPage.getByText('空房') }) .nth(workerInfo.workerIndex % 3); + await $emptyRoom.locator('.roomName').waitFor(); useRoomName = await $emptyRoom.locator('.roomName').innerText(); - expect(useRoomName).not.toBeNull(); await $emptyRoom.click(); await expect(async () => { if (await zhbPage.locator('.close > .iconfont').first().isVisible()) { @@ -66,21 +66,22 @@ test('csv', async ({ zhbPage }, workerInfo) => { .first() .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.locator('#page_footBathPay').getByText('结算签字').click(); await expect(async () => { await zhbPage.locator('#page_footBathPay li').filter({ hasText: '现金' }).click(); 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(); + await zhbPage + .locator('#page_footBathPay span') + .filter({ hasText: /结\s算/ }) + .click(); + await expect(zhbPage.getByText('顾客满意度点评')).toBeVisible({ timeout: 2000 }); await zhbPage.getByText('不想评价').click(); await zhbPage.locator('#page_footBathPay').getByText('立即返回').click();