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.
playwright-demo/tests/mgj/demo.spec.js
2024-10-21 11:49:04 +08:00

57 lines
2.2 KiB
JavaScript

const { test, expect } = require('./fixture/common');
const { Customer } = require('./pom/customerPage');
test('demo', async ({ mgjPage, customerPage }) => {
await test.step('创建顾客', async () => {
await expect(mgjPage.locator('#autoStationTip').getByText('我知道了')).toBeVisible();
await mgjPage.locator('#autoStationTip').getByText('我知道了').click();
await mgjPage.locator('#tab_main li').filter({ hasText: '顾客' }).click();
const customer = new Customer();
await customerPage.createCustomer(customer);
});
await test.step('开单结算,购买第一个项目', async () => {
await mgjPage.getByText('去开单').click();
await mgjPage.locator('span').filter({ hasText: '确认开单' }).click();
const firstEnabledElement = mgjPage
.locator('#createService .content ul .am-clickable:not(.am-disabled)')
.first();
await mgjPage.waitForTimeout(1000);
await firstEnabledElement.click();
await expect(
mgjPage.locator('#cashierTotalPanel span').filter({ hasText: /结\s算/ })
).toBeVisible();
await mgjPage.waitForTimeout(1000);
// 选择第一个项目
await mgjPage.locator('.cashierItems .am-clickable').first().click();
await expect(mgjPage.locator('.cashierBox tbody tr.am-clickable').first()).toBeVisible();
await mgjPage
.locator('#cashierTotalPanel span')
.filter({ hasText: /结\s算/ })
.click();
await expect(async () => {
const $signature = mgjPage.locator('#page_pay').getByText('结算签字');
await $signature.click();
await expect($signature).not.toHaveClass(/checked/, { timeout: 2000 });
}).toPass();
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 });
}).toPass();
await mgjPage.getByText('不想评价').click();
await expect(mgjPage.locator('#page_footBathPay').getByText('立即返回')).not.toBeVisible();
});
});