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

81 lines
2.5 KiB
TypeScript

import { type Locator, type Page } from '@playwright/test';
import { waitSpecifyApiLoad } from '@/utils/utils.js';
export class MarketingInviteGuestsPage {
page: Page;
subPages: { name: string; content?: { name: string; url?: string[] }[] }[];
$$tabItem: Locator;
/**
* 邀客管理页面
* @param page
*/
constructor(page: Page) {
this.page = page;
this.$$tabItem = this.page.locator('.tab_item');
this.subPages = [
{
name: '邀客管理',
},
{
name: '返利方案',
},
{
name: '数据统计',
},
{
name: '设置',
content: [
{ name: '礼品设置', url: [] },
{ name: '礼品分配', url: ['/user_present'] },
{ name: '返利升级方案', url: [] },
{ name: '设置', url: [] },
],
},
];
}
/**
* 进入子页面
* @param subPageName 子页面名称
* - 邀客管理
* - 返利方案
* - 数据统计
* - 设置
*/
gotoSubPage = async (subPageName: string) => {
const subPage = this.subPages.find(e => e.name === subPageName);
if (!subPage) {
throw new Error(`${subPageName}不存在`);
}
const $tabItem = this.$$tabItem.filter({ hasText: subPageName });
await $tabItem.click();
};
/**
* 进入设置子页面
* @param subPageName 子页面名称
* - 礼品设置
* - 礼品分配
* - 返利升级方案
* - 设置
*/
gotoSettingSubPage = async (subPageName: string) => {
const $tabItem = this.$$tabItem.filter({ hasText: subPageName });
const $tabItemDropDown = $tabItem.locator('.ant-dropdown-link');
const $dropDownSelected = this.page.getByRole('menuitem', { name: subPageName });
const settingSubPage = this.subPages.find(e => e.name === '设置')?.content?.find(e => e.name === subPageName);
if (!settingSubPage) {
throw new Error(`${subPageName}不存在`);
}
// 打开下拉
await $tabItemDropDown.click();
// 选择下拉选择
await Promise.all([$dropDownSelected.click(), waitSpecifyApiLoad(this.page, settingSubPage.url)]);
// 确认选择成功
await $tabItemDropDown.filter({ hasText: subPageName }).waitFor();
};
}