Some checks are pending
Playwright Tests / test (push) Waiting to run
init test test test 划分美管加、慧来客、智荟宝项目 新增美管加demo 新增npm命令 测试智荟宝 test test ii csv test init test test init init
52 lines
1.8 KiB
JavaScript
52 lines
1.8 KiB
JavaScript
const { faker } = require('@faker-js/faker/locale/zh_CN');
|
|
const { expect } = require('@playwright/test');
|
|
|
|
export class Customer {
|
|
constructor({
|
|
name = faker.person.fullName(),
|
|
phone = faker.helpers.fromRegExp(/123[0-5]{8}/),
|
|
} = {}) {
|
|
this.name = name;
|
|
this.phone = phone;
|
|
}
|
|
}
|
|
|
|
export class CustomerPage {
|
|
constructor(page) {
|
|
this.page = page;
|
|
}
|
|
|
|
/**
|
|
* 创建顾客
|
|
* @param {Customer} customer
|
|
*/
|
|
createCustomer = async (customer) => {
|
|
console.log(customer.name);
|
|
console.log(customer.phone);
|
|
|
|
await expect(this.page.locator('#page_member').getByText('新增顾客档案')).toBeVisible();
|
|
await this.page.locator('#page_member').getByText('新增顾客档案').click();
|
|
|
|
await this.page.getByPlaceholder('请输入会员姓名').fill(customer.name);
|
|
await this.page.getByPlaceholder('请输入手机号码').click();
|
|
await expect(this.page.getByText('请输入数字')).toBeVisible();
|
|
await this.page.getByPlaceholder('在此输入').click();
|
|
await this.page.keyboard.type(customer.phone, { delay: 50 });
|
|
// await this.page.getByPlaceholder('在此输入').type(customer.phone, { delay: 100 });
|
|
await this.page.locator('#maskBoard').getByText('确认').click();
|
|
await expect(this.page.getByPlaceholder('请输入手机号码')).toHaveValue(customer.phone, {
|
|
timeout: 2000,
|
|
});
|
|
await this.page
|
|
.locator('div')
|
|
.filter({ hasText: /^员工带客$/ })
|
|
.locator('span')
|
|
.first()
|
|
.click();
|
|
await this.page.getByText('创建', { exact: true }).click();
|
|
await expect(this.page.getByText('用户资料创建成功!')).toBeVisible();
|
|
await this.page.getByText('以后再说').click();
|
|
await expect(this.page.getByText('以后再说')).not.toBeVisible();
|
|
};
|
|
}
|