supplier_add.spec.ts
2.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import { test, expect } from '../fixtures';
import * as allure from 'allure-js-commons';
/**
* 供应商管理测试
*/
// 新增供应商
test.describe('供应商管理', () => {
// 使用已保存的认证状态
test.use({ storageState: 'auth.json' });
// 强制测试串行执行,避免并行测试之间的干扰
test.describe.configure({ mode: 'serial' });
test('新建供应商并绑定园区卡', async ({ supplierPage }, testInfo) => {
// 添加allure元素
await allure.epic('供应商管理');
await allure.feature('供应商信息');
await allure.story('新建供应商');
// 步骤1:生成随机供应商信息
const supplierInfo = await allure.step('生成随机供应商信息', async () => {
const info = await supplierPage.generateRandomSupplierInfo();
console.log('供应商名称:', info.name);
console.log('负责人:', info.managerName);
console.log('手机号:', info.phone);
console.log('备注:', info.remark);
return info;
});
// 步骤2:填写并提交供应商表单
await allure.step('填写并提交供应商表单', async () => {
// 进入供应商管理页面
await supplierPage.navigateToSupplierManagement();
// 点击新建供应商
await supplierPage.clickAddSupplier();
// 填写供应商名称
await supplierPage.fillFormField(supplierPage.supplierNameInput, supplierInfo.name);
// 选择供应商分组
await supplierPage.selectGroup();
// 填写负责人名称
await supplierPage.fillFormField(supplierPage.managerNameInput, supplierInfo.managerName);
// 填写手机号
await supplierPage.fillFormField(supplierPage.phoneInput, supplierInfo.phone);
// 绑定园区卡
await supplierPage.selectParkCard('888810046477', '地利');
// 填写备注
await supplierPage.fillFormField(supplierPage.remarkInput, supplierInfo.remark || '');
// 保存
await supplierPage.saveButton.click();
await supplierPage.attachScreenshot(testInfo, '新建供应商成功截图');
});
// 步骤3:验证供应商创建成功
await allure.step('验证供应商创建成功', async () => {
const isCreated = await supplierPage.verifySupplierCreated(supplierInfo.name);
expect(isCreated).toBeTruthy();
});
});
});