新增美管加demo

This commit is contained in:
wenpeng 2024-10-21 11:49:04 +08:00
parent 4bca759adb
commit 1eab67953c
5 changed files with 51 additions and 90 deletions

5
.env
View File

@ -10,6 +10,7 @@ ZHB_PASSWORD=1
ZHB_BASE_URL="https://shengyibao.meiguanjia.net/young/" ZHB_BASE_URL="https://shengyibao.meiguanjia.net/young/"
MGJ_ACCOUNT=小美美业 MGJ_ACCOUNT=美管加演示
MGJ_PASSWORD=1 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/"

View File

@ -1,97 +1,56 @@
const { test, expect } = require('./fixture/common'); const { test, expect } = require('./fixture/common');
const { Customer } = require('./pom/customerPage'); const { Customer } = require('./pom/customerPage');
test('demo', async ({ zhbPage, customerPage }) => { test('demo', async ({ mgjPage, customerPage }) => {
const $area = zhbPage await test.step('创建顾客', async () => {
.locator('.area') await expect(mgjPage.locator('#autoStationTip').getByText('我知道了')).toBeVisible();
.filter({ has: zhbPage.locator('.area-name', { hasText: '二楼' }) }); await mgjPage.locator('#autoStationTip').getByText('我知道了').click();
const $$room = $area.locator('.room-list .room'); await mgjPage.locator('#tab_main li').filter({ hasText: '顾客' }).click();
await zhbPage.locator('#tab_main li').filter({ hasText: '顾客' }).click();
const customer = new Customer(); const customer = new Customer();
await customerPage.createCustomer(customer); await customerPage.createCustomer(customer);
});
let useRoomName; await test.step('开单结算,购买第一个项目', async () => {
await test.step('购买商品', async () => { await mgjPage.getByText('去开单').click();
await zhbPage.locator('#tab_main li').filter({ hasText: '营业' }).click(); await mgjPage.locator('span').filter({ hasText: '确认开单' }).click();
const $emptyRoom = $$room.filter({ has: zhbPage.getByText('空房') }).first(); const firstEnabledElement = mgjPage
useRoomName = await $emptyRoom.locator('.roomName').innerText(); .locator('#createService .content ul .am-clickable:not(.am-disabled)')
expect(useRoomName).not.toBeNull(); .first();
await $emptyRoom.click(); await mgjPage.waitForTimeout(1000);
await expect(async () => { await firstEnabledElement.click();
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();
const $customerTr = zhbPage await expect(
.locator('.list-warp') mgjPage.locator('#cashierTotalPanel span').filter({ hasText: /结\s算/ })
.filter({ has: zhbPage.locator('.name', { hasText: customer.name }) }); ).toBeVisible();
await $customerTr.locator('.list-body').first().click();
await zhbPage.getByText('项目开单').click(); await mgjPage.waitForTimeout(1000);
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()
.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 mgjPage.locator('.cashierItems .am-clickable').first().click();
await expect(zhbPage.locator('#page_footBathPay li').filter({ hasText: '现金' })).toHaveClass( await expect(mgjPage.locator('.cashierBox tbody tr.am-clickable').first()).toBeVisible();
/selected/ await mgjPage
); .locator('#cashierTotalPanel span')
await zhbPage
.locator('#page_footBathPay span')
.filter({ hasText: /结\s算/ }) .filter({ hasText: /结\s算/ })
.click(); .click();
await expect(zhbPage.getByText('顾客满意度点评')).toBeVisible({ timeout: 2000 });
await expect(async () => {
const $signature = mgjPage.locator('#page_pay').getByText('结算签字');
await $signature.click();
await expect($signature).not.toHaveClass(/checked/, { timeout: 2000 });
}).toPass(); }).toPass();
await zhbPage.getByText('不想评价').click(); await expect(async () => {
await expect(zhbPage.locator('#page_footBathPay').getByText('立即返回')).not.toBeVisible(); const $cashBtn = mgjPage.locator('#page_pay .pay_cash');
}); await $cashBtn.click();
await expect(mgjPage.locator('#page_pay .pay_cash.selected')).toBeVisible();
await test.step('起钟下钟,清理房间', async () => { await mgjPage
const $cleanRoom = $$room.filter({ .locator('#page_pay span')
has: zhbPage.locator('.roomName', { hasText: new RegExp(`^${useRoomName}$`) }), .filter({ hasText: /结\s算/ })
});
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(); .click();
await zhbPage.getByRole('button', { name: '不需要' }).click(); await expect(mgjPage.getByText('顾客满意度点评')).toBeVisible({ timeout: 2000 });
}).toPass();
await expect($cleanRoom).toContainText('打扫'); await mgjPage.getByText('不想评价').click();
await $cleanRoom.click(); await expect(mgjPage.locator('#page_footBathPay').getByText('立即返回')).not.toBeVisible();
await zhbPage
.locator('div')
.filter({ hasText: /^确定取消$/ })
.locator('div')
.first()
.click();
await expect($cleanRoom).toContainText('空房');
}); });
}); });

View File

@ -5,8 +5,8 @@ export const test = base.extend({
/** /**
* @type {CustomerPage} * @type {CustomerPage}
*/ */
customerPage: async ({ zhbPage }, use) => { customerPage: async ({ mgjPage }, use) => {
const customerPage = new CustomerPage(zhbPage); const customerPage = new CustomerPage(mgjPage);
await use(customerPage); await use(customerPage);
}, },
}); });

View File

@ -46,7 +46,7 @@ export class CustomerPage {
.locator('span') .locator('span')
.first() .first()
.click(); .click();
await this.page.getByText('创建', { exact: true }).click(); await this.page.getByText('创建并选择').click();
await expect(this.page.getByText('用户资料创建成功!')).toBeVisible(); await expect(this.page.getByText('用户资料创建成功!')).toBeVisible();
await this.page.getByText('以后再说').click(); await this.page.getByText('以后再说').click();
await expect(this.page.getByText('以后再说')).not.toBeVisible(); await expect(this.page.getByText('以后再说')).not.toBeVisible();

View File

@ -2,15 +2,16 @@ const { test: setup, expect } = require('@playwright/test');
const path = require('path'); const path = require('path');
const mgjAuthFile = path.join(__dirname, '../../.auth/mgj_admin.json'); 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 account = process.env.MGJ_ACCOUNT;
const password = process.env.MGJ_PASSWORD; const password = process.env.MGJ_PASSWORD;
await page.goto(baseURL); 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.getByPlaceholder('请输入密码').fill(password);
await page.getByText('登录', { exact: true }).click(); 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 }); await page.context().storageState({ path: mgjAuthFile });
}); });