- 添加项目配置文件和环境变量设置 - 创建测试用例目录结构和命名规范 - 实现基础测试 fixture 和页面对象模型 - 添加示例测试用例和数据生成器 - 配置 playwright 和 gitignore 文件
40 lines
1.1 KiB
TypeScript
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]}`));
|
|
};
|
|
}
|