新增美管加demo
This commit is contained in:
parent
4bca759adb
commit
1eab67953c
5
.env
5
.env
@ -10,6 +10,7 @@ ZHB_PASSWORD=1
|
||||
ZHB_BASE_URL="https://shengyibao.meiguanjia.net/young/"
|
||||
|
||||
|
||||
MGJ_ACCOUNT=小美美业
|
||||
MGJ_ACCOUNT=美管加演示
|
||||
MGJ_PASSWORD=1
|
||||
MGJ_BASE_URL="https://vip1.meiguanjia.net/shair/?v=mgj"
|
||||
# MGJ_BASE_URL="https://vip1.meiguanjia.net/shair/?v=mgj"
|
||||
MGJ_BASE_URL="https://young.meiguanjia.net/young/"
|
||||
@ -1,97 +1,56 @@
|
||||
const { test, expect } = require('./fixture/common');
|
||||
const { Customer } = require('./pom/customerPage');
|
||||
|
||||
test('demo', async ({ zhbPage, customerPage }) => {
|
||||
const $area = zhbPage
|
||||
.locator('.area')
|
||||
.filter({ has: zhbPage.locator('.area-name', { hasText: '二楼' }) });
|
||||
const $$room = $area.locator('.room-list .room');
|
||||
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 zhbPage.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();
|
||||
|
||||
let useRoomName;
|
||||
await test.step('购买商品', async () => {
|
||||
await zhbPage.locator('#tab_main li').filter({ hasText: '营业' }).click();
|
||||
const $emptyRoom = $$room.filter({ has: zhbPage.getByText('空房') }).first();
|
||||
useRoomName = await $emptyRoom.locator('.roomName').innerText();
|
||||
expect(useRoomName).not.toBeNull();
|
||||
await $emptyRoom.click();
|
||||
await expect(async () => {
|
||||
await zhbPage.getByRole('button', { name: '选择顾客' }).click();
|
||||
await expect(zhbPage.locator('#page_searchMember').getByText('创建会员')).toBeVisible();
|
||||
}).toPass();
|
||||
await zhbPage
|
||||
.getByRole('textbox', { name: '输入会员手机号或姓名或卡号搜索' })
|
||||
.fill(customer.phone, { delay: 100 });
|
||||
await zhbPage.locator('#page_searchMember svg').click();
|
||||
await expect(
|
||||
mgjPage.locator('#cashierTotalPanel span').filter({ hasText: /结\s算/ })
|
||||
).toBeVisible();
|
||||
|
||||
const $customerTr = zhbPage
|
||||
.locator('.list-warp')
|
||||
.filter({ has: zhbPage.locator('.name', { hasText: customer.name }) });
|
||||
await $customerTr.locator('.list-body').first().click();
|
||||
await mgjPage.waitForTimeout(1000);
|
||||
|
||||
await zhbPage.getByText('项目开单').click();
|
||||
await expect(zhbPage.locator('#page_roomDetail').getByText('服务项目')).toBeVisible();
|
||||
await zhbPage.getByText('选择', { exact: true }).nth(1).click();
|
||||
await expect(zhbPage.locator('#serviceSelector').getByText('项目选择')).toBeVisible();
|
||||
await zhbPage.getByText('臻品足疗 (10101)').click();
|
||||
await zhbPage.locator('#serviceSelector').getByText('确认').click();
|
||||
await zhbPage
|
||||
.locator('div')
|
||||
.filter({ hasText: /^匠星足浴$/ })
|
||||
.locator('span')
|
||||
.first()
|
||||
// 选择第一个项目
|
||||
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 zhbPage.getByRole('button', { name: '完成开单' }).click();
|
||||
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/
|
||||
);
|
||||
await zhbPage
|
||||
.locator('#page_footBathPay span')
|
||||
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(zhbPage.getByText('顾客满意度点评')).toBeVisible({ timeout: 2000 });
|
||||
await expect(mgjPage.getByText('顾客满意度点评')).toBeVisible({ timeout: 2000 });
|
||||
}).toPass();
|
||||
|
||||
await zhbPage.getByText('不想评价').click();
|
||||
await expect(zhbPage.locator('#page_footBathPay').getByText('立即返回')).not.toBeVisible();
|
||||
});
|
||||
|
||||
await test.step('起钟下钟,清理房间', async () => {
|
||||
const $cleanRoom = $$room.filter({
|
||||
has: zhbPage.locator('.roomName', { hasText: new RegExp(`^${useRoomName}$`) }),
|
||||
});
|
||||
await expect($cleanRoom).toContainText('已结清');
|
||||
await $cleanRoom.click();
|
||||
await zhbPage.getByText('技师操作').click();
|
||||
await zhbPage.getByText('起钟', { exact: true }).click();
|
||||
await zhbPage.getByText('起钟成功!').click();
|
||||
await zhbPage.getByText('技师操作').click();
|
||||
await zhbPage.getByText('下钟', { exact: true }).click();
|
||||
await zhbPage
|
||||
.locator('div')
|
||||
.filter({ hasText: /^确认返回$/ })
|
||||
.locator('div')
|
||||
.first()
|
||||
.click();
|
||||
await zhbPage.getByRole('button', { name: '不需要' }).click();
|
||||
|
||||
await expect($cleanRoom).toContainText('打扫');
|
||||
await $cleanRoom.click();
|
||||
await zhbPage
|
||||
.locator('div')
|
||||
.filter({ hasText: /^确定取消$/ })
|
||||
.locator('div')
|
||||
.first()
|
||||
.click();
|
||||
await expect($cleanRoom).toContainText('空房');
|
||||
await mgjPage.getByText('不想评价').click();
|
||||
await expect(mgjPage.locator('#page_footBathPay').getByText('立即返回')).not.toBeVisible();
|
||||
});
|
||||
});
|
||||
|
||||
@ -5,8 +5,8 @@ export const test = base.extend({
|
||||
/**
|
||||
* @type {CustomerPage}
|
||||
*/
|
||||
customerPage: async ({ zhbPage }, use) => {
|
||||
const customerPage = new CustomerPage(zhbPage);
|
||||
customerPage: async ({ mgjPage }, use) => {
|
||||
const customerPage = new CustomerPage(mgjPage);
|
||||
await use(customerPage);
|
||||
},
|
||||
});
|
||||
|
||||
@ -46,7 +46,7 @@ export class CustomerPage {
|
||||
.locator('span')
|
||||
.first()
|
||||
.click();
|
||||
await this.page.getByText('创建', { exact: true }).click();
|
||||
await this.page.getByText('创建并选择').click();
|
||||
await expect(this.page.getByText('用户资料创建成功!')).toBeVisible();
|
||||
await this.page.getByText('以后再说').click();
|
||||
await expect(this.page.getByText('以后再说')).not.toBeVisible();
|
||||
|
||||
@ -2,15 +2,16 @@ const { test: setup, expect } = require('@playwright/test');
|
||||
const path = require('path');
|
||||
const mgjAuthFile = path.join(__dirname, '../../.auth/mgj_admin.json');
|
||||
|
||||
|
||||
setup('mgj管理员登录', async ({ page,baseURL }) => {
|
||||
setup('mgj管理员登录', async ({ page, baseURL }) => {
|
||||
const account = process.env.MGJ_ACCOUNT;
|
||||
const password = process.env.MGJ_PASSWORD;
|
||||
|
||||
await page.goto(baseURL);
|
||||
await page.getByPlaceholder('请输入您的用户名').fill(account);
|
||||
await page.getByText('点击此处帐号登录').click();
|
||||
await page.getByPlaceholder('用户名').fill(account);
|
||||
await page.getByPlaceholder('请输入密码').fill(password);
|
||||
await page.getByText('登录', { exact: true }).click();
|
||||
await expect(page.getByRole('link', { name: '管理层' })).toBeVisible();
|
||||
await page.locator('#shopSelect').getByText('一店').click();
|
||||
await expect(page.locator('#autoStationTip').getByText('我知道了')).toBeVisible();
|
||||
await page.context().storageState({ path: mgjAuthFile });
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user