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/pages/cashierRoomPage.ts
LingandRX 6517e4192c feat: 初始化慧来客自动化测试项目
- 添加项目配置文件和环境变量设置
- 创建测试用例目录结构和命名规范
- 实现基础测试 fixture 和页面对象模型
- 添加示例测试用例和数据生成器
- 配置 playwright 和 gitignore 文件
2024-12-22 19:18:27 +08:00

40 lines
1.1 KiB
TypeScript

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