From cf67a1c95c3979c50776eb2ee4606012a3f69fea Mon Sep 17 00:00:00 2001 From: LingandRX Date: Sun, 22 Dec 2024 19:20:24 +0800 Subject: [PATCH] =?UTF-8?q?test:=20=E7=A7=BB=E9=99=A4=E9=A2=84=E7=BA=A6?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E7=9B=B8=E5=85=B3=E7=9A=84=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E7=94=A8=E4=BE=8B=20-=20=E5=88=A0=E9=99=A4=E4=BA=86=E9=A2=84?= =?UTF-8?q?=E7=BA=A6=E8=AE=BE=E7=BD=AE=E3=80=81=E5=AF=BC=E5=87=BA=E5=9B=BE?= =?UTF-8?q?=E7=89=87=E5=92=8C=E8=A7=86=E5=9B=BE=E8=B0=83=E6=95=B4=E7=AD=89?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/touch/boss_appointment.spec.ts | 224 --------------------------- 1 file changed, 224 deletions(-) diff --git a/tests/touch/boss_appointment.spec.ts b/tests/touch/boss_appointment.spec.ts index 87e3d30..1efc703 100644 --- a/tests/touch/boss_appointment.spec.ts +++ b/tests/touch/boss_appointment.spec.ts @@ -341,230 +341,6 @@ test.describe('预约状态', () => { }); }); -test.describe.skip('预约设置', () => { - test('看板设置', async ({ page, homeNavigation, createCustomer, appointmentPage, customerPage }) => { - let setAppointmentTime = appointmentPage.getAppointmentTimesAvailable(); - - const customer = createCustomer; - - const employee = staffData.firstStore.firstSector.employee_6; - let switchStatus; // - let nowNormalColor; // 当前模块颜色 - let nowAppointmentColor; //当前预约颜色 - - const customerRemarkLocator = page - .locator('.appointment_content', { hasText: customer.username }) - .locator('.remark_info', { hasText: '测试看板设置' }); - const normal = page.locator('.herder_right ul > li', { hasText: '未到店' }); - const merchantRemarkLocator = page.locator('li').filter({ hasText: '商家备注' }); - const $time = page.locator('.times_table td'); - const $employee = page.locator('.room_table .tr .name_th').filter({ hasText: employee.name }); - - await test.step('创建预约', async () => { - await homeNavigation.gotoModule('预约'); - await $time.filter({ hasText: setAppointmentTime }).scrollIntoViewIfNeeded(); - await $employee.scrollIntoViewIfNeeded(); - await appointmentPage.openAppointmentCell(employee.name); - - await page.locator('.popup_content', { hasText: '选择操作' }).waitFor(); - await expect(async () => { - await appointmentPage.operationAppointment(AppointmentOperation.ADD_APPOINT); - await page.getByText('选择会员').waitFor({ timeout: 2000 }); - }).toPass(); - await customerPage.searchCustomer(customer.phone); - await customerPage.selectSearchCustomer(customer.phone); - await expect(page.locator('.newAppointmentContent .header_title')).toContainText('新建预约'); - await expect(page.locator('.newAppointmentContent .content .phone')).toContainText(customer.phone); - await page.getByRole('button', { name: '确认新建' }).click(); - await expect(page.locator('.ant-message', { hasText: '预约成功' })).toBeVisible(); - }); - - await test.step('给顾客预约添加备注', async () => { - await page - .locator('.a_userInfo', { hasText: customer.username }) - .first() - .locator('.user_name_info') - .click(); - await page.locator('.my_remark .write').click(); - await page.getByPlaceholder('请输入1-100个字符备注内容').fill('测试看板设置'); - await page.getByRole('button', { name: /确\s认/ }).click(); - await page.locator('.info_center .close').click(); - - await expect(customerRemarkLocator).toBeVisible(); - }); - - await test.step('修改商家备注为关闭、修改未到店的颜色', async () => { - await page.getByRole('button', { name: /设\s置/ }).click(); - await page.getByRole('menuitem', { name: '看板设置' }).click(); - let switchStatus = page.locator('li').filter({ hasText: '商家备注' }).getByRole('switch'); - await expect(switchStatus).toHaveText('开'); - await page.locator('li').filter({ hasText: '商家备注' }).getByRole('switch').click(); - await expect(switchStatus).toHaveText('关'); - - // 修改未到店的颜色 - await page - .locator('li') - .filter({ hasText: /^未到店$/ }) - .locator('div') - .nth(3) - .click(); - // rgb(0, 0, 0) - // D42525 - await page.getByLabel('r', { exact: true }).fill('0'); - await page.getByLabel('g', { exact: true }).fill('0'); - await page.getByLabel('b', { exact: true }).fill('0'); - - await page.getByText('看板信息').click(); - await page.locator('.close > svg > use').first().click(); - // 获取预约状态Color - nowNormalColor = await normal.locator('.status').evaluate(e => { - return window.getComputedStyle(e).backgroundColor; - }); - - // 获取当前创建预约的状态 - nowAppointmentColor = await page - .locator('.a_userInfo', { hasText: customer.username }) - .first() - .locator('.appointment') - .evaluate(e => { - return window.getComputedStyle(e).backgroundColor; - }); - - // 判断商家备注被关闭 - await expect(customerRemarkLocator).not.toBeVisible(); - // 判断未到店颜色被修改 - expect.soft(nowNormalColor).toEqual('rgb(0, 0, 0)'); - // 判断预约颜色被修改 - expect(nowAppointmentColor).toEqual('rgb(0, 0, 0)'); - }); - - await test.step('恢复默认值', async () => { - // 恢复默认 - await page.getByRole('button', { name: /设\s置/ }).click(); - await page.getByRole('menuitem', { name: '看板设置' }).click(); - switchStatus = merchantRemarkLocator.getByRole('switch'); - await expect(switchStatus).toHaveText('关'); - await merchantRemarkLocator.getByRole('switch').click(); - switchStatus = merchantRemarkLocator.getByRole('switch'); - await expect(switchStatus).toHaveText('开'); - await page - .locator('li') - .filter({ hasText: /^未到店$/ }) - .locator('span') - .nth(1) - .click(); - // await page.getByLabel('hex', { exact: true }).fill("D42525"); - await page.getByLabel('r', { exact: true }).fill('212'); - await page.getByLabel('g', { exact: true }).fill('37'); - await page.getByLabel('b', { exact: true }).fill('37'); - await page.getByText('状态颜色').click(); - await page.locator('.m_sliding_bg').click(); - - // 获取预约状态Color - nowNormalColor = await normal.locator('.status').evaluate(e => { - return window.getComputedStyle(e).backgroundColor; - }); - expect(nowNormalColor).toEqual('rgb(212, 37, 37)'); - }); - }); - - test('导出图片', async ({ page, homeNavigation }) => { - await homeNavigation.gotoModule('预约'); - await page.locator('.herder_right').getByRole('button').nth(1).click(); - const downloadPromise = page.waitForEvent('download'); - await page.getByRole('menuitem', { name: '导出图片' }).click(); - const download = await downloadPromise; - - // 获取下载的文件名 - const fileName = download.suggestedFilename(); - - // 指定保存下载文件的路径 - const downloadPath = path.join(__dirname, `@/imgs/${fileName}`); - - // 保存下载的文件 - await download.saveAs(downloadPath); - - // 验证文件是否成功保存 - const fileExists = fs.existsSync(downloadPath); - expect(fileExists).toBeTruthy(); - }); - - test('视图调整', async ({ page, homeNavigation, appointmentPage }) => { - const cellBox = { height: 0, lastHeight: 0, width: 0, lastWidth: 0 }; // 单元格 - const employee = staffData.firstStore.firstSector.employee_1; // 员工张伟 - let setAppointmentTime = appointmentPage.getAppointmentTimesAvailable(); // 预约时间 - - // 获取当前单元格的宽高 - const $time = page.locator('.times_table td', { hasText: setAppointmentTime }); - const $employee = page.locator('.room_table .tr .name_th', { hasText: employee.name }).first(); - await homeNavigation.gotoModule('预约'); - await $time.scrollIntoViewIfNeeded(); - await $employee.scrollIntoViewIfNeeded(); - let timeBox = await $time.boundingBox(); - let employeeBox = await $employee.boundingBox(); - cellBox.lastHeight = timeBox != null ? timeBox.height : 0; - cellBox.lastWidth = employeeBox != null ? employeeBox.width : 0; - - await page.locator('.herder_right').getByRole('button').nth(1).click(); - await page.getByRole('menuitem', { name: '视图调整' }).click(); - // 打开了自定义的宽高 - await expect(page.locator('.set_w_h_box .set_w_h_title', { hasText: '自定义预约表格宽高' })).toBeVisible(); - - const setHeightLocator = page.locator('.set_w_h_content', { hasText: '高度' }).getByRole('slider'); - const setWidthLocator = page.locator('.set_w_h_content', { hasText: '宽度' }).getByRole('slider'); - - // 获取可以移动最大和最小的宽度和高度 - const heightValueMax = Number(await setHeightLocator.getAttribute('aria-valuemax')); - const heightValueMin = Number(await setHeightLocator.getAttribute('aria-valuemin')); - const widthValueMax = Number(await setWidthLocator.getAttribute('aria-valuemax')); - const widthValueMin = Number(await setWidthLocator.getAttribute('aria-valuemin')); - const heightDistance = heightValueMax - heightValueMin; - const widthDistance = widthValueMax - widthValueMin; - - const setHeightBox = await setHeightLocator.boundingBox(); - const setWidthBox = await setWidthLocator.boundingBox(); - if (setHeightBox == null || setWidthBox == null) { - throw new Error('获取设置高度和宽度的定位器失败'); - } - - await test.step('设置高度', async () => { - await $time.scrollIntoViewIfNeeded(); - // 设置单元格高度 - await page.mouse.move(setHeightBox.x + setHeightBox.width / 2, setHeightBox.y + setHeightBox.height / 2); - await page.mouse.down(); - await page.mouse.move( - setHeightBox.x + setHeightBox.width / 2 + heightDistance, - setHeightBox.y + setHeightBox.height / 2, - ); - await page.mouse.down(); - - timeBox = await $time.boundingBox(); - cellBox.height = timeBox != null ? timeBox.height : 0; - expect(cellBox.height - cellBox.lastHeight).toEqual(heightDistance); - }); - - await test.step('设置宽度', async () => { - // 设置单元格宽度 - await page.mouse.move(setWidthBox.x + setWidthBox.width / 2, setWidthBox.y + setWidthBox.height / 2); - await page.mouse.move(setWidthBox.x, setWidthBox.y); - await page.mouse.down(); - await page.mouse.move( - setWidthBox.x + setWidthBox.width / 2 + widthDistance, - setWidthBox.y + setWidthBox.height / 2, - ); - await page.mouse.down(); - - await $employee.scrollIntoViewIfNeeded(); - employeeBox = await $employee.boundingBox(); - cellBox.width = employeeBox?.width ?? 0; - expect(cellBox.width - cellBox.lastWidth).toEqual(widthDistance); - }); - - // 恢复默认视图设置 - await page.locator('.resetting').click(); - }); -}); - test.afterEach(async ({ homeNavigation, wasteBookBusinessRecordPage, billSet }) => { // 撤回预约开的单 await homeNavigation.gotoModule('流水');