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

72 lines
2.7 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { Locator, Page } from 'playwright';
import { waitSpecifyApiLoad } from '@/utils/utils';
export class WasteBookBusinessRecordPage {
page: Page;
$homePage: Locator;
subPages: { name: string; url?: string[] }[];
/**
* 流水模块-营业记录页面
* @param {import("@playwright/test").Page} page
*/
constructor(page: Page) {
this.page = page;
this.$homePage = this.page.locator('.top_tab .tab_item', {
hasText: '营业记录',
});
this.subPages = [
{ name: '营业记录', url: ['/settled_flow'] },
{ name: '业绩流水', url: ['/perf_flow'] },
{ name: '对账流水', url: ['/payment_flow'] },
];
}
/**
* 进入营业记录子页面
* @param subPageName 子页面名称
* - 营业记录
* - 业绩流水
* - 对账流水
*/
gotoSubPage = async (subPageName: string) => {
const subPage = this.subPages.find(item => item.name === subPageName);
if (!subPage) {
throw new Error(`未找到${subPageName}页面`);
}
const $dropDown = this.$homePage.locator('.ant-dropdown-link');
await $dropDown.click();
const $subPage = this.page.getByRole('menuitem', { name: subPageName });
await Promise.all([$subPage.click(), waitSpecifyApiLoad(this.page, subPage.url)]);
};
/**
* 根据billSet进行撤单操作
* 配合billSet夹具使用baseFixture
*/
revokeOrder = async (billSet: Set<string>) => {
// 撤掉在预约中开的单
if (billSet.size === 0) {
return;
}
await this.page.getByText('已结算', { exact: true }).waitFor();
for (const bill of billSet) {
await this.page.getByRole('button').click();
await this.page.getByPlaceholder('输入流水单号搜索').fill(bill);
await this.page.locator('.search_btn > svg').click();
const $fixedRightTable = this.page.locator('.m-table__fixed-right');
await $fixedRightTable.locator('td').nth(1).getByText('撤单').click();
await this.page.getByPlaceholder('请输入1-100个字符备注内容').click();
await this.page.getByPlaceholder('请输入1-100个字符备注内容').fill('撤单');
await this.page.getByRole('button', { name: /确\s认/ }).click();
try {
await this.page.locator('.ant-message', { hasText: '撤单成功' }).waitFor({ timeout: 3000 });
} catch (error) {
console.log(`撤单失败,流水单号:${bill}`);
await this.page.getByRole('button', { name: '我知道了' }).click();
}
}
};
}