test(boss_customer): 优化顾客相关测试的结算流程和动态查看功能
- 移除了不必要的日期相关变量和计算 - 优化了结算流程,增加了对结算状态的验证 - 改进了动态查看功能,增加了对当前月份动态的精确查找和验证 -修复了一些测试步骤中的潜在问题,提高了测试的稳定性和准确性
This commit is contained in:
parent
c7f923d834
commit
e55b84e3cc
@ -1041,11 +1041,6 @@ test.describe('顾客详情', () => {
|
||||
|
||||
test('操作套餐', async ({ page, homeNavigation, customerPage, createCustomer }) => {
|
||||
let billNo: string;
|
||||
const date = new Date();
|
||||
const currentYear = date.getFullYear();
|
||||
const currentMonth = date.getMonth() + 1;
|
||||
const currentDay = date.getDate();
|
||||
const dayStr = currentDay >= 10 ? `${currentDay}` : `0${currentDay}`;
|
||||
// 套餐的名称
|
||||
const $setMeal = page.getByText('护理修护全套');
|
||||
// 套餐的所有项目
|
||||
@ -1071,14 +1066,24 @@ test.describe('顾客详情', () => {
|
||||
|
||||
// 结算
|
||||
const [response] = await Promise.all([
|
||||
page.waitForResponse(async res => {
|
||||
return res.url().includes('/bill') && (await res.json()).code === 'SUCCESS';
|
||||
}),
|
||||
page.waitForResponse(res => res.url().includes('/bill') && res.status() === 200 && res.request().method() === 'POST'),
|
||||
page.getByRole('button', { name: /跳\s过/ }).click(),
|
||||
]);
|
||||
const responseBody = await response.json();
|
||||
billNo = responseBody?.content?.billNo;
|
||||
expect(billNo).not.toBeNull();
|
||||
|
||||
billNo = (await response.json())?.content?.billNo;
|
||||
|
||||
await page.waitForResponse(async res => {
|
||||
if (
|
||||
res.url().includes('/bill_status') &&
|
||||
res.status() === 200 &&
|
||||
res.request().method() === 'GET'
|
||||
) {
|
||||
const responseBody = await res.json(); // 等待解析 JSON
|
||||
return responseBody?.content?.status === 'SETTLED';
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
await page.getByRole('button', { name: '不寄存' }).click();
|
||||
});
|
||||
|
||||
@ -1103,19 +1108,17 @@ test.describe('顾客详情', () => {
|
||||
});
|
||||
|
||||
await test.step('冻结有效期-解冻有效期', async () => {
|
||||
// 冻结日期
|
||||
const freezeStr = `${currentYear}-${currentMonth}-${dayStr}冻结`;
|
||||
// 冻结有效期
|
||||
await $$treatCard.first().locator('svg').last().click();
|
||||
await page.getByText('冻结有效期').click();
|
||||
await Promise.all([page.getByRole('button', { name: /确\s认/ }).click(), page.waitForLoadState()]);
|
||||
await expect(page.locator('.ant-message')).toContainText('修改成功');
|
||||
await expect($$treatCard.first().locator('.deadline_row span')).toContainText(freezeStr);
|
||||
await expect($$treatCard.first().locator('.deadline_row span')).toContainText('冻结');
|
||||
// 解冻有效期
|
||||
await expect(async () => {
|
||||
await $$treatCard.first().locator('svg').last().click();
|
||||
await page.getByText('解冻有效期').click({ timeout: 2000 });
|
||||
await expect($$treatCard.first().locator('.deadline_row span')).not.toContainText(freezeStr, {
|
||||
await expect($$treatCard.first().locator('.deadline_row span')).not.toContainText('冻结', {
|
||||
timeout: 2000,
|
||||
});
|
||||
}).toPass();
|
||||
@ -1417,35 +1420,37 @@ test.describe('顾客详情', () => {
|
||||
const currentMonth = date.getMonth() + 1;
|
||||
const currentDay = date.getDate();
|
||||
|
||||
/**@type {string} */
|
||||
let billNo = '';
|
||||
let billNo: string;
|
||||
await test.step('开单拿取单号', async () => {
|
||||
await homeNavigation.gotoModule('收银');
|
||||
await page.getByRole('button', { name: /开\s单/ }).click();
|
||||
await page.getByPlaceholder('姓名(拼音首字)、手机号、档案号搜索').fill(customer.phone);
|
||||
await page.getByText('搜索', { exact: true }).click();
|
||||
await page.locator('.member_list_li').filter({ hasText: customer.phone }).click();
|
||||
await customerPage.searchCustomer(customer.phone);
|
||||
await customerPage.selectSearchCustomer(customer.phone);
|
||||
await page.locator('.list_box .project_list').first().click();
|
||||
await page
|
||||
.locator('.pay_btn')
|
||||
.filter({ hasText: /^结\s算$/ })
|
||||
.click();
|
||||
//取消推送消息提醒
|
||||
await page.locator('div.pay_btn').filter({ hasText: /^结\s算$/ }).click();
|
||||
await page.getByLabel('推送消费提醒').uncheck();
|
||||
//取消结算签字
|
||||
await page.getByLabel('结算签字').uncheck();
|
||||
await page.locator('.paymentInfoItem').first().click();
|
||||
|
||||
// 结算
|
||||
const [response] = await Promise.all([
|
||||
page.waitForResponse(async res => {
|
||||
return res.url().includes('/bill') && (await res.json()).code === 'SUCCESS';
|
||||
}),
|
||||
page.getByRole('button', { name: /^结\s算$/ }).click(),
|
||||
page.waitForResponse(res => res.url().includes('/bill') && res.status() === 200 && res.request().method() === 'POST'),
|
||||
page.getByRole('button', { name: /结\s算/ }).click(),
|
||||
]);
|
||||
|
||||
billNo = (await response.json())?.content?.billNo;
|
||||
expect(billNo).not.toBeNull();
|
||||
|
||||
await page.waitForResponse(async res => {
|
||||
if (
|
||||
res.url().includes('/bill_status') &&
|
||||
res.status() === 200 &&
|
||||
res.request().method() === 'GET'
|
||||
) {
|
||||
const responseBody = await res.json(); // 等待解析 JSON
|
||||
return responseBody?.content?.status === 'SETTLED';
|
||||
}
|
||||
return false;
|
||||
});
|
||||
});
|
||||
|
||||
await test.step('进入顾客详情页面', async () => {
|
||||
@ -1482,36 +1487,32 @@ test.describe('顾客详情', () => {
|
||||
});
|
||||
|
||||
// 今年所有月份的动态
|
||||
const $$dynamic = page.locator('.calendar_year_list', { hasText: `${currentYear}` }).locator('.dynamic_list');
|
||||
const $$dynamic = page.locator('div.calendar_year_list', { hasText: `${currentYear}` }).locator('.dynamic_list');
|
||||
// 当前月份的动态
|
||||
const $currentForMonthDynamic = $$dynamic.filter({
|
||||
has: page.locator('.month_box', { hasText: `${currentMonth}` }),
|
||||
const $currentMonthDynamic = $$dynamic.filter({
|
||||
has: page.locator('.month_box').getByText(`${currentMonth}`, { exact: true }),
|
||||
});
|
||||
|
||||
await test.step('查看月动态-缩略', async () => {
|
||||
await page
|
||||
.locator('div')
|
||||
.filter({ hasText: /^日月$/ })
|
||||
.getByRole('switch')
|
||||
.click();
|
||||
await page.locator('div').filter({ hasText: /^日月$/ }).getByRole('switch').click();
|
||||
await expect(page.getByText('月', { exact: true })).toHaveClass('selected_btn');
|
||||
|
||||
await expect(async () => {
|
||||
await $currentForMonthDynamic.click();
|
||||
await $currentMonthDynamic.click();
|
||||
await expect(page.getByRole('tabpanel').getByText(billNo)).toBeVisible();
|
||||
}).toPass();
|
||||
await page.locator('.action_detail > .container > .m_sliding_menu > .box > .top > .anticon').click();
|
||||
|
||||
await page.locator('div.action_detail div.m_sliding_menu div.top i.anticon').click();
|
||||
});
|
||||
|
||||
await test.step('查看月动态-日期', async () => {
|
||||
await page
|
||||
.locator('div')
|
||||
.filter({ hasText: /^缩略日期$/ })
|
||||
.getByRole('switch')
|
||||
.click();
|
||||
await page.locator('div').filter({ hasText: /^缩略日期$/ }).getByRole('switch').click();
|
||||
await expect(page.getByText('日期', { exact: true })).toHaveClass('selected_btn');
|
||||
|
||||
await $currentForMonthDynamic.filter({ hasText: `${currentDay}` }).click();
|
||||
const $$dateList = $currentMonthDynamic.locator('div.date_list');
|
||||
await expect(async () => {
|
||||
await $$dateList.getByText(`${currentDay}`, { exact: true }).click();
|
||||
await expect(page.getByRole('tabpanel').getByText(billNo)).toBeVisible();
|
||||
}).toPass();
|
||||
await expect(page.getByRole('tabpanel').getByText(billNo)).toBeVisible();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user