Commit 42894307b06adb629c524cace893539cb0e40570

Authored by 赵旭婷
2 parents a744361f e1a3b38f

merge: purchase draft edit feature

pages/purchasePage.ts
... ... @@ -102,7 +102,7 @@ export class PurchasePage extends BasePage {
102 102  
103 103 // 图片上传
104 104 readonly uploadImageButton: Locator;
105   -
  105 +
106 106 // 保存
107 107 readonly saveButton: Locator;
108 108  
... ... @@ -158,7 +158,7 @@ export class PurchasePage extends BasePage {
158 158  
159 159 // 图片上传
160 160 this.uploadImageButton = page.getByText('图片(最多上传9张)');
161   -
  161 +
162 162 // 保存
163 163 this.saveButton = page.getByText('保存', { exact: true });
164 164  
... ... @@ -363,6 +363,34 @@ export class PurchasePage extends BasePage {
363 363 }
364 364  
365 365 /**
  366 + * 点击保存按钮
  367 + */
  368 + async clickSave(): Promise<void> {
  369 + await this.saveButton.click();
  370 + await this.page.waitForLoadState('networkidle', { timeout: 30000 });
  371 + await this.page.waitForTimeout(2000);
  372 + }
  373 +
  374 + /**
  375 + * 点击草稿单中的商品名称进入编辑页
  376 + * @param productName 商品名称
  377 + */
  378 + async clickDraftProduct(productName: string): Promise<void> {
  379 + await this.page.locator('span').filter({ hasText: productName }).first().click();
  380 + await this.page.waitForLoadState('networkidle', { timeout: 30000 });
  381 + await this.page.waitForTimeout(1000);
  382 + }
  383 +
  384 + /**
  385 + * 验证采购单状态为待支付
  386 + * @param productName 商品名称
  387 + */
  388 + async expectPurchaseOrderStatusPending(productName: string): Promise<void> {
  389 + const statusLabel = this.page.getByText('待支付').nth(1);
  390 + await expect(statusLabel).toBeVisible({ timeout: 10000 });
  391 + }
  392 +
  393 + /**
366 394 * 创建采购入库草稿(完整流程)
367 395 * @param productName 商品名称
368 396 * @param supplierName 供应商名称
... ... @@ -497,24 +525,6 @@ export class PurchasePage extends BasePage {
497 525 }
498 526  
499 527 /**
500   - * 点击保存按钮
501   - */
502   - async clickSave(): Promise<void> {
503   - await this.saveButton.click();
504   - await this.page.waitForLoadState('networkidle', { timeout: 30000 });
505   - await this.page.waitForTimeout(2000);
506   - }
507   -
508   - /**
509   - * 验证采购单状态为待支付
510   - * @param productName 商品名称
511   - */
512   - async expectPurchaseOrderStatusPending(productName: string): Promise<void> {
513   - const statusLabel = this.page.getByText('待支付').nth(1);
514   - await expect(statusLabel).toBeVisible({ timeout: 10000 });
515   - }
516   -
517   - /**
518 528 * 点击付款按钮
519 529 */
520 530 async clickPay(): Promise<void> {
... ...
tests/purchase.spec.ts
... ... @@ -14,7 +14,7 @@ test.describe(&#39;采购入库&#39;, () =&gt; {
14 14  
15 15 test('采购入库存草稿', async ({ page }, testInfo) => {
16 16 const purchasePage = new PurchasePage(page);
17   -
  17 +
18 18 // 添加allure元素
19 19 await allure.epic('仓储管理');
20 20 await allure.feature('采购入库');
... ... @@ -23,7 +23,7 @@ test.describe(&#39;采购入库&#39;, () =&gt; {
23 23 // 测试数据
24 24 let supplierName: string;
25 25 let warehouseName: string;
26   -
  26 +
27 27 let productName: string;
28 28  
29 29 // 步骤1:进入采购入库页面
... ... @@ -85,105 +85,120 @@ test.describe(&#39;采购入库&#39;, () =&gt; {
85 85 });
86 86 });
87 87  
88   - test('采购入库保存', async ({ page }, testInfo) => {
  88 + test('采购入库付款', async ({ page }, testInfo) => {
89 89 const purchasePage = new PurchasePage(page);
90   -
  90 +
91 91 // 添加allure元素
92 92 await allure.epic('仓储管理');
93 93 await allure.feature('采购入库');
94   - await allure.story('采购入库保存');
95   -
  94 + await allure.story('采购入库付款');
  95 +
96 96 // 测试数据
97 97 let supplierName: string;
98 98 let warehouseName: string;
99 99 let productName: string;
100   -
  100 +
101 101 // 步骤1:进入采购入库页面
102 102 await allure.step('进入采购入库页面', async () => {
103 103 await purchasePage.openPurchaseInbound();
104 104 });
105   -
  105 +
106 106 // 步骤2:随机选择商品
107 107 await allure.step('随机选择商品', async () => {
108 108 productName = await purchasePage.selectRandomProduct();
109 109 console.log('商品:', productName);
110 110 });
111   -
  111 +
112 112 // 步骤3:输入数量
113 113 await allure.step('输入数量', async () => {
114 114 await purchasePage.enterQuantity('1');
115 115 });
116   -
  116 +
117 117 // 步骤4:输入单价
118 118 await allure.step('输入单价', async () => {
119 119 await purchasePage.enterPrice('1');
120 120 });
121   -
  121 +
122 122 // 步骤5:点击完成
123 123 await allure.step('点击完成', async () => {
124 124 await purchasePage.clickDone();
125 125 });
126   -
  126 +
127 127 // 步骤6:添加入库费用
128 128 await allure.step('添加入库费用', async () => {
129 129 await purchasePage.addExpense(0, '1');
130 130 });
131   -
  131 +
132 132 // 步骤7:随机选择供应商
133 133 await allure.step('随机选择供应商', async () => {
134 134 supplierName = await purchasePage.getRandomSupplier();
135 135 console.log('供应商:', supplierName);
136 136 });
137   -
  137 +
138 138 // 步骤8:随机选择仓库
139 139 await allure.step('随机选择仓库', async () => {
140 140 warehouseName = await purchasePage.getRandomWarehouse();
141 141 console.log('仓库:', warehouseName);
142 142 });
143   -
  143 +
144 144 // 步骤9:选择采购员
145 145 await allure.step('选择采购员', async () => {
146 146 await purchasePage.selectPurchaser();
147 147 });
148   -
  148 +
149 149 // 步骤10:输入车牌号
150 150 await allure.step('输入车牌号', async () => {
151 151 await purchasePage.enterLicensePlate('渝A99999');
152 152 });
153   -
  153 +
154 154 // 步骤11:输入备注
155 155 await allure.step('输入备注', async () => {
156 156 await purchasePage.enterRemark('自动化测试');
157 157 });
158   -
  158 +
159 159 // 步骤12:上传图片(暂时跳过)
160 160 // await allure.step('上传图片', async () => {
161 161 // await purchasePage.uploadImage('test-data/img/苹果.jpg');
162 162 // });
163   -
164   - // 步骤13:点击保存
165   - await allure.step('点击保存', async () => {
166   - await purchasePage.clickSave();
  163 +
  164 + // 步骤13:点击付款
  165 + await allure.step('点击付款', async () => {
  166 + await purchasePage.clickPay();
167 167 });
168   -
169   - // 步骤14:搜索商品
  168 +
  169 + // 步骤14:选择结算账户
  170 + await allure.step('选择结算账户', async () => {
  171 + await purchasePage.selectSettlementAccount('微信支付');
  172 + });
  173 +
  174 + // 步骤15:确认付款
  175 + await allure.step('确认付款', async () => {
  176 + await purchasePage.confirmPayment();
  177 + });
  178 +
  179 + // 步骤16:进入采购列表
  180 + await allure.step('进入采购列表', async () => {
  181 + await purchasePage.goToPurchaseList();
  182 + });
  183 +
  184 + // 步骤17:搜索商品
170 185 await allure.step('搜索商品', async () => {
171 186 await purchasePage.searchInPurchaseList(productName);
172 187 });
173   -
174   - // 步骤15:验证采购单状态为待支付
175   - await allure.step('验证采购单状态为待支付', async () => {
176   - await purchasePage.expectPurchaseOrderStatusPending(productName);
  188 +
  189 + // 步骤18:验证采购列表中存在该商品
  190 + await allure.step('验证采购列表中存在该商品', async () => {
  191 + await purchasePage.expectPurchaseListContainsProduct(productName);
177 192 });
178 193 });
179 194  
180   - test('采购入库付款', async ({ page }, testInfo) => {
  195 + test('采购入库草稿编辑', async ({ page }, testInfo) => {
181 196 const purchasePage = new PurchasePage(page);
182 197  
183 198 // 添加allure元素
184 199 await allure.epic('仓储管理');
185 200 await allure.feature('采购入库');
186   - await allure.story('采购入库付款');
  201 + await allure.story('采购入库草稿编辑');
187 202  
188 203 // 测试数据
189 204 let supplierName: string;
... ... @@ -216,71 +231,56 @@ test.describe(&#39;采购入库&#39;, () =&gt; {
216 231 await purchasePage.clickDone();
217 232 });
218 233  
219   - // 步骤6:添加入库费用
220   - await allure.step('添加入库费用', async () => {
221   - await purchasePage.addExpense(0, '1');
222   - });
223   -
224   - // 步骤7:随机选择供应商
  234 + // 步骤6:随机选择供应商
225 235 await allure.step('随机选择供应商', async () => {
226 236 supplierName = await purchasePage.getRandomSupplier();
227 237 console.log('供应商:', supplierName);
228 238 });
229 239  
230   - // 步骤8:随机选择仓库
  240 + // 步骤7:随机选择仓库
231 241 await allure.step('随机选择仓库', async () => {
232 242 warehouseName = await purchasePage.getRandomWarehouse();
233 243 console.log('仓库:', warehouseName);
234 244 });
235 245  
236   - // 步骤9:选择采购员
237   - await allure.step('选择采购员', async () => {
238   - await purchasePage.selectPurchaser();
239   - });
240   -
241   - // 步骤10:输入车牌号
242   - await allure.step('输入车牌号', async () => {
243   - await purchasePage.enterLicensePlate('渝A99999');
  246 + // 步骤8:存入草稿
  247 + await allure.step('存入草稿', async () => {
  248 + await purchasePage.clickSaveDraft();
244 249 });
245 250  
246   - // 步骤11:输入备注
247   - await allure.step('输入备注', async () => {
248   - await purchasePage.enterRemark('自动化测试');
  251 + // 步骤9:打开草稿单列表
  252 + await allure.step('打开草稿单列表', async () => {
  253 + await purchasePage.clickDraftList();
249 254 });
250 255  
251   - // 步骤12:上传图片(暂时跳过)
252   - // await allure.step('上传图片', async () => {
253   - // await purchasePage.uploadImage('test-data/img/苹果.jpg');
254   - // });
255   -
256   - // 步骤13:点击付款
257   - await allure.step('点击付款', async () => {
258   - await purchasePage.clickPay();
  256 + // 步骤10:搜索商品
  257 + await allure.step('搜索商品', async () => {
  258 + await purchasePage.searchInDraftList(productName);
259 259 });
260 260  
261   - // 步骤14:选择结算账户
262   - await allure.step('选择结算账户', async () => {
263   - await purchasePage.selectSettlementAccount('微信支付');
  261 + // 步骤11:点击草稿单商品进入编辑页
  262 + await allure.step('点击草稿单商品进入编辑页', async () => {
  263 + await purchasePage.clickDraftProduct(productName);
264 264 });
265 265  
266   - // 步骤15:确认付款
267   - await allure.step('确认付款', async () => {
268   - await purchasePage.confirmPayment();
  266 + // 步骤12:选择采购员
  267 + await allure.step('选择采购员', async () => {
  268 + await purchasePage.selectPurchaser();
269 269 });
270 270  
271   - // 步骤16:进入采购列表
272   - await allure.step('进入采购列表', async () => {
273   - await purchasePage.goToPurchaseList();
  271 + // 步骤13:点击保存
  272 + await allure.step('点击保存', async () => {
  273 + await purchasePage.clickSave();
274 274 });
275 275  
276   - // 步骤17:搜索商品
  276 + // 步骤14:搜索商品(采购列表自动跳转后)
277 277 await allure.step('搜索商品', async () => {
278 278 await purchasePage.searchInPurchaseList(productName);
279 279 });
280 280  
281   - // 步骤18:验证采购列表中存在该商品
282   - await allure.step('验证采购列表中存在该商品', async () => {
283   - await purchasePage.expectPurchaseListContainsProduct(productName);
  281 + // 步骤15:验证采购单状态为待支付
  282 + await allure.step('验证采购单状态为待支付', async () => {
  283 + await purchasePage.expectPurchaseOrderStatusPending(productName);
284 284 });
285 285 });
286 286 -});
  287 +});
287 288 \ No newline at end of file
... ...