test(touch): 优化测试脚本的定位器和断言逻辑- 在 boss_appointment.spec.ts 中,将顾客预约的定位器从 '.a_userInfo' 修改为 'div.a_userInfo',提高定位准确性

- 在 boss_cashier.spec.ts 中,简化了已过期单据和已删除单据的测试流程,使用更高效的定位器和断言方式
- 优化了微信/支付宝收款和会员卡消费的测试步骤,使用 setCommonValue 替代 setValue 方法
This commit is contained in:
LingandRX 2025-01-03 22:29:51 +08:00
parent 6af040e406
commit c7f923d834
2 changed files with 20 additions and 38 deletions

View File

@ -191,7 +191,7 @@ test.describe('预约状态', () => {
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 const $customerAppointment = page
.locator('.a_userInfo') .locator('div.a_userInfo')
.filter({ hasText: customer.phone }) .filter({ hasText: customer.phone })
.filter({ hasText: customer.username }); .filter({ hasText: customer.username });

View File

@ -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();