This repository has been archived on 2025-04-22. You can view files and clone it, but cannot push or open issues or pull requests.
hlk_autotest/tests/setup/staff_auth.setup.ts
LingandRX d44f457d86 test(boss_cashier): 优化挂单测试流程
- 移除不必要的挂单数量记录步骤
- 简化挂单流程,每个员工只挂单一次
- 使用 expect.soft 进行软断言,提高测试稳定性
- 优化员工选择和挂单校验的代码结构
2025-03-23 11:54:08 +08:00

38 lines
1.5 KiB
TypeScript

import { test as setup, expect } from '@playwright/test';
import { getEnvVar } from '@/utils/envUtils';
const employee = [
{
phone: process.env.staff1_account,
password: process.env.staff1_password,
authFile: '.auth/user_1.json',
},
{
phone: process.env.staff2_account,
password: process.env.staff2_password,
authFile: '.auth/user_2.json',
},
];
setup.describe('员工登录', () => {
for (const e of employee) {
setup(`门店员工登录_${e.phone}`, async ({ page }) => {
const phone = e.phone || '';
const password = e.password || '';
const baseUrl = getEnvVar('BASE_URL');
const $phone = page.getByRole('textbox', { name: '请输入您的手机号码' });
const $password = page.getByRole('textbox', { name: '请输入登录密码' });
const $login = page.getByRole('button', { name: /登\s录/ });
await page.goto(baseUrl);
await $phone.fill(phone);
const checkPhone = page.locator('.ant-row', { has: $phone }).locator('.pass_svg');
await expect(checkPhone).toBeVisible();
await $password.fill(password);
await page.getByLabel('请同意慧来客隐私政策和用户协议').check();
await $login.click();
await expect(page.getByRole('button', { name: /开\s单/ })).toBeEnabled();
await page.context().storageState({ path: e.authFile, indexedDB: true });
});
}
});