supplier_grouping.spec.ts
4.22 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
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 ({ supplierGroupingPage }, testInfo) => {
await allure.epic('供应商管理');
await allure.feature('供应商分组');
await allure.story('新增供应商分组');
// 步骤1:生成随机分组信息
const groupName = `自动${Date.now().toString().slice(-3)}`;
const remark = '自动化测试';
// 步骤2:进入供应商分组页面并点击新建
await allure.step('进入供应商分组页面', async () => {
await supplierGroupingPage.navigateToSupplierGrouping();
await supplierGroupingPage.clickAddButton();
});
// 步骤3:填写分组信息
await allure.step('填写分组信息', async () => {
await supplierGroupingPage.fillGroupName(groupName);
await supplierGroupingPage.fillRemark(remark);
});
// 步骤4:保存分组
await allure.step('保存分组', async () => {
await supplierGroupingPage.saveGrouping();
await supplierGroupingPage.attachScreenshot(testInfo, '新增供应商分组成功截图');
});
// 步骤5:验证分组创建成功
await allure.step('验证分组创建成功', async () => {
const isCreated = await supplierGroupingPage.verifyGroupingCreated(groupName);
expect(isCreated).toBeTruthy();
});
});
test('修改供应商分组', async ({ supplierGroupingPage }, testInfo) => {
await allure.epic('供应商管理');
await allure.feature('供应商分组');
await allure.story('修改供应商分组');
// 步骤1:生成新的分组信息
const newGroupName = `修改${Date.now().toString().slice(-2)}`;
const newRemark = '自动化测试修改';
// 步骤2:进入供应商分组页面
await allure.step('进入供应商分组页面', async () => {
await supplierGroupingPage.navigateToSupplierGrouping();
});
// 步骤3:点击编辑分组
await allure.step('点击编辑分组', async () => {
await supplierGroupingPage.clickEditButton();
});
// 步骤4:修改分组信息
await allure.step('修改分组信息', async () => {
await supplierGroupingPage.updateGrouping(newGroupName, newRemark);
await supplierGroupingPage.attachScreenshot(testInfo, '修改供应商分组成功截图');
});
// 步骤5:验证分组修改成功
await allure.step('验证分组修改成功', async () => {
const isUpdated = await supplierGroupingPage.verifyGroupingUpdated(newGroupName);
expect(isUpdated).toBeTruthy();
});
});
test('删除供应商分组', async ({ supplierGroupingPage }, testInfo) => {
await allure.epic('供应商管理');
await allure.feature('供应商分组');
await allure.story('删除供应商分组');
// 步骤1:生成待删除的分组名称
const groupName = `删除${Date.now().toString().slice(-2)}`;
// 步骤2:先创建一个分组用于删除
await allure.step('创建待删除的分组', async () => {
await supplierGroupingPage.navigateToSupplierGrouping();
await supplierGroupingPage.clickAddButton();
await supplierGroupingPage.fillGroupName(groupName);
await supplierGroupingPage.fillRemark('自动化测试');
await supplierGroupingPage.saveGrouping();
});
// 步骤3:删除分组
await allure.step('删除分组', async () => {
await supplierGroupingPage.navigateToSupplierGrouping();
await supplierGroupingPage.clickGroupingItem(groupName);
await supplierGroupingPage.clickDeleteButton();
await supplierGroupingPage.confirmDelete();
await supplierGroupingPage.attachScreenshot(testInfo, '删除供应商分组成功截图');
});
// 步骤4:验证分组删除成功
await allure.step('验证分组删除成功', async () => {
const isDeleted = await supplierGroupingPage.verifyGroupingDeleted(groupName);
expect(isDeleted).toBeTruthy();
});
});
});