- 添加了商品分类页面的测试用例,包括验证表格头和新增分类功能 - 添加了商品列表页面的测试用例,验证页面元素和功能 - 新增了 CommondityCategoryPage 和 CommondityCreateCategoryPage 两个页面对象 - 更新了环境变量和配置文件,为测试用例做准备
47 lines
1.7 KiB
TypeScript
47 lines
1.7 KiB
TypeScript
import { expect, type Locator, type Page } from '@playwright/test';
|
|
|
|
export class CommondityCreateCategoryPage {
|
|
readonly page: Page;
|
|
readonly create_category_page_header: Locator;
|
|
readonly create_category_button: Locator;
|
|
readonly category_level_select: (level: 1 | 2) => Locator;
|
|
readonly category_name_input: Locator;
|
|
readonly category_code_input: Locator;
|
|
readonly category_sort_input: Locator;
|
|
constructor(page: Page) {
|
|
this.page = page;
|
|
this.create_category_page_header = page.locator('.popup_content').getByText('新增分类', { exact: true });
|
|
this.create_category_button = page.getByRole('button', { name: /保\s存/ });
|
|
this.category_level_select = (level: 1 | 2) => {
|
|
const radioList = [
|
|
page.getByRole('radio', { name: '一级分类' }),
|
|
page.getByRole('radio', { name: '二级分类' }),
|
|
];
|
|
return radioList[level - 1];
|
|
};
|
|
this.category_name_input = page
|
|
.locator('div')
|
|
.filter({ hasText: /^分类名称\*$/ })
|
|
.getByPlaceholder('请输入分类名称');
|
|
this.category_code_input = page.locator('span').filter({ hasText: '请选择' }).locator('span').nth(1);
|
|
this.category_sort_input = page.getByPlaceholder('请输入分类排序');
|
|
}
|
|
|
|
async create_category(
|
|
categoryName: string,
|
|
categoryCode: string,
|
|
categorySort: string,
|
|
categoryLevel: 1 | 2
|
|
) {
|
|
await this.category_level_select(categoryLevel).click();
|
|
await this.category_name_input.fill(categoryName);
|
|
await this.category_code_input.fill(categoryCode);
|
|
await this.category_sort_input.fill(categorySort);
|
|
await this.create_category_button.click();
|
|
}
|
|
|
|
async open_create_category_page_success() {
|
|
await expect(this.create_category_page_header).toBeVisible();
|
|
}
|
|
}
|