Compare commits
2 Commits
e2647263a3
...
c7f923d834
| Author | SHA1 | Date | |
|---|---|---|---|
| c7f923d834 | |||
| 6af040e406 |
@ -5,7 +5,7 @@ import { getNextAppointmentTime } from '@/utils/timeUtils';
|
|||||||
/**
|
/**
|
||||||
* 预约状态颜色
|
* 预约状态颜色
|
||||||
*/
|
*/
|
||||||
type colorStatus = {
|
type status = {
|
||||||
name: string;
|
name: string;
|
||||||
color: string;
|
color: string;
|
||||||
quantity: number;
|
quantity: number;
|
||||||
@ -30,11 +30,11 @@ export class AppointmentPage {
|
|||||||
$customer: Locator;
|
$customer: Locator;
|
||||||
$occupy: Locator;
|
$occupy: Locator;
|
||||||
appointmentStatus: {
|
appointmentStatus: {
|
||||||
NORMAL: colorStatus;
|
NORMAL: status;
|
||||||
CONSULT: colorStatus;
|
CONSULT: status;
|
||||||
BILL: colorStatus;
|
BILL: status;
|
||||||
SETTLED: colorStatus;
|
SETTLED: status;
|
||||||
EXPIRED: colorStatus;
|
EXPIRED: status;
|
||||||
};
|
};
|
||||||
appointmentOperation: typeof AppointmentOperation;
|
appointmentOperation: typeof AppointmentOperation;
|
||||||
|
|
||||||
|
|||||||
@ -128,7 +128,10 @@ test('占用预约单元格', async ({
|
|||||||
await appointmentPage.operationAppointment(AppointmentOperation.ADD_REMARK);
|
await appointmentPage.operationAppointment(AppointmentOperation.ADD_REMARK);
|
||||||
// 进行添加备注,确认添加备注成功
|
// 进行添加备注,确认添加备注成功
|
||||||
await page.getByPlaceholder('请输入备注').fill(remark);
|
await page.getByPlaceholder('请输入备注').fill(remark);
|
||||||
await popupContent.confirm();
|
await Promise.all([
|
||||||
|
page.waitForResponse(res => res.url().includes('/reservation_num') && res.status() === 200),
|
||||||
|
popupContent.confirm(),
|
||||||
|
]);
|
||||||
// 判断备注后的单元格存在
|
// 判断备注后的单元格存在
|
||||||
await expect($$occupy.filter({ hasText: remark })).toBeVisible();
|
await expect($$occupy.filter({ hasText: remark })).toBeVisible();
|
||||||
});
|
});
|
||||||
@ -139,10 +142,11 @@ test('占用预约单元格', async ({
|
|||||||
// 取消占用
|
// 取消占用
|
||||||
await appointmentPage.operationAppointment(AppointmentOperation.CANCEL_OCCUPY);
|
await appointmentPage.operationAppointment(AppointmentOperation.CANCEL_OCCUPY);
|
||||||
// 判断取消占用成功
|
// 判断取消占用成功
|
||||||
await expect(async () => {
|
await Promise.all([
|
||||||
await popupContent.confirm();
|
page.waitForResponse(res => res.url().includes('/reservation_num') && res.status() === 200),
|
||||||
await expect($$occupy.filter({ hasText: remark })).not.toBeVisible({ timeout: 1500 });
|
popupContent.confirm(),
|
||||||
}).toPass();
|
]);
|
||||||
|
await expect($$occupy.filter({ hasText: remark })).not.toBeVisible();
|
||||||
});
|
});
|
||||||
|
|
||||||
await test.step('取消占用后,能够进行预约', async () => {
|
await test.step('取消占用后,能够进行预约', async () => {
|
||||||
@ -185,15 +189,14 @@ test.describe('预约状态', () => {
|
|||||||
const $time = page.locator('.times_table td').filter({ hasText: appointmentTime });
|
const $time = page.locator('.times_table td').filter({ hasText: appointmentTime });
|
||||||
// 员工定位器
|
// 员工定位器
|
||||||
const $employee = page.locator('.room_table .tr .name_th').filter({ hasText: employee.name });
|
const $employee = page.locator('.room_table .tr .name_th').filter({ hasText: employee.name });
|
||||||
|
// 顾客预约定位器
|
||||||
// 获取设置的预约状态
|
const $customerAppointment = page
|
||||||
let appointmentStatusSetting;
|
.locator('div.a_userInfo')
|
||||||
await test.step('获取预约状态', async () => {
|
.filter({ hasText: customer.phone })
|
||||||
await homeNavigation.gotoModule('预约');
|
.filter({ hasText: customer.username });
|
||||||
appointmentStatusSetting = await appointmentPage.getAppointmentStatusSetting();
|
|
||||||
});
|
|
||||||
|
|
||||||
await test.step('进行创建预约', async () => {
|
await test.step('进行创建预约', async () => {
|
||||||
|
await homeNavigation.gotoModule('预约');
|
||||||
await $time.scrollIntoViewIfNeeded();
|
await $time.scrollIntoViewIfNeeded();
|
||||||
await $employee.scrollIntoViewIfNeeded();
|
await $employee.scrollIntoViewIfNeeded();
|
||||||
// 打开预约单元格,进行预约
|
// 打开预约单元格,进行预约
|
||||||
@ -201,68 +204,63 @@ test.describe('预约状态', () => {
|
|||||||
await appointmentPage.operationAppointment(AppointmentOperation.ADD_APPOINT);
|
await appointmentPage.operationAppointment(AppointmentOperation.ADD_APPOINT);
|
||||||
await customerPage.searchCustomer(customer.phone);
|
await customerPage.searchCustomer(customer.phone);
|
||||||
await customerPage.selectSearchCustomer(customer.phone);
|
await customerPage.selectSearchCustomer(customer.phone);
|
||||||
await expect.soft(page.locator('.newAppointmentContent .header_title')).toContainText('新建预约');
|
await expect(page.locator('div.name_box div.phone')).toContainText(customer.phone);
|
||||||
await expect(page.locator('.newAppointmentContent .content .phone')).toContainText(customer.phone);
|
await expect(page.locator('div.user_box')).toContainText(employee.name);
|
||||||
await page.getByRole('button', { name: '确认新建' }).click();
|
await page.getByRole('button', { name: '确认新建' }).click();
|
||||||
await expect(page.locator('.ant-message', { hasText: '预约成功' })).toBeVisible();
|
await expect($customerAppointment).toBeVisible();
|
||||||
});
|
});
|
||||||
|
|
||||||
await test.step('判断预约,状态为未到店', async () => {
|
await test.step('判断预约,状态为未到店', async () => {
|
||||||
const { customerColor, customerStatus } = await appointmentPage.getCustomerAppointmentStatus(customer);
|
await appointmentPage.openAppointmentDetail(customer.phone);
|
||||||
// 进入未到店状态
|
await expect(page.locator('div.state')).toContainText('未到店');
|
||||||
expect.soft(customerColor).toEqual(appointmentStatusSetting.NORMAL.color);
|
|
||||||
expect(customerStatus).toEqual(appointmentStatusSetting.NORMAL.name);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
await test.step('进行挂单,状态为已开单', async () => {
|
await test.step('进行挂单,状态为已开单', async () => {
|
||||||
await page
|
|
||||||
.locator('.a_userInfo', { hasText: customer.username })
|
|
||||||
.first()
|
|
||||||
.locator('.user_name_info')
|
|
||||||
.click();
|
|
||||||
// 预约进行挂单
|
// 预约进行挂单
|
||||||
await page.getByRole('button', { name: '到店开单' }).click();
|
await page.getByRole('button', { name: '到店开单' }).click();
|
||||||
await page
|
await page
|
||||||
.locator('.project_list')
|
.locator('div.project_list')
|
||||||
.filter({ hasText: project.name })
|
.filter({ hasText: project.name })
|
||||||
.filter({ hasText: project.no })
|
.filter({ hasText: project.no })
|
||||||
.click();
|
.click();
|
||||||
await page.locator('.hold_bill', { hasText: '挂单' }).click();
|
await Promise.all([
|
||||||
await expect(page.locator('.ant-message', { hasText: '挂单成功' })).toBeVisible();
|
page.waitForResponse(res => res.url().includes('/bill') && res.status() === 200),
|
||||||
|
page.locator('div.hold_bill', { hasText: '挂单' }).click(),
|
||||||
|
]);
|
||||||
|
|
||||||
await homeNavigation.gotoModule('预约');
|
await homeNavigation.gotoModule('预约');
|
||||||
|
|
||||||
// 获取当前预约的状态
|
await appointmentPage.openAppointmentDetail(customer.phone);
|
||||||
const { customerColor, customerStatus } = await appointmentPage.getCustomerAppointmentStatus(customer);
|
await expect(page.locator('div.state')).toContainText('已开单');
|
||||||
// 进入未到店状态
|
|
||||||
expect.soft(customerColor).toEqual(appointmentStatusSetting.BILL.color);
|
|
||||||
expect(customerStatus).toEqual(appointmentStatusSetting.BILL.name);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
await test.step('进行结算,状态为已结算', async () => {
|
await test.step('进行结算,状态为已结算', async () => {
|
||||||
await page
|
|
||||||
.locator('.a_userInfo', { hasText: customer.username })
|
|
||||||
.first()
|
|
||||||
.locator('.user_name_info')
|
|
||||||
.click();
|
|
||||||
await page.getByRole('button', { name: /取\s单/ }).click();
|
await page.getByRole('button', { name: /取\s单/ }).click();
|
||||||
await page.locator('.pay_btn', { hasText: /结\s算/ }).click();
|
await page.locator('div.pay_btn', { hasText: /结\s算/ }).click();
|
||||||
// 取消推送消费提醒和结算签字
|
// 取消推送消费提醒和结算签字
|
||||||
await page.getByLabel('推送消费提醒').uncheck();
|
await page.getByLabel('推送消费提醒').uncheck();
|
||||||
await page.getByLabel('结算签字').uncheck();
|
await page.getByLabel('结算签字').uncheck();
|
||||||
await page.locator('.paytype .paymentInfoItem', { hasText: '现金' }).click();
|
await page.locator('div.paymentInfoItem', { hasText: '现金' }).click();
|
||||||
// 结算
|
// 结算
|
||||||
const [response] = await Promise.all([
|
const [response] = await Promise.all([
|
||||||
page.waitForResponse(async res => {
|
page.waitForResponse(res => res.url().includes('/bill') && res.status() === 200 && res.request().method() === 'POST'),
|
||||||
return res.url().includes('/bill') && (await res.json()).code === 'SUCCESS';
|
|
||||||
}),
|
|
||||||
page.getByRole('button', { name: /结\s算/ }).click(),
|
page.getByRole('button', { name: /结\s算/ }).click(),
|
||||||
]);
|
]);
|
||||||
const responseBody = await response.json();
|
const billNo = (await response.json())?.content?.billNo;
|
||||||
const billNo = responseBody?.content?.billNo;
|
|
||||||
expect(billNo).not.toBeNull();
|
|
||||||
billSet.add(billNo);
|
billSet.add(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.addLocatorHandler(page.getByRole('button', { name: '我知道了' }), async () => {
|
await page.addLocatorHandler(page.getByRole('button', { name: '我知道了' }), async () => {
|
||||||
await page.getByRole('button', { name: '我知道了' }).click();
|
await page.getByRole('button', { name: '我知道了' }).click();
|
||||||
@ -273,11 +271,8 @@ test.describe('预约状态', () => {
|
|||||||
|
|
||||||
// 进入预约模块
|
// 进入预约模块
|
||||||
await homeNavigation.gotoModule('预约');
|
await homeNavigation.gotoModule('预约');
|
||||||
// 获取当前创建预约的状态
|
await appointmentPage.openAppointmentDetail(customer.phone);
|
||||||
const { customerColor, customerStatus } = await appointmentPage.getCustomerAppointmentStatus(customer);
|
await expect(page.locator('div.state')).toContainText('已结算');
|
||||||
// 进入未到店状态
|
|
||||||
expect.soft(customerColor).toEqual(appointmentStatusSetting.SETTLED.color);
|
|
||||||
expect(customerStatus).toEqual(appointmentStatusSetting.SETTLED.name);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -276,26 +276,19 @@ test.describe('挂单', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('已过期单据不能取单,只能删除', async ({ page }) => {
|
test('已过期单据不能取单,只能删除', async ({ page }) => {
|
||||||
// 点击已过期 / 删除单据
|
const $slidingMenu = page.locator('div.deleteList .m_sliding_menu');
|
||||||
await page.getByText('已过期 / 删除单据').click();
|
await page.getByText('已过期 / 删除单据').click();
|
||||||
// 等待过期删除水单页面出来
|
await page.getByText('警告:已过期服务无法取单结算,请至收银台处理').waitFor();
|
||||||
await page.locator('.deleteList').locator('.item_box').first().waitFor();
|
await $slidingMenu.locator('div.item_box').first().waitFor();
|
||||||
// 水单都没有取单
|
await expect($slidingMenu.locator('div.item_box').first().getByRole('button', { name: /^取\s单$/ })).not.toBeVisible();
|
||||||
const PendingOrder_1 = page.locator('.deleteList').locator('.item_box');
|
|
||||||
|
const $delete = $slidingMenu.locator('div.item_box').first().locator('.comment > div:nth-child(2) > .touchIcon');
|
||||||
|
await $delete.click();
|
||||||
|
await page.getByPlaceholder('请输入1-100个字符备注内容').click();
|
||||||
|
await page.getByPlaceholder('请输入1-100个字符备注内容').fill('测试备注');
|
||||||
|
|
||||||
await expect(PendingOrder_1.getByRole('button', { name: /^取\s单$/ })).not.toBeVisible();
|
|
||||||
await page
|
|
||||||
.locator(
|
|
||||||
'div:nth-child(3) > .scroller-body > .alloytouch-target > .list > div > .item > .comment > div:nth-child(2) > .touchIcon',
|
|
||||||
)
|
|
||||||
.first()
|
|
||||||
.click();
|
|
||||||
await expect(async () => {
|
|
||||||
await page.locator('label').filter({ hasText: '1' }).click();
|
|
||||||
await page.locator('.ant-radio-checked').waitFor();
|
|
||||||
}).toPass();
|
|
||||||
await page.getByRole('button', { name: /^保\s存$/ }).click();
|
await page.getByRole('button', { name: /^保\s存$/ }).click();
|
||||||
await expect(page.locator('div').filter({ hasText: '删除成功' }).nth(2)).toBeVisible();
|
await expect(page.locator('.ant-message').filter({ hasText: '删除成功' }).nth(2)).toBeVisible();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -390,22 +383,13 @@ test.describe('挂单', () => {
|
|||||||
|
|
||||||
test('已删除单据不能取单,也不能删除', async ({ page }) => {
|
test('已删除单据不能取单,也不能删除', async ({ page }) => {
|
||||||
// 找到已过期/删除单据
|
// 找到已过期/删除单据
|
||||||
await page.locator('.cash_content > .main > .top').getByText('已过期').click();
|
await page.getByText('已过期 / 删除单据').click();
|
||||||
await expect(async () => {
|
await expect(page.getByText('已删除服务', { exact: true })).toBeInViewport();
|
||||||
// 点击已删除服务
|
await page.getByText('已删除服务', { exact: true }).click();
|
||||||
await page.getByText(' 已删除服务 ').click();
|
await expect(page.getByText('警告:已过期服务无法取单结算,请至收银台处理')).not.toBeInViewport();
|
||||||
await page.locator('.loading_container').waitFor({ state: 'hidden' });
|
const $slidingMenu = page.locator('div.deleteList .m_sliding_menu');
|
||||||
// 等待过期删除水单页面出来
|
await expect($slidingMenu.locator('div.item_box').first()).toBeVisible();
|
||||||
await page.locator('.deleteList').locator('.item_box').first().waitFor({ timeout: 2000 });
|
await expect($slidingMenu.locator('div.comment > i.anticon').first()).not.toBeVisible();
|
||||||
// 判断有没有取单和删除
|
|
||||||
const PendingOrder = page.locator('.deleteList').locator('.item_box');
|
|
||||||
await expect(PendingOrder.getByRole('button', { name: /^取\s单$/ })).not.toBeVisible();
|
|
||||||
await expect(
|
|
||||||
page.locator(
|
|
||||||
'div:nth-child(3) > .scroller-body > .alloytouch-target > .list > div > .item > .comment > div:nth-child(2) > .touchIcon',
|
|
||||||
),
|
|
||||||
).not.toBeVisible();
|
|
||||||
}).toPass();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('微信/支付宝收款', async ({ page, homeNavigation, baseURL }) => {
|
test('微信/支付宝收款', async ({ page, homeNavigation, baseURL }) => {
|
||||||
@ -1247,8 +1231,6 @@ test.describe('收银-开单&结算', () => {
|
|||||||
await expect(page.locator('.membercard_box .bonuses').first()).toContainText('100');
|
await expect(page.locator('.membercard_box .bonuses').first()).toContainText('100');
|
||||||
});
|
});
|
||||||
|
|
||||||
await page.reload();
|
|
||||||
|
|
||||||
await test.step('使用卡金和赠金', async () => {
|
await test.step('使用卡金和赠金', async () => {
|
||||||
//使用卡金和赠金
|
//使用卡金和赠金
|
||||||
await page.reload();
|
await page.reload();
|
||||||
@ -1274,13 +1256,13 @@ test.describe('收银-开单&结算', () => {
|
|||||||
await page.getByText('卡金').nth(4).click();
|
await page.getByText('卡金').nth(4).click();
|
||||||
await page.getByRole('button', { name: '增加收款' }).click();
|
await page.getByRole('button', { name: '增加收款' }).click();
|
||||||
// 输入金额
|
// 输入金额
|
||||||
await numberInput.setValue(100);
|
await numberInput.setCommonValue(100);
|
||||||
await numberInput.confirmValue();
|
await numberInput.confirmValue();
|
||||||
// 选择赠送金支付
|
// 选择赠送金支付
|
||||||
await page.getByText('赠金').nth(2).click();
|
await page.getByText('赠金').nth(2).click();
|
||||||
await page.getByRole('button', { name: '增加收款' }).click();
|
await page.getByRole('button', { name: '增加收款' }).click();
|
||||||
// 输入金额
|
// 输入金额
|
||||||
await numberInput.setValue(90);
|
await numberInput.setCommonValue(90);
|
||||||
await numberInput.confirmValue();
|
await numberInput.confirmValue();
|
||||||
// 结算
|
// 结算
|
||||||
await page.getByRole('button', { name: /^结\s算$/ }).click();
|
await page.getByRole('button', { name: /^结\s算$/ }).click();
|
||||||
|
|||||||
Reference in New Issue
Block a user