supplier_update.spec.ts
2.77 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
72
73
74
75
76
77
78
79
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 namePrefixes = ['修改', '更新', '调整', '变更'];
const namePrefix = namePrefixes[Math.floor(Math.random() * namePrefixes.length)];
const info = await supplierPage.generateRandomSupplierInfo({
namePrefix: namePrefix,
});
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.clickSupplierItemByIndex(0);
// 点击编辑按钮
await supplierPage.clickEditButton();
// 修改供应商名称
await supplierPage.clearAndFillFormField(supplierPage.supplierNameInput, supplierInfo.name);
// 修改负责人名称
await supplierPage.clearAndFillFormField(supplierPage.managerNameInput, supplierInfo.managerName);
// 修改手机号
await supplierPage.clearAndFillFormField(supplierPage.phoneInput, supplierInfo.phone);
// 选择供应商类型(必选字段)
await supplierPage.selectSupplierType();
// 绑定园区卡
await supplierPage.selectParkCard('888800010617');
// 修改备注
await supplierPage.clearAndFillFormField(supplierPage.remarkInput, supplierInfo.remark || '');
// 保存
await supplierPage.clickConfirmButton();
await supplierPage.attachScreenshot(testInfo, '编辑供应商成功截图');
});
// 步骤3:验证供应商修改成功
await allure.step('验证供应商修改成功', async () => {
const isUpdated = await supplierPage.verifySupplierCreated(supplierInfo.name);
expect(isUpdated).toBeTruthy();
});
});
});