purchase.spec.ts
5.88 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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
import { test, expect } from '@playwright/test';
import * as allure from 'allure-js-commons';
import { PurchasePage } from '../pages/purchasePage';
/**
* 采购入库测试
*/
test.describe('采购入库', () => {
// 使用已保存的认证状态
test.use({ storageState: 'auth.json' });
// 强制测试串行执行,避免并行测试之间的干扰
test.describe.configure({ mode: 'serial' });
test('采购入库存草稿', async ({ page }, testInfo) => {
const purchasePage = new PurchasePage(page);
// 添加allure元素
await allure.epic('仓储管理');
await allure.feature('采购入库');
await allure.story('采购入库存草稿');
// 测试数据
let supplierName: string;
let warehouseName: string;
let productName: string;
// 步骤1:进入采购入库页面
await allure.step('进入采购入库页面', async () => {
await purchasePage.openPurchaseInbound();
});
// 步骤2:随机选择商品
await allure.step('随机选择商品', async () => {
productName = await purchasePage.selectRandomProduct();
console.log('商品:', productName);
});
// 步骤3:输入数量
await allure.step('输入数量', async () => {
await purchasePage.enterQuantity('1');
});
// 步骤5:输入单价
await allure.step('输入单价', async () => {
await purchasePage.enterPrice('2');
});
// 步骤6:点击完成
await allure.step('点击完成', async () => {
await purchasePage.clickDone();
});
// 步骤7:随机选择供应商
await allure.step('随机选择供应商', async () => {
supplierName = await purchasePage.getRandomSupplier();
console.log('供应商:', supplierName);
});
// 步骤8:随机选择仓库
await allure.step('随机选择仓库', async () => {
warehouseName = await purchasePage.getRandomWarehouse();
console.log('仓库:', warehouseName);
});
// 步骤9:存入草稿
await allure.step('存入草稿', async () => {
await purchasePage.clickSaveDraft();
});
// 步骤10:打开草稿单列表
await allure.step('打开草稿单列表', async () => {
await purchasePage.clickDraftList();
});
// 步骤11:搜索商品
await allure.step('搜索商品', async () => {
await purchasePage.searchInDraftList(productName!);
});
// 步骤12:验证草稿中存在该商品
await allure.step('验证草稿中存在该商品', async () => {
await purchasePage.expectDraftContainsProduct(productName!);
});
});
test('采购入库付款', async ({ page }, testInfo) => {
const purchasePage = new PurchasePage(page);
// 添加allure元素
await allure.epic('仓储管理');
await allure.feature('采购入库');
await allure.story('采购入库付款');
// 测试数据
let supplierName: string;
let warehouseName: string;
let productName: string;
// 步骤1:进入采购入库页面
await allure.step('进入采购入库页面', async () => {
await purchasePage.openPurchaseInbound();
});
// 步骤2:随机选择商品
await allure.step('随机选择商品', async () => {
productName = await purchasePage.selectRandomProduct();
console.log('商品:', productName);
});
// 步骤3:输入数量
await allure.step('输入数量', async () => {
await purchasePage.enterQuantity('1');
});
// 步骤4:输入单价
await allure.step('输入单价', async () => {
await purchasePage.enterPrice('1');
});
// 步骤5:点击完成
await allure.step('点击完成', async () => {
await purchasePage.clickDone();
});
// 步骤6:添加入库费用
await allure.step('添加入库费用', async () => {
await purchasePage.addExpense(0, '1');
});
// 步骤7:随机选择供应商
await allure.step('随机选择供应商', async () => {
supplierName = await purchasePage.getRandomSupplier();
console.log('供应商:', supplierName);
});
// 步骤8:随机选择仓库
await allure.step('随机选择仓库', async () => {
warehouseName = await purchasePage.getRandomWarehouse();
console.log('仓库:', warehouseName);
});
// 步骤9:选择采购员
await allure.step('选择采购员', async () => {
await purchasePage.selectPurchaser();
});
// 步骤10:输入车牌号
await allure.step('输入车牌号', async () => {
await purchasePage.enterLicensePlate('渝A99999');
});
// 步骤11:输入备注
await allure.step('输入备注', async () => {
await purchasePage.enterRemark('自动化测试');
});
// 步骤12:上传图片(暂时跳过)
// await allure.step('上传图片', async () => {
// await purchasePage.uploadImage('test-data/img/苹果.jpg');
// });
// 步骤13:点击付款
await allure.step('点击付款', async () => {
await purchasePage.clickPay();
});
// 步骤14:选择结算账户
await allure.step('选择结算账户', async () => {
await purchasePage.selectSettlementAccount('微信支付');
});
// 步骤15:确认付款
await allure.step('确认付款', async () => {
await purchasePage.confirmPayment();
});
// 步骤16:进入采购列表
await allure.step('进入采购列表', async () => {
await purchasePage.goToPurchaseList();
});
// 步骤17:搜索商品
await allure.step('搜索商品', async () => {
await purchasePage.searchInPurchaseList(productName);
});
// 步骤18:验证采购列表中存在该商品
await allure.step('验证采购列表中存在该商品', async () => {
await purchasePage.expectPurchaseListContainsProduct(productName);
});
});
});