From d870c803782a03c3a875e9e61a06064297f53663 Mon Sep 17 00:00:00 2001 From: LingandRX Date: Thu, 7 Nov 2024 22:31:42 +0800 Subject: [PATCH] fix --- playwright.config.js | 2 +- tests/hlk/demo.spec.js | 5 +---- tests/mgj/demo.spec.js | 21 ++++++++++----------- 3 files changed, 12 insertions(+), 16 deletions(-) diff --git a/playwright.config.js b/playwright.config.js index 668190b..5cb9a12 100644 --- a/playwright.config.js +++ b/playwright.config.js @@ -24,7 +24,7 @@ module.exports = defineConfig({ /* Fail the build on CI if you accidentally left test.only in the source code. */ forbidOnly: !!process.env.CI, /* Retry on CI only */ - retries: process.env.CI ? 2 : 0, + retries: process.env.CI ? 1 : 0, /* Opt out of parallel tests on CI. */ workers: process.env.CI ? 1 : 1, /* Reporter to use. See https://playwright.dev/docs/test-reporters */ diff --git a/tests/hlk/demo.spec.js b/tests/hlk/demo.spec.js index d0e178d..ad64d74 100644 --- a/tests/hlk/demo.spec.js +++ b/tests/hlk/demo.spec.js @@ -4,7 +4,6 @@ const { faker } = require('@faker-js/faker/locale/zh_CN'); test('登录touch和h5,创建顾客购买会员卡,使用顾客账号到h5商城购买货品', async ({ touchPage, - h5Page, touchCustomerPage, h5LoginPage, }) => { @@ -12,15 +11,12 @@ test('登录touch和h5,创建顾客购买会员卡,使用顾客账号到h5 const customer = new Customer(1, 1, { phone: phone }); await touchCustomerPage.createCustomer(customer); - /** @type string*/ - let cardName; await test.step('在touch页面购买会员卡', async () => { await touchPage.getByText('去开单').click(); await touchPage.locator('.more > .icon > svg').click(); await touchPage.getByText('去开卡').click(); const $firstCard = touchPage.locator('.memberCard_box').first(); await $firstCard.click(); - cardName = await $firstCard.locator('.card_name').innerText(); await touchPage.getByRole('button', { name: '去结算' }).click(); await touchPage.locator('.row').filter({ hasText: '总额' }).locator('.touchIcon').click(); await touchPage.getByPlaceholder('请输入内容').fill('1000'); @@ -30,6 +26,7 @@ test('登录touch和h5,创建顾客购买会员卡,使用顾客账号到h5 await touchPage.getByLabel('结算签字').uncheck(); await touchPage.getByRole('button', { name: /结\s算/ }).click(); await touchPage.getByRole('button', { name: /跳\s过/ }).click(); + await touchPage.close(); }); await test.step('登录h5,并且商城页面使用会员卡进行购买', async () => { diff --git a/tests/mgj/demo.spec.js b/tests/mgj/demo.spec.js index c3761a7..c7bdfcd 100644 --- a/tests/mgj/demo.spec.js +++ b/tests/mgj/demo.spec.js @@ -39,18 +39,17 @@ test('demo', async ({ mgjPage, customerPage }) => { await expect($signature).not.toHaveClass(/checked/, { timeout: 2000 }); }).toPass(); + const $cashBtn = mgjPage.locator('#page_pay .pay_cash'); await expect(async () => { - const $cashBtn = mgjPage.locator('#page_pay .pay_cash'); - await $cashBtn.click(); - await expect(mgjPage.locator('#page_pay .pay_cash.selected')).toBeVisible(); - await mgjPage - .locator('#page_pay span') - .filter({ hasText: /结\s算/ }) - .click(); - await expect(mgjPage.getByText('顾客满意度点评')).toBeVisible({ timeout: 2000 }); + if ($cashBtn.isVisible()) { + await $cashBtn.click(); + } + await expect(mgjPage.locator('#page_pay .pay_cash.selected')).toBeVisible({ timeout: 2000 }); }).toPass(); - - await mgjPage.getByText('不想评价').click(); - await expect(mgjPage.locator('#page_footBathPay').getByText('立即返回')).not.toBeVisible(); + await mgjPage + .locator('#page_pay span') + .filter({ hasText: /结\s算/ }) + .click(); + await expect(mgjPage.getByText('顾客满意度点评')).toBeVisible(); }); });