import { test as setup, expect } from "@playwright/test"; const authFileArray = [".auth/user_1.json", ".auth/user_2.json"]; const employee = [ { phone: process.env.staff1_account, password: process.env.staff1_password, }, { phone: process.env.staff2_account, password: process.env.staff2_password, }, ]; setup.describe("员工登录", () => { for (let i = 0; i < 2; i++) { setup(`门店员工登录_${i}`, async ({ page }) => { const baseUrl = process.env.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(employee[i].phone); const checkPhone = page.locator(".ant-row", { has: $phone }).locator(".pass_svg"); await expect(checkPhone).toBeVisible(); await $password.fill(employee[i].password); await page.getByLabel("请同意慧来客隐私政策和用户协议").check(); await $login.click(); await expect(page.getByRole("button", { name: /开\s单/ })).toBeEnabled(); await page.context().storageState({ path: authFileArray[i] }); }); } });