import { expect, type Locator, type Page } from '@playwright/test'; import { type Customer } from '@/utils/customer'; export class CashierRoomPage { page: Page; $userInfo: Locator; statusCss: {}; /** * 收银-房态 */ constructor(page: Page) { this.page = page; this.$userInfo = this.page.locator('.a_userInfo'); this.statusCss = { doing: 'doing', wait: 'wait', pass: 'pass', }; } /** * 检查顾客房间状态 * @param {import("../utils/customer").Customer} customer * @param {string} expectedStatus * - 'doing' 服务中 * - 'wait' 已占用 * - 'pass' 已结束 */ checkStatus = async (customer: Customer, expectedStatus: string) => { const userInfo = this.$userInfo.filter({ hasText: customer.username }); const count = await userInfo.count(); if (count !== 1) { throw new Error(`顾客${JSON.stringify(customer)}有${count}个预约房间`); } await expect(userInfo).toHaveClass(new RegExp(`${this.statusCss[expectedStatus]}`)); }; }