1500 lines
72 KiB
TypeScript
1500 lines
72 KiB
TypeScript
// @ts-check
|
||
import { expect, test } from '@/fixtures/boss_common.js';
|
||
import { staffData } from '@/fixtures/staff.js';
|
||
import { Employees } from '@/fixtures/userconfig.js';
|
||
import { Customer } from '@/utils/customer';
|
||
import { KeepOnlyNumbers } from '@/utils/utils.js';
|
||
|
||
test.describe('目标设置', () => {
|
||
test('总部设置', async ({ page, homeNavigation, numberInput }) => {
|
||
const goal = 100; //目标金额
|
||
const employeeA = Employees.FirstShop.Employee_3.name;
|
||
|
||
await homeNavigation.gotoModule('目标');
|
||
await page.getByRole('button', { name: '设置目标' }).click();
|
||
await page.locator('.popupComTableStyle .m-table__fixed-left tbody tr td:first-child').first().waitFor();
|
||
// 员工A内行数
|
||
const allTrA = page.locator('.popupComTableStyle .m-table__fixed-left tbody tr td:first-child');
|
||
const nowRowA = await allTrA
|
||
.allInnerTexts()
|
||
.then(text => {
|
||
return text.findIndex(item => item.includes(employeeA));
|
||
})
|
||
.then(Number);
|
||
if (nowRowA === -1) {
|
||
throw new Error('员工A不存在');
|
||
}
|
||
|
||
await page
|
||
.locator('.popupComTableStyle .m-table__body .main-table-body_tr')
|
||
.nth(nowRowA)
|
||
.locator('.m-table-cell')
|
||
.nth(1)
|
||
.click();
|
||
await numberInput.delAllValue();
|
||
await numberInput.setValue(goal);
|
||
await numberInput.confirmValue();
|
||
await page.getByRole('button', { name: /保\s存/ }).click();
|
||
await page.locator('.ant-message', { hasText: '设置成功' }).waitFor();
|
||
// 等待加载完成
|
||
await expect(page.locator('.m-table__icon__warp')).toBeHidden();
|
||
|
||
// 员工A行数
|
||
const allTrB = page.locator('.tableStyle .m-table__fixed-left tbody tr');
|
||
const nowRowB = await allTrB
|
||
.allInnerTexts()
|
||
.then(text => {
|
||
return text.findIndex(item => item.includes(employeeA));
|
||
})
|
||
.then(Number);
|
||
|
||
const verify = page
|
||
.locator('.tableStyle .m-table__body-wrapper tbody tr')
|
||
.nth(nowRowB)
|
||
.locator('.is-right .targetValue')
|
||
.nth(0);
|
||
// 对比输入的目标
|
||
await expect(verify).toContainText(`${goal}`);
|
||
|
||
// 清理
|
||
await page.getByRole('button', { name: '设置目标' }).click();
|
||
|
||
await page
|
||
.locator('.popupComTableStyle .m-table__body .main-table-body_tr')
|
||
.nth(nowRowA)
|
||
.locator('.m-table-cell')
|
||
.nth(1)
|
||
.click();
|
||
await numberInput.delAllValue();
|
||
await numberInput.confirmValue();
|
||
await page.getByRole('button', { name: /保\s存/ }).click();
|
||
});
|
||
});
|
||
|
||
test.describe('个人看板', () => {
|
||
test('查看个人看板', async ({ page, createCustomer, homeNavigation }) => {
|
||
// 今日消费之前和之后的现金和消耗
|
||
let lastCash;
|
||
let lastExpend;
|
||
// 上月和本月的现金和消耗
|
||
let lastMonthCash;
|
||
let lastMonthExpend;
|
||
|
||
// 定义会员
|
||
const leftPaymentInfoItem = page.locator('.left .paymentmain .paymentInfoItem');
|
||
// 定位器
|
||
const verify = page.locator('.m-table__header-wrapper .date_box');
|
||
|
||
const customer = createCustomer;
|
||
|
||
await test.step('进入目标界面获取初始数据', async () => {
|
||
// 进入目标界面获取初始数据
|
||
await homeNavigation.gotoModule('目标');
|
||
await page.locator('.m-table__fixed-left .employeeName', { hasText: '张伟' }).click();
|
||
await page.locator('.m-table__body-wrapper').last().waitFor();
|
||
await expect(page.locator('.m-table__icon__warp')).toBeHidden();
|
||
|
||
lastCash = KeepOnlyNumbers(
|
||
await verify
|
||
.filter({ has: page.locator('.title', { hasText: '现金' }) })
|
||
.locator('.target_txt')
|
||
.last()
|
||
.innerText(),
|
||
);
|
||
lastExpend = KeepOnlyNumbers(
|
||
await verify
|
||
.filter({ has: page.locator('.title', { hasText: '消耗' }) })
|
||
.locator('.target_txt')
|
||
.last()
|
||
.innerText(),
|
||
);
|
||
// 点击上个月
|
||
await page.locator('.left_btn').last().click();
|
||
await expect(page.locator('.m-table__icon__warp')).toBeHidden();
|
||
|
||
lastMonthCash = KeepOnlyNumbers(
|
||
await verify
|
||
.filter({ has: page.locator('.title', { hasText: '现金' }) })
|
||
.locator('.target_txt')
|
||
.last()
|
||
.innerText(),
|
||
);
|
||
lastMonthExpend = KeepOnlyNumbers(
|
||
await verify
|
||
.filter({ has: page.locator('.title', { hasText: '消耗' }) })
|
||
.locator('.target_txt')
|
||
.last()
|
||
.innerText(),
|
||
);
|
||
// 关闭目标窗口
|
||
await page.locator('.close_icon').last().click();
|
||
});
|
||
|
||
await test.step('购买项目A并消耗(本月)', async () => {
|
||
await homeNavigation.gotoModule('收银');
|
||
await page.getByRole('button', { name: /开\s单/ }).click();
|
||
await page.getByPlaceholder('姓名(拼音首字)、手机号、档案号搜索').fill(customer.phone);
|
||
await page.locator('.ant-input-suffix', { hasText: '搜索' }).click();
|
||
await page.locator('.member_list .phone', { hasText: customer.phone }).click();
|
||
|
||
// 购买并消耗
|
||
await page.locator('.project_list .number', { hasText: '100028' }).click();
|
||
await page.locator('#shoppingCart .commodity_list li').first().click();
|
||
|
||
// 购买添加员工
|
||
await page.locator('#buyList .staff_btn').click();
|
||
await page.locator('.check_row', { hasText: '张伟' }).getByRole('checkbox').check();
|
||
await page.getByRole('button', { name: /确\s认/ }).click();
|
||
|
||
// 消耗添加员工
|
||
await page.locator('.use_list .staff_btn').click();
|
||
await page.locator('.check_row', { hasText: '张伟' }).getByRole('checkbox').check();
|
||
await page.getByRole('button', { name: /确\s认/ }).click();
|
||
|
||
await page.locator('.pay_btn', { hasText: /结\s算/ }).click();
|
||
await page.getByLabel('推送消费提醒').uncheck();
|
||
await page.getByLabel('结算签字').uncheck();
|
||
// 选择现金结算
|
||
await leftPaymentInfoItem.filter({ hasText: '现金' }).click();
|
||
await page.getByRole('button', { name: /结\s算/ }).click();
|
||
});
|
||
|
||
await test.step('购买项目A并消耗(补录上月)', async () => {
|
||
await homeNavigation.gotoModule('收银');
|
||
await page.getByRole('button', { name: /开\s单/ }).click();
|
||
await page.getByPlaceholder('姓名(拼音首字)、手机号、档案号搜索').fill(customer.phone);
|
||
await page.locator('.ant-input-suffix', { hasText: '搜索' }).click();
|
||
await page.locator('.member_list .phone', { hasText: customer.phone }).click();
|
||
|
||
// 购买并消耗
|
||
await page.locator('.project_list .number', { hasText: '100028' }).click();
|
||
await page.locator('#shoppingCart .commodity_list li').first().click();
|
||
|
||
// 购买添加员工
|
||
await page.locator('#buyList .staff_btn').click();
|
||
await page.locator('.check_row', { hasText: '张伟' }).getByRole('checkbox').check();
|
||
await page.getByRole('button', { name: /确\s认/ }).click();
|
||
|
||
// 消耗添加员工
|
||
await page.locator('.use_list .staff_btn').click();
|
||
await page.locator('.check_row', { hasText: '张伟' }).getByRole('checkbox').check();
|
||
await page.getByRole('button', { name: /确\s认/ }).click();
|
||
|
||
await page.locator('.pay_btn', { hasText: /结\s算/ }).click();
|
||
await page.getByLabel('推送消费提醒').uncheck();
|
||
await page.getByLabel('结算签字').uncheck();
|
||
|
||
// 点击补录
|
||
await page.locator('.recording_checkbox').click();
|
||
// 点击上个月
|
||
await page.locator('.ant-calendar-prev-month-btn').waitFor();
|
||
await page.locator('.ant-calendar-prev-month-btn').click();
|
||
// 选择上个月15号
|
||
await page.locator('.ant-calendar-cell', { hasText: '15' }).click();
|
||
await page.locator('.date_text .date', { hasText: '15' }).waitFor();
|
||
|
||
await leftPaymentInfoItem.filter({ hasText: '现金' }).click();
|
||
await page.getByRole('button', { name: /结\s算/ }).click();
|
||
});
|
||
|
||
await test.step('最后目标界面校验数据', async () => {
|
||
// 进入目标界面
|
||
await homeNavigation.gotoModule('目标');
|
||
await page.locator('.m-table__fixed-left .employeeName', { hasText: '张伟' }).click();
|
||
await page.locator('.m-table__body-wrapper').last().waitFor();
|
||
await expect.soft(page.locator('.m-table__icon__warp')).toBeHidden();
|
||
|
||
await expect
|
||
.soft(
|
||
verify
|
||
.filter({ has: page.locator('.title', { hasText: '现金' }) })
|
||
.locator('.target_txt')
|
||
.last(),
|
||
)
|
||
.toContainText(`${Number(lastCash) + 50}`);
|
||
|
||
await expect(
|
||
verify
|
||
.filter({ has: page.locator('.title', { hasText: '消耗' }) })
|
||
.locator('.target_txt')
|
||
.last(),
|
||
).toContainText(`${Number(lastExpend) + 60}`);
|
||
|
||
// 点击上个月
|
||
await page.locator('.left_btn').last().click();
|
||
await expect(page.locator('.m-table__icon__warp')).toBeHidden();
|
||
|
||
await expect
|
||
.soft(
|
||
verify
|
||
.filter({ has: page.locator('.title', { hasText: '现金' }) })
|
||
.locator('.target_txt')
|
||
.last(),
|
||
)
|
||
.toContainText(`${Number(lastMonthCash) + 50}`);
|
||
await expect(
|
||
verify
|
||
.filter({ has: page.locator('.title', { hasText: '消耗' }) })
|
||
.locator('.target_txt')
|
||
.last(),
|
||
).toContainText(`${Number(lastMonthExpend) + 60}`);
|
||
});
|
||
});
|
||
});
|
||
|
||
test.describe('个人日结单', () => {
|
||
test('查看个人日结单', async ({ page, createCustomer, homeNavigation }) => {
|
||
let cash;
|
||
let expend;
|
||
|
||
const leftPaymentInfoItem = page.locator('.left .paymentmain .paymentInfoItem');
|
||
|
||
const customer = createCustomer;
|
||
|
||
await test.step('购买项目A并消耗', async () => {
|
||
await homeNavigation.gotoModule('收银');
|
||
await page.getByRole('button', { name: /开\s单/ }).click();
|
||
await page.getByPlaceholder('姓名(拼音首字)、手机号、档案号搜索').fill(customer.phone);
|
||
await page.locator('.ant-input-suffix', { hasText: '搜索' }).click();
|
||
await page.locator('.member_list .phone', { hasText: customer.phone }).click();
|
||
|
||
// 购买并消耗
|
||
await page.locator('.project_list .number', { hasText: '100028' }).click();
|
||
await page.locator('#shoppingCart .commodity_list li').first().click();
|
||
|
||
// 购买添加员工
|
||
await page.locator('#buyList .staff_btn').click();
|
||
await page.locator('.check_row', { hasText: '赵军' }).getByRole('checkbox').check();
|
||
await page.getByRole('button', { name: /确\s认/ }).click();
|
||
|
||
// 消耗添加员工
|
||
await page.locator('.use_list .staff_btn').click();
|
||
await page.locator('.check_row', { hasText: '赵军' }).getByRole('checkbox').check();
|
||
await page.getByRole('button', { name: /确\s认/ }).click();
|
||
|
||
await page.locator('.pay_btn', { hasText: /结\s算/ }).click();
|
||
await page.getByLabel('推送消费提醒').uncheck();
|
||
await page.getByLabel('结算签字').uncheck();
|
||
// 选择现金结算
|
||
await leftPaymentInfoItem.filter({ hasText: '现金' }).click();
|
||
await page.getByRole('button', { name: /结\s算/ }).click();
|
||
});
|
||
|
||
await test.step('进入流水获取赵军今日现金及消耗', async () => {
|
||
await homeNavigation.gotoModule('流水');
|
||
await page.locator('.tab_item', { hasText: '日结单' }).click();
|
||
await expect(page.locator('.m-table__empty')).not.toBeVisible();
|
||
await expect(page.locator('.m-table__loading')).toBeHidden();
|
||
await expect(page.locator('.m-table__body-wrapper tbody tr').first()).toBeVisible();
|
||
// 获取员工赵军在第几列
|
||
const allTrLine = page.locator('.m-table__header-wrapper th');
|
||
const nowLine = await allTrLine.allInnerTexts().then(text => {
|
||
return text.findIndex(item => item.includes('赵军'));
|
||
});
|
||
|
||
// 获取流水里赵军的今日现金及消耗
|
||
const codes = page.locator('.m-table__body-wrapper tbody tr');
|
||
cash = KeepOnlyNumbers(
|
||
await codes
|
||
.filter({ has: page.locator('td', { hasText: '现金' }) })
|
||
.locator('td')
|
||
.nth(nowLine)
|
||
.innerText(),
|
||
);
|
||
expend = KeepOnlyNumbers(
|
||
await codes
|
||
.filter({ has: page.locator('td', { hasText: '消耗' }) })
|
||
.locator('td')
|
||
.nth(nowLine)
|
||
.innerText(),
|
||
);
|
||
});
|
||
|
||
await test.step('进入目标获取赵军今日现金及消耗', async () => {
|
||
await homeNavigation.gotoModule('目标');
|
||
// 点击赵军进入个人目标
|
||
await page.locator('.m-table__fixed-left tbody .employeeName', { hasText: '赵军' }).click();
|
||
await Promise.any([
|
||
page.locator('.no_done').first().waitFor({ timeout: 5000 }),
|
||
page.locator('.no_start').first().waitFor({ timeout: 5000 }),
|
||
]);
|
||
// 获取今日的现金以及消耗
|
||
const coded = page.locator('.m-table__body-wrapper .main-table-body_tr');
|
||
await expect(
|
||
coded
|
||
.filter({ has: page.locator('.is-center', { hasText: '今' }) })
|
||
.locator('td')
|
||
.nth(1),
|
||
).toContainText(cash);
|
||
|
||
await expect(
|
||
coded
|
||
.filter({ has: page.locator('.is-center', { hasText: '今' }) })
|
||
.locator('td')
|
||
.nth(3),
|
||
).toContainText(expend);
|
||
});
|
||
});
|
||
});
|
||
|
||
test.describe('门店看板', () => {
|
||
test('查看门店看板', async ({ page, createCustomers, homeNavigation }) => {
|
||
// E1 李娜
|
||
// E2 杨雪
|
||
// E3 赵伟
|
||
// F1 张凯
|
||
// 总部账号:17770720220 a123456
|
||
// 门店一 : 17770720221 a123456
|
||
// 门店二: 17770720222 a123456
|
||
// 组长李娜:139876543 a123456
|
||
let customer_a;
|
||
let customer_b;
|
||
let customer_c;
|
||
let coded;
|
||
// 各员工初始数据
|
||
let LNCash; //李娜
|
||
let LastLNCash; //李娜上月
|
||
let YXCash; //杨雪
|
||
let ZWCash; //赵伟
|
||
let ZKCash; //张凯
|
||
|
||
// 收银结算button
|
||
const leftPaymentInfoItem = page.locator('.left .paymentmain .paymentInfoItem');
|
||
|
||
let customers: Customer[] = [];
|
||
await test.step('创建3个顾客', async () => {
|
||
customers = await createCustomers(3);
|
||
});
|
||
customer_a = customers[0];
|
||
customer_b = customers[1];
|
||
customer_c = customers[2];
|
||
|
||
await test.step('总部账号获取各门店各部门各员工数据', async () => {
|
||
// 进入目标界面获取初始数据
|
||
await homeNavigation.gotoModule('目标');
|
||
// 点击李娜进入个人目标
|
||
await page.locator('.m-table__fixed-left tbody .employeeName', { hasText: '李娜' }).click();
|
||
await Promise.any([
|
||
page.locator('.no_done').first().waitFor({ timeout: 5000 }),
|
||
page.locator('.no_start').first().waitFor({ timeout: 5000 }),
|
||
]);
|
||
// 获取今日的现金以及消耗
|
||
coded = page.locator('.m-table__body-wrapper .main-table-body_tr');
|
||
LNCash = await coded
|
||
.filter({ has: page.locator('.is-center', { hasText: '今' }) })
|
||
.locator('td')
|
||
.nth(1)
|
||
.innerText();
|
||
// 关闭窗口
|
||
await page.locator('.close_icon').last().click();
|
||
// 点击上个月
|
||
await page.locator('.left_btn').last().click();
|
||
// await expect (coded.filter({has:page.locator('.is-center').last()}).locator('td .kpiType').first()).not.toBeEmpty()
|
||
await page.waitForTimeout(2000);
|
||
|
||
// 点击李娜进入个人目标
|
||
await page.locator('.m-table__fixed-left tbody .employeeName', { hasText: '李娜' }).click();
|
||
await Promise.any([
|
||
page.locator('.no_done').first().waitFor({ timeout: 5000 }),
|
||
page.locator('.no_start').first().waitFor({ timeout: 5000 }),
|
||
]);
|
||
// 获取上月的现金以及消耗
|
||
LastLNCash = await coded
|
||
.filter({ has: page.locator('.is-center', { hasText: '15' }) })
|
||
.locator('td')
|
||
.nth(1)
|
||
.innerText();
|
||
// 关闭窗口
|
||
await page.locator('.close_icon').last().click();
|
||
// 返回下个月以便校验其他员工数据
|
||
await page.locator('.right_btn').last().click();
|
||
await expect(page.locator('.m-table__loading')).toBeHidden();
|
||
|
||
// 点击杨雪进入个人目标
|
||
await page.locator('.m-table__fixed-left tbody .employeeName', { hasText: '杨雪' }).click();
|
||
await Promise.any([
|
||
page.locator('.no_done').first().waitFor({ timeout: 5000 }),
|
||
page.locator('.no_start').first().waitFor({ timeout: 5000 }),
|
||
]);
|
||
// 获取今日的现金以及消耗
|
||
YXCash = await coded
|
||
.filter({ has: page.locator('.is-center', { hasText: '今' }) })
|
||
.locator('td')
|
||
.nth(1)
|
||
.innerText();
|
||
// 关闭窗口
|
||
await page.locator('.close_icon').last().click();
|
||
|
||
// 点击选择门店
|
||
await expect(async () => {
|
||
await page.locator('.shop-picker-store').click();
|
||
await page.locator('.shopSelect_title', { hasText: '选择查询对象' }).waitFor();
|
||
// 选择部门
|
||
await page.locator('.needsclick', { hasText: '医美部' }).click();
|
||
await page.locator('.shop_btn', { hasText: /^保\s存$/ }).click();
|
||
await page
|
||
.locator('.m-table__fixed-left tbody .employeeName', { hasText: '赵伟' })
|
||
.waitFor({ timeout: 2000 });
|
||
}).toPass();
|
||
|
||
// 点击赵伟进入个人目标
|
||
await page.locator('.m-table__fixed-left tbody .employeeName', { hasText: '赵伟' }).click();
|
||
await Promise.any([
|
||
page.locator('.no_done').first().waitFor({ timeout: 5000 }),
|
||
page.locator('.no_start').first().waitFor({ timeout: 5000 }),
|
||
]);
|
||
// 获取今日的现金以及消耗
|
||
ZWCash = await coded
|
||
.filter({ has: page.locator('.is-center', { hasText: '今' }) })
|
||
.locator('td')
|
||
.nth(1)
|
||
.innerText();
|
||
// 关闭窗口
|
||
await page.locator('.close_icon').last().click();
|
||
|
||
// 点击选择门店
|
||
await expect(async () => {
|
||
await page.locator('.shop-picker-store').click();
|
||
await page.locator('.shopSelect_title', { hasText: '选择查询对象' }).waitFor();
|
||
// 选择门店
|
||
await page.locator('.shopSelect_shop_content').click();
|
||
await page.locator('.comSelect_title', { hasText: '选择' }).waitFor();
|
||
await page.locator('.customWith', { hasText: 'AT测试二店' }).click();
|
||
await page.locator('.shopSelect_shop_content', { hasText: 'AT测试二店' }).waitFor();
|
||
await page.locator('.shop_btn', { hasText: /^保\s存$/ }).click();
|
||
await page
|
||
.locator('.m-table__fixed-left tbody .employeeName', { hasText: '张凯' })
|
||
.waitFor({ timeout: 2000 });
|
||
}).toPass();
|
||
|
||
// 点击张凯进入个人目标
|
||
await page.locator('.m-table__fixed-left tbody .employeeName', { hasText: '张凯' }).click();
|
||
await Promise.any([
|
||
page.locator('.no_done').first().waitFor({ timeout: 5000 }),
|
||
page.locator('.no_start').first().waitFor({ timeout: 5000 }),
|
||
]);
|
||
// 获取今日的现金以及消耗
|
||
ZKCash = await coded
|
||
.filter({ has: page.locator('.is-center', { hasText: '今' }) })
|
||
.locator('td')
|
||
.nth(1)
|
||
.innerText();
|
||
// 关闭窗口
|
||
await page.locator('.close_icon').last().click();
|
||
|
||
// 点击选择门店
|
||
await expect(async () => {
|
||
await page.locator('.shop-picker-store').click();
|
||
await page.locator('.shopSelect_title', { hasText: '选择查询对象' }).waitFor();
|
||
// 选择门店
|
||
await page.locator('.shopSelect_shop_content').click();
|
||
await page.locator('.comSelect_title', { hasText: '选择' }).waitFor();
|
||
await page.locator('.customWith', { hasText: 'AT测试一店' }).click();
|
||
await page.locator('.shopSelect_shop_content', { hasText: 'AT测试一店' }).waitFor();
|
||
await page.locator('.shop_btn', { hasText: /^保\s存$/ }).click();
|
||
await page
|
||
.locator('.m-table__fixed-left tbody .employeeName', { hasText: '李娜' })
|
||
.waitFor({ timeout: 2000 });
|
||
}).toPass();
|
||
});
|
||
|
||
await test.step('顾客A购买项目A 补录上月', async () => {
|
||
await homeNavigation.gotoModule('收银');
|
||
await page.getByRole('button', { name: /开\s单/ }).click();
|
||
await page.getByPlaceholder('姓名(拼音首字)、手机号、档案号搜索').fill(customer_a.phone);
|
||
await page.locator('.ant-input-suffix', { hasText: '搜索' }).click();
|
||
await page.locator('.member_list .phone', { hasText: customer_a.phone }).click();
|
||
|
||
// 购买并消耗
|
||
await page.locator('.project_list .number', { hasText: '100028' }).click();
|
||
|
||
// 购买添加员工
|
||
await page.locator('#buyList .staff_btn').click();
|
||
await page.locator('.check_row', { hasText: '李娜' }).getByRole('checkbox').check();
|
||
await page.getByRole('button', { name: /确\s认/ }).click();
|
||
|
||
await page.locator('.pay_btn', { hasText: /结\s算/ }).click();
|
||
await page.getByLabel('推送消费提醒').uncheck();
|
||
await page.getByLabel('结算签字').uncheck();
|
||
|
||
// 点击补录
|
||
await page.locator('.recording_checkbox').click();
|
||
// 点击上个月
|
||
await page.locator('.ant-calendar-prev-month-btn').waitFor();
|
||
await page.locator('.ant-calendar-prev-month-btn').click();
|
||
// 选择上个月15号
|
||
await page.locator('.ant-calendar-cell', { hasText: '15' }).click();
|
||
await page.locator('.date_text .date', { hasText: '15' }).waitFor();
|
||
|
||
await leftPaymentInfoItem.filter({ hasText: '现金' }).click();
|
||
await page.getByRole('button', { name: /结\s算/ }).click();
|
||
});
|
||
|
||
await test.step('顾客B购买项目A 选顾问', async () => {
|
||
await homeNavigation.gotoModule('收银');
|
||
await page.getByRole('button', { name: /开\s单/ }).click();
|
||
await page.getByPlaceholder('姓名(拼音首字)、手机号、档案号搜索').fill(customer_b.phone);
|
||
await page.locator('.ant-input-suffix', { hasText: '搜索' }).click();
|
||
await page.locator('.member_list .phone', { hasText: customer_b.phone }).click();
|
||
|
||
// 购买并消耗
|
||
await page.locator('.project_list .number', { hasText: '100028' }).click();
|
||
|
||
// 购买添加员工
|
||
await page.locator('#buyList .staff_btn').click();
|
||
await page.locator('.check_row', { hasText: '李娜' }).getByRole('checkbox').check();
|
||
await page.getByRole('button', { name: /确\s认/ }).click();
|
||
|
||
await page.locator('.pay_btn', { hasText: /结\s算/ }).click();
|
||
await page.getByLabel('推送消费提醒').uncheck();
|
||
await page.getByLabel('结算签字').uncheck();
|
||
|
||
await leftPaymentInfoItem.filter({ hasText: '现金' }).click();
|
||
await page.getByRole('button', { name: /结\s算/ }).click();
|
||
});
|
||
|
||
await test.step('顾客B购买项目A 选美容师', async () => {
|
||
await page.getByRole('button', { name: /开\s单/ }).click();
|
||
await page.getByPlaceholder('姓名(拼音首字)、手机号、档案号搜索').fill(customer_b.phone);
|
||
await page.locator('.ant-input-suffix', { hasText: '搜索' }).click();
|
||
await page.locator('.member_list .phone', { hasText: customer_b.phone }).click();
|
||
|
||
// 购买并消耗
|
||
await page.locator('.project_list .number', { hasText: '100028' }).click();
|
||
|
||
// 购买添加员工
|
||
await page.locator('#buyList .staff_btn').click();
|
||
await page.locator('.check_row', { hasText: '杨雪' }).getByRole('checkbox').check();
|
||
await page.getByRole('button', { name: /确\s认/ }).click();
|
||
|
||
await page.locator('.pay_btn', { hasText: /结\s算/ }).click();
|
||
await page.getByLabel('推送消费提醒').uncheck();
|
||
await page.getByLabel('结算签字').uncheck();
|
||
|
||
await leftPaymentInfoItem.filter({ hasText: '现金' }).click();
|
||
await page.getByRole('button', { name: /结\s算/ }).click();
|
||
});
|
||
|
||
await test.step('顾客B购买项目B 选医美部', async () => {
|
||
await page.getByRole('button', { name: /开\s单/ }).click();
|
||
await page.getByPlaceholder('姓名(拼音首字)、手机号、档案号搜索').fill(customer_b.phone);
|
||
await page.locator('.ant-input-suffix', { hasText: '搜索' }).click();
|
||
await page.locator('.member_list .phone', { hasText: customer_b.phone }).click();
|
||
|
||
// 购买并消耗
|
||
await page.locator('.project_list .number', { hasText: '100029' }).click();
|
||
|
||
// 购买添加员工
|
||
await page.locator('#buyList .staff_btn').click();
|
||
await page.locator('.ant-radio-button-wrapper', { hasText: '医美部' }).click();
|
||
await page.locator('.check_row', { hasText: '赵伟' }).getByRole('checkbox').check();
|
||
await page.getByRole('button', { name: /确\s认/ }).click();
|
||
|
||
await page.locator('.pay_btn', { hasText: /结\s算/ }).click();
|
||
await page.getByLabel('推送消费提醒').uncheck();
|
||
await page.getByLabel('结算签字').uncheck();
|
||
|
||
await leftPaymentInfoItem.filter({ hasText: '现金' }).click();
|
||
await page.getByRole('button', { name: /结\s算/ }).click();
|
||
});
|
||
|
||
await test.step('二店顾客C购买项目A,选二店员工', async () => {
|
||
// 点击选择门店
|
||
await page.locator('.shop_select').click();
|
||
await page.locator('.comSelect_title', { hasText: '选择' }).waitFor();
|
||
// 选择二店
|
||
await page.locator('.check_box_container', { hasText: 'AT测试二店' }).click();
|
||
|
||
await page.getByRole('button', { name: /开\s单/ }).click();
|
||
await page.getByPlaceholder('姓名(拼音首字)、手机号、档案号搜索').fill(customer_c.phone);
|
||
await page.locator('.ant-input-suffix', { hasText: '搜索' }).click();
|
||
await page.locator('.member_list .phone', { hasText: customer_c.phone }).click();
|
||
|
||
// 购买并消耗
|
||
await page.locator('.project_list .number', { hasText: '100028' }).click();
|
||
|
||
// 购买添加员工
|
||
await page.locator('#buyList .staff_btn').click();
|
||
await page.locator('.check_row', { hasText: '张凯' }).getByRole('checkbox').check();
|
||
await page.getByRole('button', { name: /确\s认/ }).click();
|
||
|
||
await page.locator('.pay_btn', { hasText: /结\s算/ }).click();
|
||
await page.getByLabel('推送消费提醒').uncheck();
|
||
await page.getByLabel('结算签字').uncheck();
|
||
|
||
await leftPaymentInfoItem.filter({ hasText: '现金' }).click();
|
||
await page.getByRole('button', { name: /结\s算/ }).click();
|
||
});
|
||
|
||
await test.step('总部账号验证各门店各部门各员工数据', async () => {
|
||
// 进入目标界面核对数据
|
||
await homeNavigation.gotoModule('目标');
|
||
// 点击选择门店
|
||
await expect(async () => {
|
||
await page.locator('.shop-picker-store').click();
|
||
await page.locator('.shopSelect_title', { hasText: '选择查询对象' }).waitFor();
|
||
// 选择门店
|
||
await page.locator('.shopSelect_shop_content').click();
|
||
await page.locator('.comSelect_title', { hasText: '选择' }).waitFor();
|
||
await page.locator('.customWith', { hasText: 'AT测试一店' }).click();
|
||
await page.locator('.shopSelect_shop_content', { hasText: 'AT测试一店' }).waitFor();
|
||
await page.locator('.shop_btn', { hasText: /^保\s存$/ }).click();
|
||
await page
|
||
.locator('.m-table__fixed-left tbody .employeeName', { hasText: '李娜' })
|
||
.waitFor({ timeout: 2000 });
|
||
}).toPass();
|
||
|
||
// 点击李娜进入个人目标
|
||
await page.locator('.m-table__fixed-left tbody .employeeName', { hasText: '李娜' }).click();
|
||
await Promise.any([
|
||
page.locator('.no_done').first().waitFor({ timeout: 5000 }),
|
||
page.locator('.no_start').first().waitFor({ timeout: 5000 }),
|
||
]);
|
||
// 获取今日的现金以及消耗
|
||
|
||
const LNCashed = await coded
|
||
.filter({ has: page.locator('.is-center', { hasText: '今' }) })
|
||
.locator('td')
|
||
.nth(1)
|
||
.innerText();
|
||
// 关闭窗口
|
||
await page.locator('.close_icon').last().click();
|
||
|
||
// 点击杨雪进入个人目标
|
||
await page.locator('.m-table__fixed-left tbody .employeeName', { hasText: '杨雪' }).click();
|
||
await Promise.any([
|
||
page.locator('.no_done').first().waitFor({ timeout: 5000 }),
|
||
page.locator('.no_start').first().waitFor({ timeout: 5000 }),
|
||
]);
|
||
// 获取今日的现金以及消耗
|
||
const YXCashed = await coded
|
||
.filter({ has: page.locator('.is-center', { hasText: '今' }) })
|
||
.locator('td')
|
||
.nth(1)
|
||
.innerText();
|
||
// 关闭窗口
|
||
await page.locator('.close_icon').last().click();
|
||
|
||
// 点击选择门店
|
||
await expect(async () => {
|
||
await page.locator('.shop-picker-store').click();
|
||
await page.locator('.shopSelect_title', { hasText: '选择查询对象' }).waitFor();
|
||
// 选择部门
|
||
await page.locator('.needsclick', { hasText: '医美部' }).click();
|
||
await page.locator('.shop_btn', { hasText: /^保\s存$/ }).click();
|
||
await page
|
||
.locator('.m-table__fixed-left tbody .employeeName', { hasText: '赵伟' })
|
||
.waitFor({ timeout: 2000 });
|
||
}).toPass();
|
||
|
||
// 点击赵伟进入个人目标
|
||
await page.locator('.m-table__fixed-left tbody .employeeName', { hasText: '赵伟' }).click();
|
||
await Promise.any([
|
||
page.locator('.no_done').first().waitFor({ timeout: 5000 }),
|
||
page.locator('.no_start').first().waitFor({ timeout: 5000 }),
|
||
]);
|
||
// 获取今日的现金以及消耗
|
||
const ZWCashed = await coded
|
||
.filter({ has: page.locator('.is-center', { hasText: '今' }) })
|
||
.locator('td')
|
||
.nth(1)
|
||
.innerText();
|
||
// 关闭窗口
|
||
await page.locator('.close_icon').last().click();
|
||
|
||
// 点击选择门店
|
||
await expect(async () => {
|
||
await page.locator('.shop-picker-store').click();
|
||
await page.locator('.shopSelect_title', { hasText: '选择查询对象' }).waitFor();
|
||
// 选择门店
|
||
await page.locator('.shopSelect_shop_content').click();
|
||
await page.locator('.comSelect_title', { hasText: '选择' }).waitFor();
|
||
await page.locator('.customWith', { hasText: 'AT测试二店' }).click();
|
||
await page.locator('.shopSelect_shop_content', { hasText: 'AT测试二店' }).waitFor();
|
||
await page.locator('.shop_btn', { hasText: /^保\s存$/ }).click();
|
||
await page
|
||
.locator('.m-table__fixed-left tbody .employeeName', { hasText: '张凯' })
|
||
.waitFor({ timeout: 2000 });
|
||
}).toPass();
|
||
|
||
// 点击张凯进入个人目标
|
||
await page.locator('.m-table__fixed-left tbody .employeeName', { hasText: '张凯' }).click();
|
||
await Promise.any([
|
||
page.locator('.no_done').first().waitFor({ timeout: 5000 }),
|
||
page.locator('.no_start').first().waitFor({ timeout: 5000 }),
|
||
]);
|
||
// 获取今日的现金以及消耗
|
||
const ZKCashed = await coded
|
||
.filter({ has: page.locator('.is-center', { hasText: '今' }) })
|
||
.locator('td')
|
||
.nth(1)
|
||
.innerText();
|
||
// 关闭窗口
|
||
await page.locator('.close_icon').last().click();
|
||
// 点击选择门店
|
||
await expect(async () => {
|
||
await page.locator('.shop-picker-store').click();
|
||
await page.locator('.shopSelect_title', { hasText: '选择查询对象' }).waitFor();
|
||
// 选择门店
|
||
await page.locator('.shopSelect_shop_content').click();
|
||
await page.locator('.comSelect_title', { hasText: '选择' }).waitFor();
|
||
await page.locator('.customWith', { hasText: 'AT测试一店' }).click();
|
||
await page.locator('.shopSelect_shop_content', { hasText: 'AT测试一店' }).waitFor();
|
||
await page.locator('.shop_btn', { hasText: /^保\s存$/ }).click();
|
||
await page
|
||
.locator('.m-table__fixed-left tbody .employeeName', { hasText: '李娜' })
|
||
.waitFor({ timeout: 2000 });
|
||
}).toPass();
|
||
|
||
// 校验对比
|
||
expect(LNCashed * 1).toBe(LNCash * 1 + 50);
|
||
expect(YXCashed * 1).toBe(YXCash * 1 + 50);
|
||
expect(ZWCashed * 1).toBe(ZWCash * 1 + 100);
|
||
expect(ZKCashed * 1).toBe(ZKCash * 1 + 50);
|
||
});
|
||
});
|
||
|
||
test('展示KPI配置', async ({ page, homeNavigation }) => {
|
||
const goal = page.locator('.ant-checkbox-group .ant-col .ant-checkbox-wrapper');
|
||
const check = goal
|
||
.filter({ has: page.locator('.needsclick', { hasText: '划卡' }) })
|
||
.locator('.ant-checkbox-checked');
|
||
const title = page.locator('.m-table__header-wrapper thead th', { hasText: '划卡' });
|
||
|
||
await test.step('进入设置确认划卡处于勾选状态', async () => {
|
||
// 进入设置
|
||
await homeNavigation.gotoModule('设置');
|
||
await page.locator('.tab_item', { hasText: '目标' }).click();
|
||
await page.locator('.tag_content_title', { hasText: '目标维度' }).waitFor();
|
||
await expect(async () => {
|
||
await goal
|
||
.filter({ has: page.locator('.needsclick', { hasText: '划卡' }) })
|
||
.locator('.ant-checkbox')
|
||
.click();
|
||
await expect(check).toBeVisible({ timeout: 2000 });
|
||
}).toPass();
|
||
});
|
||
|
||
await test.step('进入目标查看划卡列', async () => {
|
||
// 进入目标
|
||
await homeNavigation.gotoModule('目标');
|
||
await page.locator('.summary').first().waitFor();
|
||
// 判断划卡存在
|
||
await expect(title).toBeVisible();
|
||
});
|
||
|
||
await test.step('进入设置关闭划卡', async () => {
|
||
// 进入设置
|
||
await homeNavigation.gotoModule('设置');
|
||
await page.locator('.tab_item', { hasText: '目标' }).click();
|
||
await page.locator('.tag_content_title', { hasText: '目标维度' }).waitFor();
|
||
await goal
|
||
.filter({ has: page.locator('.needsclick', { hasText: '划卡' }) })
|
||
.locator('.ant-checkbox')
|
||
.click();
|
||
await expect(check).not.toBeVisible();
|
||
});
|
||
|
||
await test.step('判断目标不存在划卡', async () => {
|
||
// 进入目标
|
||
await homeNavigation.gotoModule('目标');
|
||
await page.locator('.summary').first().waitFor();
|
||
await expect(title).not.toBeVisible();
|
||
});
|
||
|
||
await test.step('重复以上操作恢复设置', async () => {
|
||
// 进入设置
|
||
await homeNavigation.gotoModule('设置');
|
||
await page.locator('.tab_item', { hasText: '目标' }).click();
|
||
await page.locator('.tag_content_title', { hasText: '目标维度' }).waitFor();
|
||
await goal
|
||
.filter({ has: page.locator('.needsclick', { hasText: '划卡' }) })
|
||
.locator('.ant-checkbox')
|
||
.click();
|
||
await expect(check).toBeVisible();
|
||
|
||
// 进入目标
|
||
await homeNavigation.gotoModule('目标');
|
||
await page.locator('.summary').first().waitFor();
|
||
await expect(title).toBeVisible();
|
||
});
|
||
});
|
||
});
|
||
|
||
test.describe('指标看板', () => {
|
||
test('查看指标看板', async ({ page, createCustomer, homeNavigation }) => {
|
||
// 定义初始获取的数据
|
||
let cash;
|
||
let expend;
|
||
let LastMonthCash;
|
||
let LastMonthExpend;
|
||
const leftPaymentInfoItem = page.locator('.left .paymentmain .paymentInfoItem');
|
||
// 获取员工定位器
|
||
const $$employeeHeader = page.locator('.kpiManagement .m-table__header-wrapper tr th');
|
||
const $$valueBody = page.locator('.kpiManagement .m-table__body-wrapper').last().locator('tbody').first();
|
||
|
||
const customer = createCustomer;
|
||
|
||
/**@type {number} 员工所在列 */
|
||
let nowColumn;
|
||
// 今天在第几行
|
||
let todayLine = (new Date().getDate() - 1) * 3;
|
||
// 15号在第几行
|
||
let fifteenLine = (15 - 1) * 3;
|
||
|
||
await test.step('进入目标界面获取初始数据', async () => {
|
||
// 进入目标界面获取初始数据
|
||
await homeNavigation.gotoModule('目标');
|
||
|
||
// 进入现金KPI
|
||
await page.locator('.kpiTh', { hasText: '现金' }).click();
|
||
await page.locator('.stripe_odd').first().waitFor();
|
||
// 获取员工所在列
|
||
nowColumn = await $$employeeHeader.allInnerTexts().then(text => {
|
||
return text.findIndex(item => item === '王芳');
|
||
});
|
||
|
||
if (nowColumn === -1) {
|
||
throw new Error('员工王芳不存在');
|
||
}
|
||
|
||
// 获取初始现金
|
||
cash = await $$valueBody.locator('tr').nth(todayLine).locator('td').nth(nowColumn).innerText();
|
||
|
||
// 点击上个月,获取包含 '15' 的行索引
|
||
await Promise.all([
|
||
page.locator('.left_btn').last().click(),
|
||
page.waitForResponse(res => res.url().includes('/user_kpi') && res.status() === 200),
|
||
]);
|
||
|
||
// 等待上个月最后一天的日差额加载出来
|
||
await page
|
||
.locator('.m-table__body-wrapper')
|
||
.last()
|
||
.locator('tbody')
|
||
.first()
|
||
.locator('tr')
|
||
.last()
|
||
.locator('.kpiType', { hasText: '日差额' })
|
||
.waitFor();
|
||
|
||
// 获取上个月初始现金
|
||
LastMonthCash = await $$valueBody.locator('tr').nth(fifteenLine).locator('td').nth(nowColumn).innerText();
|
||
// 关闭现金窗口
|
||
await page.locator('.close').last().click();
|
||
|
||
// 进入消耗KPI,获取初始消耗
|
||
await page.locator('.kpiTh', { hasText: '消耗' }).click();
|
||
await page.locator('.stripe_odd').first().waitFor();
|
||
expend = await $$valueBody.locator('tr').nth(todayLine).locator('td').nth(nowColumn).innerText();
|
||
|
||
// 点击上个月,获取上个月初始消耗
|
||
await Promise.all([
|
||
page.locator('.left_btn').last().click(),
|
||
page.waitForResponse(res => res.url().includes('/user_kpi') && res.status() === 200),
|
||
]);
|
||
|
||
// 等待上个月最后一天的日差额加载出来
|
||
await page
|
||
.locator('.m-table__body-wrapper')
|
||
.last()
|
||
.locator('tbody')
|
||
.first()
|
||
.locator('tr')
|
||
.last()
|
||
.locator('.kpiType', { hasText: '日差额' })
|
||
.waitFor();
|
||
|
||
// 关闭消耗窗口
|
||
await page.locator('.close').last().click();
|
||
});
|
||
|
||
await test.step('购买项目A并消耗(补录上月)', async () => {
|
||
await homeNavigation.gotoModule('收银');
|
||
await page.getByRole('button', { name: /开\s单/ }).click();
|
||
await page.getByPlaceholder('姓名(拼音首字)、手机号、档案号搜索').fill(customer.phone);
|
||
await page.locator('.ant-input-suffix', { hasText: '搜索' }).click();
|
||
await page.locator('.member_list .phone', { hasText: customer.phone }).click();
|
||
|
||
// 购买并消耗
|
||
await page.locator('.project_list .number', { hasText: '100028' }).click();
|
||
await page.locator('#shoppingCart .commodity_list li').first().click();
|
||
|
||
// 购买添加员工
|
||
await page.locator('#buyList .staff_btn').click();
|
||
await page.locator('.check_row', { hasText: '王芳' }).getByRole('checkbox').check();
|
||
await page.getByRole('button', { name: /确\s认/ }).click();
|
||
|
||
// 消耗添加员工
|
||
await page.locator('.use_list .staff_btn').click();
|
||
await page.locator('.check_row', { hasText: '王芳' }).getByRole('checkbox').check();
|
||
await page.getByRole('button', { name: /确\s认/ }).click();
|
||
|
||
await page.locator('.pay_btn', { hasText: /结\s算/ }).click();
|
||
await page.getByLabel('推送消费提醒').uncheck();
|
||
await page.getByLabel('结算签字').uncheck();
|
||
// 点击补录
|
||
await page.locator('.recording_checkbox').click();
|
||
// 点击上个月
|
||
await page.locator('.ant-calendar-prev-month-btn').waitFor();
|
||
await page.locator('.ant-calendar-prev-month-btn').click();
|
||
// 选择上个月15号
|
||
await page.locator('.ant-calendar-cell', { hasText: '15' }).click();
|
||
await page.locator('.date_text .date', { hasText: '15' }).waitFor();
|
||
await leftPaymentInfoItem.filter({ hasText: '现金' }).click();
|
||
await page.getByRole('button', { name: /结\s算/ }).click();
|
||
});
|
||
|
||
await test.step('购买项目A并消耗(本月)', async () => {
|
||
await homeNavigation.gotoModule('收银');
|
||
await page.getByRole('button', { name: /开\s单/ }).click();
|
||
await page.getByPlaceholder('姓名(拼音首字)、手机号、档案号搜索').fill(customer.phone);
|
||
await page.locator('.ant-input-suffix', { hasText: '搜索' }).click();
|
||
await page.locator('.member_list .phone', { hasText: customer.phone }).click();
|
||
|
||
// 购买并消耗
|
||
await page.locator('.project_list .number', { hasText: '100028' }).click();
|
||
await page.locator('#shoppingCart .commodity_list li').first().click();
|
||
|
||
// 购买添加员工
|
||
await page.locator('#buyList .staff_btn').click();
|
||
await page.locator('.check_row', { hasText: '王芳' }).getByRole('checkbox').check();
|
||
await page.getByRole('button', { name: /确\s认/ }).click();
|
||
|
||
// 消耗添加员工
|
||
await page.locator('.use_list .staff_btn').click();
|
||
await page.locator('.check_row', { hasText: '王芳' }).getByRole('checkbox').check();
|
||
await page.getByRole('button', { name: /确\s认/ }).click();
|
||
|
||
await page.locator('.pay_btn', { hasText: /结\s算/ }).click();
|
||
await page.getByLabel('推送消费提醒').uncheck();
|
||
await page.getByLabel('结算签字').uncheck();
|
||
// 选择现金结算
|
||
await leftPaymentInfoItem.filter({ hasText: '现金' }).click();
|
||
await page.getByRole('button', { name: /结\s算/ }).click();
|
||
});
|
||
|
||
await test.step('最后目标界面校验数据', async () => {
|
||
// 进入目标界面
|
||
await homeNavigation.gotoModule('目标');
|
||
// 进入现金KPI
|
||
await page.locator('.kpiTh', { hasText: '现金' }).click();
|
||
await page.locator('.stripe_odd').first().waitFor();
|
||
|
||
// 获取王芳今天的现金值
|
||
const nowCash = $$valueBody.locator('tr').nth(todayLine).locator('td').nth(nowColumn);
|
||
await expect(nowCash).toContainText(`${Number(cash) + 50}`);
|
||
|
||
// 点击上个月
|
||
await Promise.all([
|
||
page.locator('.left_btn').last().click(),
|
||
page.waitForResponse(res => res.url().includes('/user_kpi') && res.status() === 200),
|
||
]);
|
||
// 等待上个月最后一天的日差额加载出来
|
||
await page
|
||
.locator('.m-table__body-wrapper')
|
||
.last()
|
||
.locator('tbody')
|
||
.first()
|
||
.locator('tr')
|
||
.last()
|
||
.locator('.kpiType', { hasText: '日差额' })
|
||
.waitFor();
|
||
|
||
// 获取上个月现金
|
||
const nowLastMonthCash = $$valueBody.locator('tr').nth(fifteenLine).locator('td').nth(nowColumn);
|
||
await expect(nowLastMonthCash).toContainText(`${Number(LastMonthCash) + 50}`);
|
||
// 关闭现金窗口
|
||
await page.locator('.close').last().click();
|
||
|
||
// 进入消耗KPI
|
||
await page.locator('.kpiTh', { hasText: '消耗' }).click();
|
||
await page.locator('.stripe_odd').first().waitFor();
|
||
// 获取消耗值
|
||
const nowExpend = $$valueBody.locator('tr').nth(todayLine).locator('td').nth(nowColumn);
|
||
await expect(nowExpend).toContainText(`${Number(expend) + 60}`);
|
||
|
||
// 点击上个月
|
||
await Promise.all([
|
||
page.locator('.left_btn').last().click(),
|
||
page.waitForResponse(res => res.url().includes('/user_kpi') && res.status() === 200),
|
||
]);
|
||
|
||
// 等待上个月最后一天的日差额加载出来
|
||
await page
|
||
.locator('.m-table__body-wrapper')
|
||
.last()
|
||
.locator('tbody')
|
||
.first()
|
||
.locator('tr')
|
||
.last()
|
||
.locator('.kpiType', { hasText: '日差额' })
|
||
.waitFor();
|
||
|
||
// 获取上个月消耗
|
||
const nowLastMonthExpend = $$valueBody.locator('tr').nth(fifteenLine).locator('td').nth(nowColumn);
|
||
await expect(nowLastMonthExpend).toContainText(`${Number(LastMonthExpend) + 60}`);
|
||
});
|
||
});
|
||
});
|
||
|
||
test.describe('精细目标', () => {
|
||
test('设置精细化目标', async ({ page, homeNavigation, createCustomCustomer, numberInput }) => {
|
||
const project = { no: '100012', name: '雪肌晶纯护理', Price: 300 };
|
||
const employee = staffData.firstStore.firstSector.employee_8;
|
||
|
||
const customer = new Customer(1, 1, { employees: [{ level: '医生', name: employee.name }] });
|
||
|
||
let firstStoreFirstSector = staffData.firstStore.firstSector;
|
||
|
||
await test.step('新建有员工的顾客', async () => {
|
||
await createCustomCustomer(customer);
|
||
});
|
||
|
||
await test.step('给员工设置目标', async () => {
|
||
await homeNavigation.gotoModule('目标');
|
||
// 设置目标
|
||
await page.getByRole('button', { name: '设置目标' }).click();
|
||
// 选择部门
|
||
await page.getByRole('combobox').click();
|
||
await page.getByRole('option', { name: firstStoreFirstSector.name }).click();
|
||
// 弹窗定位器
|
||
const popupContent = page.locator('.popup_content .m-table__body-wrapper');
|
||
// 判断员工是否存在
|
||
await expect(popupContent).toContainText(employee.name);
|
||
// 选择指定员工的现金列
|
||
await popupContent.locator('tbody > tr', { hasText: employee.name }).locator('td').nth(1).click();
|
||
await numberInput.setValue(1);
|
||
await numberInput.confirmValue();
|
||
await page.getByRole('button', { name: /保\s存/ }).click();
|
||
});
|
||
|
||
await test.step('给顾客设置服务项目,查看设置的服务项目', async () => {
|
||
// 进入精细化管理页面
|
||
await page.locator('.left_view .tab_item', { hasText: '精细化管理' }).click();
|
||
await page.getByRole('cell', { name: '顾客' }).waitFor();
|
||
|
||
// 进入设置目标页面
|
||
await page.getByRole('button', { name: '设置目标' }).click();
|
||
await Promise.all([
|
||
await page.locator('.com_picker .label', { hasText: employee.name }).click(),
|
||
await page.waitForResponse(res => res.url().includes('/user_kpi_detail') && res.status() === 200),
|
||
]);
|
||
|
||
// 设置精细化窗口定位器
|
||
const settingPointViewLocator = page.locator('.flow_content');
|
||
// 设置顾客定位器
|
||
const settingCustomerLocator = settingPointViewLocator.locator(
|
||
'.m-table__body-wrapper .main-table-body_tr',
|
||
);
|
||
|
||
// 查询指定顾客
|
||
const userTr = settingCustomerLocator.filter({ hasText: customer.username });
|
||
await page.locator('.filter_box').getByRole('button').click();
|
||
await page.getByPlaceholder('输入顾客姓名、手机号、首字母搜索').fill(customer.phone);
|
||
await Promise.all([
|
||
page.locator('.search_btn > svg').click(),
|
||
page.waitForResponse(res => res.url().includes('/user_kpi_detail') && res.status() === 200),
|
||
]);
|
||
await expect(userTr).toBeVisible();
|
||
|
||
// 增加指定项目
|
||
await userTr.locator('td', { hasText: '增加' }).first().click();
|
||
// 项目选择器
|
||
const projectPickerLocator = page.locator('.com_picker', {
|
||
has: page.locator('.comSelect_title', { hasText: '添加项目' }),
|
||
});
|
||
await projectPickerLocator.locator('.search_box input').fill(project.no);
|
||
await projectPickerLocator.getByRole('button', { name: /搜\s索/ }).click();
|
||
await expect(async () => {
|
||
await projectPickerLocator.getByLabel(project.name).uncheck();
|
||
await projectPickerLocator.getByLabel(project.name).check();
|
||
await expect(
|
||
page.locator('.item_modal_tab .left_menu-item', { hasText: '全部' }).locator('.menu-item-dot'),
|
||
).toBeVisible({ timeout: 2000 });
|
||
}).toPass();
|
||
await page.getByRole('button', { name: '确定选择' }).click();
|
||
await numberInput.setValue(1);
|
||
await numberInput.confirmValue();
|
||
await expect(userTr).toContainText(project.name);
|
||
|
||
// 关闭设置目标页面
|
||
await page.locator('.close_btn > .icon > svg').click();
|
||
// 判断设置的项目状态
|
||
await expect(page.locator('.main-table-body_tr', { hasText: customer.username }).first()).toContainText(
|
||
project.name,
|
||
);
|
||
});
|
||
});
|
||
|
||
test('完成精细目标', async ({ page, homeNavigation, createCustomCustomer, numberInput }) => {
|
||
const project = { no: '100012', name: '雪肌晶纯护理', Price: 300 };
|
||
const employee = staffData.firstStore.firstSector.employee_8;
|
||
const firstStoreFirstSector = staffData.firstStore.firstSector;
|
||
|
||
const customer = new Customer(1, 1, { employees: [{ level: '医生', name: employee.name }] });
|
||
|
||
await test.step('新建有员工的顾客', async () => {
|
||
await createCustomCustomer(customer);
|
||
});
|
||
|
||
await test.step('给员工设置目标', async () => {
|
||
await homeNavigation.gotoModule('目标');
|
||
// 设置目标
|
||
await page.getByRole('button', { name: '设置目标' }).click();
|
||
// 选择部门
|
||
await page.getByRole('combobox').click();
|
||
await page.getByRole('option', { name: firstStoreFirstSector.name }).click();
|
||
// 弹窗定位器
|
||
const popupContent = page.locator('.popup_content .m-table__body-wrapper');
|
||
// 判断员工是否存在
|
||
await expect(popupContent).toContainText(employee.name);
|
||
// 选择指定员工的现金列
|
||
await popupContent.locator('tbody > tr', { hasText: employee.name }).locator('td').nth(1).click();
|
||
await numberInput.setValue(1);
|
||
await numberInput.confirmValue();
|
||
await page.getByRole('button', { name: /保\s存/ }).click();
|
||
});
|
||
|
||
await test.step('给顾客设置服务项目,查看设置的服务项目, 查看项目的状态', async () => {
|
||
// 进入精细化管理页面
|
||
await page.locator('.left_view .tab_item', { hasText: '精细化管理' }).click();
|
||
await page.getByRole('cell', { name: '顾客' }).waitFor();
|
||
|
||
// 进入设置目标页面
|
||
await page.getByRole('button', { name: '设置目标' }).click();
|
||
await Promise.all([
|
||
await page.locator('.com_picker .label', { hasText: employee.name }).click(),
|
||
await page.waitForResponse(res => res.url().includes('/user_kpi_detail') && res.status() === 200),
|
||
]);
|
||
|
||
// 设置精细化窗口定位器
|
||
const settingPointViewLocator = page.locator('.flow_content');
|
||
// 设置顾客定位器
|
||
const settingCustomerLocator = settingPointViewLocator.locator(
|
||
'.m-table__body-wrapper .main-table-body_tr',
|
||
);
|
||
|
||
// 查询指定顾客
|
||
const userTr = settingCustomerLocator.filter({ hasText: customer.username });
|
||
await page.locator('.filter_box').getByRole('button').click();
|
||
await page.getByPlaceholder('输入顾客姓名、手机号、首字母搜索').fill(customer.phone);
|
||
await Promise.all([
|
||
page.locator('.search_btn > svg').click(),
|
||
page.waitForResponse(res => res.url().includes('/user_kpi_detail') && res.status() === 200),
|
||
]);
|
||
await expect(userTr).toBeVisible();
|
||
|
||
// 增加指定项目
|
||
await userTr.locator('td', { hasText: '增加' }).first().click();
|
||
// 项目选择器
|
||
const projectPickerLocator = page.locator('.com_picker', {
|
||
has: page.locator('.comSelect_title', { hasText: '添加项目' }),
|
||
});
|
||
await projectPickerLocator.locator('.search_box input').fill(project.no);
|
||
await projectPickerLocator.getByRole('button', { name: /搜\s索/ }).click();
|
||
await expect(async () => {
|
||
await projectPickerLocator.getByLabel(project.name).uncheck();
|
||
await projectPickerLocator.getByLabel(project.name).check();
|
||
await expect(
|
||
page.locator('.item_modal_tab .left_menu-item', { hasText: '全部' }).locator('.menu-item-dot'),
|
||
).toBeVisible({ timeout: 2000 });
|
||
}).toPass();
|
||
await page.getByRole('button', { name: '确定选择' }).click();
|
||
await numberInput.setValue(1);
|
||
await numberInput.confirmValue();
|
||
await expect(userTr).toContainText(project.name);
|
||
|
||
// 等待设置项目后的页面
|
||
await Promise.all([
|
||
page.locator('.close_btn > .icon > svg').click(),
|
||
page.waitForResponse(res => res.url().includes('/user_kpi_detail') && res.status() === 200),
|
||
]);
|
||
});
|
||
|
||
await test.step('选择顾客去开单,购买目标项目,选择目标员工结算', async () => {
|
||
await homeNavigation.gotoModule('收银');
|
||
await page.getByRole('button', { name: /开\s单/ }).click();
|
||
await page.getByPlaceholder('姓名(拼音首字)、手机号、档案号搜索').fill(customer.phone);
|
||
await page.locator('.ant-input-suffix', { hasText: '搜索' }).click();
|
||
await page.locator('.member_list .phone', { hasText: customer.phone }).click();
|
||
|
||
// 选择项目
|
||
await page.locator('.project_list .number', { hasText: project.no }).click();
|
||
|
||
// 选择添加员工
|
||
await page.locator('button.staff_btn').click();
|
||
await page.locator('.check_row', { hasText: employee.name }).getByRole('checkbox').check();
|
||
await page.getByRole('button', { name: /确\s认/ }).click();
|
||
await page.locator('.pay_btn', { hasText: /^结\s算$/ }).click();
|
||
await page.getByLabel('推送消费提醒').uncheck();
|
||
await page.getByLabel('结算签字').uncheck();
|
||
|
||
const leftPaymentInfoItem = page.locator('.left .paymentmain .paymentInfoItem');
|
||
await leftPaymentInfoItem.filter({ hasText: '现金' }).click();
|
||
await page.getByRole('button', { name: /结\s算/ }).click();
|
||
});
|
||
|
||
await test.step('进入目标页面,查看目标项目状态', async () => {
|
||
await homeNavigation.gotoModule('目标');
|
||
|
||
await page.locator('.left_view .tab_item', { hasText: '精细化管理' }).click();
|
||
|
||
await page.waitForLoadState('domcontentloaded');
|
||
|
||
const customerTr = page
|
||
.locator('#app tr')
|
||
.filter({ has: page.locator('td', { hasText: customer.username }) });
|
||
|
||
// 打开现金列tip
|
||
await customerTr.locator('.service_box .item_li use').first().click();
|
||
// 判断提示窗口内容
|
||
await expect(page.getByRole('tooltip')).toContainText('已经完成');
|
||
});
|
||
});
|
||
|
||
test('完成惊喜业绩', async ({ page, homeNavigation, createCustomers, numberInput }) => {
|
||
const project = { no: '100012', name: '雪肌晶纯护理', Price: 300 };
|
||
const employee = staffData.firstStore.firstSector.employee_8;
|
||
|
||
let firstStoreFirstSector = staffData.firstStore.firstSector;
|
||
let firstStoreSecondSector = staffData.firstStore.secondSector;
|
||
|
||
let customers: Customer[] = [];
|
||
await test.step('创建两个顾客', async () => {
|
||
customers = await createCustomers(2);
|
||
});
|
||
const customerA = customers[0];
|
||
const customerB = customers[1];
|
||
|
||
await test.step('给顾客分配员工', async () => {
|
||
await homeNavigation.gotoModule('顾客');
|
||
|
||
// 根据手机号进行搜索,进入顾客详情页面
|
||
await page.getByPlaceholder('姓名(拼音首字)、手机号、档案号搜索').fill(customerA.phone);
|
||
await page.locator('.ant-input-suffix .search_btn', { hasText: '搜索' }).click();
|
||
await page.locator('.custom_content', { hasText: customerA.phone }).click();
|
||
await page.locator('.m-table__fixed-left').getByText(customerA.username).first().click();
|
||
|
||
// 分配员工
|
||
await page.locator('.person_content').waitFor();
|
||
await page.locator('.user_name').locator('i').click();
|
||
|
||
// 打开员工分配页面
|
||
await page.locator('.member_info_list', { hasText: '顾问' }).locator('.beautician_box').click();
|
||
|
||
// 选择分配的员工
|
||
await page.getByRole('treeitem', { name: employee.name }).click();
|
||
|
||
await page.getByRole('button', { name: /确\s认/ }).click();
|
||
await page.getByRole('button', { name: /保\s存/ }).click();
|
||
// 返回顾客模块
|
||
await page.locator('.close_icons > svg').click();
|
||
});
|
||
|
||
await test.step('给员工设置目标', async () => {
|
||
await homeNavigation.gotoModule('目标');
|
||
await page.getByRole('button', { name: '设置目标' }).click();
|
||
|
||
const department = await page.getByRole('combobox').innerText();
|
||
if (customerA.department === 1) {
|
||
if (department !== firstStoreFirstSector.name) {
|
||
await page.getByRole('combobox').click();
|
||
await page.getByRole('option', { name: firstStoreFirstSector.name }).click();
|
||
}
|
||
} else if (customerA.department === 2) {
|
||
if (department !== firstStoreSecondSector.name) {
|
||
await page.getByRole('combobox').click();
|
||
await page
|
||
.getByRole('option', {
|
||
name: firstStoreSecondSector.name,
|
||
})
|
||
.click();
|
||
}
|
||
}
|
||
|
||
const popupContent = page.locator('.popup_content .m-table__body-wrapper');
|
||
await expect(popupContent).toContainText(employee.name);
|
||
|
||
// 选择某个员工的现金列
|
||
await popupContent.locator('tbody > tr', { hasText: employee.name }).locator('td').nth(1).click();
|
||
await numberInput.setValue(1);
|
||
await numberInput.confirmValue();
|
||
await page.getByRole('button', { name: /保\s存/ }).click();
|
||
});
|
||
|
||
await test.step('给顾客设置服务项目,查看设置的服务项目, 查看项目的状态', async () => {
|
||
// await page.pause();
|
||
await page.locator('.left_view .tab_item', { hasText: '精细化管理' }).click();
|
||
await page.getByRole('cell', { name: '顾客' }).waitFor();
|
||
|
||
await page.getByRole('button', { name: '设置目标' }).click();
|
||
await Promise.all([
|
||
await page.locator('.com_picker .label', { hasText: employee.name }).click(),
|
||
await page.waitForResponse(res => res.url().includes('/user_kpi_detail') && res.status() === 200),
|
||
]);
|
||
|
||
// 设置精细化窗口
|
||
const settingPointViewLocator = page.locator('.flow_content');
|
||
// 设置顾客行
|
||
const settingCustomerLocator = settingPointViewLocator.locator(
|
||
'.m-table__body-wrapper .main-table-body_tr',
|
||
);
|
||
|
||
const userTr = settingCustomerLocator.filter({ hasText: customerA.username });
|
||
|
||
await page.locator('.filter_box').getByRole('button').click();
|
||
await page.getByPlaceholder('输入顾客姓名、手机号、首字母搜索').fill(customerA.phone);
|
||
|
||
// 查询指定顾客
|
||
await Promise.all([
|
||
page.locator('.search_btn > svg').click(),
|
||
page.waitForResponse(res => res.url().includes('/user_kpi_detail') && res.status() === 200),
|
||
]);
|
||
|
||
await expect(userTr).toBeVisible();
|
||
|
||
await userTr.locator('td', { hasText: '增加' }).first().click();
|
||
await page.waitForTimeout(2000);
|
||
// 项目选择器
|
||
const projectPickerLocator = page.locator('.com_picker', {
|
||
has: page.locator('.comSelect_title', { hasText: '添加项目' }),
|
||
});
|
||
await projectPickerLocator.locator('.search_box input').fill(project.no);
|
||
await projectPickerLocator.getByRole('button', { name: /搜\s索/ }).click();
|
||
await expect(async () => {
|
||
await projectPickerLocator.locator('.label', { hasText: project.no }).click();
|
||
await page.getByRole('button', { name: '确定选择' }).click();
|
||
await expect(page.locator('.popup_content', { hasText: '修改次数' })).toBeVisible({
|
||
timeout: 2000,
|
||
});
|
||
}).toPass();
|
||
await numberInput.setValue(1);
|
||
await numberInput.confirmValue();
|
||
await expect(userTr).toContainText(project.name);
|
||
await page.locator('.close_btn > .icon > svg').click();
|
||
});
|
||
|
||
await test.step('选择顾客A去开单,购买目标项目,选择目标员工结算', async () => {
|
||
await homeNavigation.gotoModule('收银');
|
||
await page.getByRole('button', { name: /开\s单/ }).click();
|
||
await page.getByPlaceholder('姓名(拼音首字)、手机号、档案号搜索').fill(customerA.phone);
|
||
await page.locator('.ant-input-suffix', { hasText: '搜索' }).click();
|
||
await page.locator('.member_list .phone', { hasText: customerA.phone }).click();
|
||
|
||
// 选择项目
|
||
await page.locator('.project_list .number', { hasText: project.no }).click();
|
||
await page.getByRole('button', { name: '体' }).click();
|
||
await page.locator('.popup_content').getByText('普通').click();
|
||
|
||
// 选择添加员工
|
||
await page.locator('button.staff_btn').click();
|
||
await page.locator('.check_row', { hasText: employee.name }).getByRole('checkbox').check();
|
||
await page.getByRole('button', { name: /确\s认/ }).click();
|
||
await page.locator('.pay_btn', { hasText: /^结\s算$/ }).click();
|
||
await page.getByLabel('推送消费提醒').uncheck();
|
||
await page.getByLabel('结算签字').uncheck();
|
||
|
||
const leftPaymentInfoItem = page.locator('.left .paymentmain .paymentInfoItem');
|
||
await leftPaymentInfoItem.filter({ hasText: '现金' }).click();
|
||
await page.getByRole('button', { name: /结\s算/ }).click();
|
||
});
|
||
|
||
await test.step('选择顾客B去开单,购买项目并消耗,选择目标员工结算', async () => {
|
||
await homeNavigation.gotoModule('收银');
|
||
await page.getByRole('button', { name: /开\s单/ }).click();
|
||
await page.getByPlaceholder('姓名(拼音首字)、手机号、档案号搜索').fill(customerB.phone);
|
||
await page.locator('.ant-input-suffix', { hasText: '搜索' }).click();
|
||
await page.locator('.member_list .phone', { hasText: customerB.phone }).click();
|
||
|
||
// 购买并消耗
|
||
await page.locator('.project_list .number', { hasText: project.no }).click();
|
||
await page.locator('#shoppingCart .commodity_list li').first().click();
|
||
|
||
// 购买添加员工
|
||
await page.locator('#buyList .staff_btn').click();
|
||
await page.locator('.check_row', { hasText: employee.name }).getByRole('checkbox').check();
|
||
await page.getByRole('button', { name: /确\s认/ }).click();
|
||
|
||
// 消耗添加员工
|
||
await page.locator('.use_list .staff_btn').click();
|
||
await page.locator('.check_row', { hasText: employee.name }).getByRole('checkbox').check();
|
||
await page.getByRole('button', { name: /确\s认/ }).click();
|
||
|
||
await page.locator('.pay_btn', { hasText: /结\s算/ }).click();
|
||
await page.getByLabel('推送消费提醒').uncheck();
|
||
await page.getByLabel('结算签字').uncheck();
|
||
|
||
const leftPaymentInfoItem = page.locator('.left .paymentmain .paymentInfoItem');
|
||
await leftPaymentInfoItem.filter({ hasText: '现金' }).click();
|
||
await page.getByRole('button', { name: /结\s算/ }).click();
|
||
});
|
||
|
||
await test.step('进入目标页面,查看顾客A和顾客B的状态', async () => {
|
||
await homeNavigation.gotoModule('目标');
|
||
await page.locator('.left_view .tab_item', { hasText: '精细化管理' }).click();
|
||
await page.waitForLoadState('domcontentloaded');
|
||
|
||
// 获取顾客A的项目状态
|
||
const customerATr = page
|
||
.locator('#app tr')
|
||
.filter({ has: page.locator('td', { hasText: customerA.username }) });
|
||
await customerATr.locator('.service_box .item_li use').first().click();
|
||
await expect(page.getByRole('tooltip')).toContainText('已经完成');
|
||
// 获取顾客B的项目状态
|
||
const customerBTr = page
|
||
.locator('#app tr')
|
||
.filter({ has: page.locator('td', { hasText: customerB.username }) });
|
||
|
||
await expect(customerBTr).toContainText('惊喜');
|
||
});
|
||
});
|
||
|
||
test('查看员工精细化目标', async ({ page, homeNavigation }) => {
|
||
let cashCustomer;
|
||
let cashProject;
|
||
let cashGoal;
|
||
let expendCustomer;
|
||
let expendProject;
|
||
let expendGoal;
|
||
|
||
await test.step('获取员工目标数据', async () => {
|
||
// 进入目标页面
|
||
await homeNavigation.gotoModule('目标');
|
||
await page.locator('.tab_item', { hasText: '精细化管理' }).click();
|
||
await expect.soft(page.locator('.m-table__icon__warp')).toBeHidden();
|
||
await expect(page.locator('.custom_txt')).not.toBeVisible();
|
||
|
||
const code = page.locator('.m-table__body-wrapper tbody tr').first();
|
||
// 现金顾客、项目、目标
|
||
cashCustomer = await code.locator('td').nth(1).innerText();
|
||
// 保留从第一个字符到x之前
|
||
cashProject = (await code.locator('td').nth(2).innerText()).match(/^[^x]+/)?.[0];
|
||
cashGoal = await code.locator('td').nth(3).locator('.has_done').innerText();
|
||
// 消耗顾客、项目、目标
|
||
expendCustomer = await code.locator('td').nth(1).innerText();
|
||
expendProject = (await code.locator('td').nth(5).innerText()).match(/^[^x]+/)?.[0];
|
||
expendGoal = await code.locator('td').nth(6).locator('.has_done').innerText();
|
||
});
|
||
|
||
await test.step('获取员工精细化数据做对比', async () => {
|
||
// 点击员工进入员工精细化管理
|
||
await page.locator('.m-table__fixed-left tbody tr').first().locator('td').first().click();
|
||
await page.locator('.title', { hasText: '员工精细化目标' }).waitFor();
|
||
await expect.soft(page.locator('.m-table__icon__warp')).toBeHidden();
|
||
await page.locator('.loading_container').waitFor({ state: 'hidden' });
|
||
// 获取最后一个表格行
|
||
const cedes = page.locator('.m-table__body-wrapper').last().locator('tr').first();
|
||
|
||
// 现金
|
||
await expect.soft(cedes.locator('td').nth(0)).toContainText(cashCustomer);
|
||
await expect.soft(cedes.locator('td').nth(1)).toContainText(cashProject);
|
||
await expect.soft(cedes.locator('td').nth(2)).toContainText(cashGoal);
|
||
// 消耗
|
||
await expect.soft(cedes.locator('td').nth(0)).toContainText(expendCustomer);
|
||
await expect.soft(cedes.locator('td').nth(4)).toContainText(expendProject);
|
||
await expect(cedes.locator('td').nth(5)).toContainText(expendGoal);
|
||
});
|
||
});
|
||
});
|