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 }); }); } });