Commit a744361f1f5e87d06e90cc2b4cf33d562a158658

Authored by 赵旭婷
1 parent e066ca9c

新增采购入库保存

.gitignore
@@ -11,4 +11,7 @@ node_modules/ @@ -11,4 +11,7 @@ node_modules/
11 /allure-results/ 11 /allure-results/
12 /plans/ 12 /plans/
13 /reports/ 13 /reports/
14 -/screenshots/  
15 \ No newline at end of file 14 \ No newline at end of file
  15 +/screenshots/
  16 +/CLAUDE.md
  17 +/docs/
  18 +/.worktrees/
16 \ No newline at end of file 19 \ No newline at end of file
pages/purchasePage.ts
@@ -103,6 +103,9 @@ export class PurchasePage extends BasePage { @@ -103,6 +103,9 @@ export class PurchasePage extends BasePage {
103 // 图片上传 103 // 图片上传
104 readonly uploadImageButton: Locator; 104 readonly uploadImageButton: Locator;
105 105
  106 + // 保存
  107 + readonly saveButton: Locator;
  108 +
106 // 付款 109 // 付款
107 readonly payButton: Locator; 110 readonly payButton: Locator;
108 readonly settlementAccount: Locator; 111 readonly settlementAccount: Locator;
@@ -156,6 +159,9 @@ export class PurchasePage extends BasePage { @@ -156,6 +159,9 @@ export class PurchasePage extends BasePage {
156 // 图片上传 159 // 图片上传
157 this.uploadImageButton = page.getByText('图片(最多上传9张)'); 160 this.uploadImageButton = page.getByText('图片(最多上传9张)');
158 161
  162 + // 保存
  163 + this.saveButton = page.getByText('保存', { exact: true });
  164 +
159 // 付款 165 // 付款
160 this.payButton = page.getByText('付款', { exact: true }); 166 this.payButton = page.getByText('付款', { exact: true });
161 this.settlementAccount = page.locator('uni-view').filter({ hasText: /^微信支付$/ }).first(); 167 this.settlementAccount = page.locator('uni-view').filter({ hasText: /^微信支付$/ }).first();
@@ -491,6 +497,24 @@ export class PurchasePage extends BasePage { @@ -491,6 +497,24 @@ export class PurchasePage extends BasePage {
491 } 497 }
492 498
493 /** 499 /**
  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 + /**
494 * 点击付款按钮 518 * 点击付款按钮
495 */ 519 */
496 async clickPay(): Promise<void> { 520 async clickPay(): Promise<void> {
tests/purchase.spec.ts
@@ -14,7 +14,7 @@ test.describe(&#39;采购入库&#39;, () =&gt; { @@ -14,7 +14,7 @@ test.describe(&#39;采购入库&#39;, () =&gt; {
14 14
15 test('采购入库存草稿', async ({ page }, testInfo) => { 15 test('采购入库存草稿', async ({ page }, testInfo) => {
16 const purchasePage = new PurchasePage(page); 16 const purchasePage = new PurchasePage(page);
17 - 17 +
18 // 添加allure元素 18 // 添加allure元素
19 await allure.epic('仓储管理'); 19 await allure.epic('仓储管理');
20 await allure.feature('采购入库'); 20 await allure.feature('采购入库');
@@ -23,7 +23,7 @@ test.describe(&#39;采购入库&#39;, () =&gt; { @@ -23,7 +23,7 @@ test.describe(&#39;采购入库&#39;, () =&gt; {
23 // 测试数据 23 // 测试数据
24 let supplierName: string; 24 let supplierName: string;
25 let warehouseName: string; 25 let warehouseName: string;
26 - 26 +
27 let productName: string; 27 let productName: string;
28 28
29 // 步骤1:进入采购入库页面 29 // 步骤1:进入采购入库页面
@@ -85,110 +85,202 @@ test.describe(&#39;采购入库&#39;, () =&gt; { @@ -85,110 +85,202 @@ test.describe(&#39;采购入库&#39;, () =&gt; {
85 }); 85 });
86 }); 86 });
87 87
  88 + test('采购入库保存', async ({ page }, testInfo) => {
  89 + const purchasePage = new PurchasePage(page);
  90 +
  91 + // 添加allure元素
  92 + await allure.epic('仓储管理');
  93 + await allure.feature('采购入库');
  94 + await allure.story('采购入库保存');
  95 +
  96 + // 测试数据
  97 + let supplierName: string;
  98 + let warehouseName: string;
  99 + let productName: string;
  100 +
  101 + // 步骤1:进入采购入库页面
  102 + await allure.step('进入采购入库页面', async () => {
  103 + await purchasePage.openPurchaseInbound();
  104 + });
  105 +
  106 + // 步骤2:随机选择商品
  107 + await allure.step('随机选择商品', async () => {
  108 + productName = await purchasePage.selectRandomProduct();
  109 + console.log('商品:', productName);
  110 + });
  111 +
  112 + // 步骤3:输入数量
  113 + await allure.step('输入数量', async () => {
  114 + await purchasePage.enterQuantity('1');
  115 + });
  116 +
  117 + // 步骤4:输入单价
  118 + await allure.step('输入单价', async () => {
  119 + await purchasePage.enterPrice('1');
  120 + });
  121 +
  122 + // 步骤5:点击完成
  123 + await allure.step('点击完成', async () => {
  124 + await purchasePage.clickDone();
  125 + });
  126 +
  127 + // 步骤6:添加入库费用
  128 + await allure.step('添加入库费用', async () => {
  129 + await purchasePage.addExpense(0, '1');
  130 + });
  131 +
  132 + // 步骤7:随机选择供应商
  133 + await allure.step('随机选择供应商', async () => {
  134 + supplierName = await purchasePage.getRandomSupplier();
  135 + console.log('供应商:', supplierName);
  136 + });
  137 +
  138 + // 步骤8:随机选择仓库
  139 + await allure.step('随机选择仓库', async () => {
  140 + warehouseName = await purchasePage.getRandomWarehouse();
  141 + console.log('仓库:', warehouseName);
  142 + });
  143 +
  144 + // 步骤9:选择采购员
  145 + await allure.step('选择采购员', async () => {
  146 + await purchasePage.selectPurchaser();
  147 + });
  148 +
  149 + // 步骤10:输入车牌号
  150 + await allure.step('输入车牌号', async () => {
  151 + await purchasePage.enterLicensePlate('渝A99999');
  152 + });
  153 +
  154 + // 步骤11:输入备注
  155 + await allure.step('输入备注', async () => {
  156 + await purchasePage.enterRemark('自动化测试');
  157 + });
  158 +
  159 + // 步骤12:上传图片(暂时跳过)
  160 + // await allure.step('上传图片', async () => {
  161 + // await purchasePage.uploadImage('test-data/img/苹果.jpg');
  162 + // });
  163 +
  164 + // 步骤13:点击保存
  165 + await allure.step('点击保存', async () => {
  166 + await purchasePage.clickSave();
  167 + });
  168 +
  169 + // 步骤14:搜索商品
  170 + await allure.step('搜索商品', async () => {
  171 + await purchasePage.searchInPurchaseList(productName);
  172 + });
  173 +
  174 + // 步骤15:验证采购单状态为待支付
  175 + await allure.step('验证采购单状态为待支付', async () => {
  176 + await purchasePage.expectPurchaseOrderStatusPending(productName);
  177 + });
  178 + });
  179 +
88 test('采购入库付款', async ({ page }, testInfo) => { 180 test('采购入库付款', async ({ page }, testInfo) => {
89 const purchasePage = new PurchasePage(page); 181 const purchasePage = new PurchasePage(page);
90 - 182 +
91 // 添加allure元素 183 // 添加allure元素
92 await allure.epic('仓储管理'); 184 await allure.epic('仓储管理');
93 await allure.feature('采购入库'); 185 await allure.feature('采购入库');
94 await allure.story('采购入库付款'); 186 await allure.story('采购入库付款');
95 - 187 +
96 // 测试数据 188 // 测试数据
97 let supplierName: string; 189 let supplierName: string;
98 let warehouseName: string; 190 let warehouseName: string;
99 let productName: string; 191 let productName: string;
100 - 192 +
101 // 步骤1:进入采购入库页面 193 // 步骤1:进入采购入库页面
102 await allure.step('进入采购入库页面', async () => { 194 await allure.step('进入采购入库页面', async () => {
103 await purchasePage.openPurchaseInbound(); 195 await purchasePage.openPurchaseInbound();
104 }); 196 });
105 - 197 +
106 // 步骤2:随机选择商品 198 // 步骤2:随机选择商品
107 await allure.step('随机选择商品', async () => { 199 await allure.step('随机选择商品', async () => {
108 productName = await purchasePage.selectRandomProduct(); 200 productName = await purchasePage.selectRandomProduct();
109 console.log('商品:', productName); 201 console.log('商品:', productName);
110 }); 202 });
111 - 203 +
112 // 步骤3:输入数量 204 // 步骤3:输入数量
113 await allure.step('输入数量', async () => { 205 await allure.step('输入数量', async () => {
114 await purchasePage.enterQuantity('1'); 206 await purchasePage.enterQuantity('1');
115 }); 207 });
116 - 208 +
117 // 步骤4:输入单价 209 // 步骤4:输入单价
118 await allure.step('输入单价', async () => { 210 await allure.step('输入单价', async () => {
119 await purchasePage.enterPrice('1'); 211 await purchasePage.enterPrice('1');
120 }); 212 });
121 - 213 +
122 // 步骤5:点击完成 214 // 步骤5:点击完成
123 await allure.step('点击完成', async () => { 215 await allure.step('点击完成', async () => {
124 await purchasePage.clickDone(); 216 await purchasePage.clickDone();
125 }); 217 });
126 - 218 +
127 // 步骤6:添加入库费用 219 // 步骤6:添加入库费用
128 await allure.step('添加入库费用', async () => { 220 await allure.step('添加入库费用', async () => {
129 await purchasePage.addExpense(0, '1'); 221 await purchasePage.addExpense(0, '1');
130 }); 222 });
131 - 223 +
132 // 步骤7:随机选择供应商 224 // 步骤7:随机选择供应商
133 await allure.step('随机选择供应商', async () => { 225 await allure.step('随机选择供应商', async () => {
134 supplierName = await purchasePage.getRandomSupplier(); 226 supplierName = await purchasePage.getRandomSupplier();
135 console.log('供应商:', supplierName); 227 console.log('供应商:', supplierName);
136 }); 228 });
137 - 229 +
138 // 步骤8:随机选择仓库 230 // 步骤8:随机选择仓库
139 await allure.step('随机选择仓库', async () => { 231 await allure.step('随机选择仓库', async () => {
140 warehouseName = await purchasePage.getRandomWarehouse(); 232 warehouseName = await purchasePage.getRandomWarehouse();
141 console.log('仓库:', warehouseName); 233 console.log('仓库:', warehouseName);
142 }); 234 });
143 - 235 +
144 // 步骤9:选择采购员 236 // 步骤9:选择采购员
145 await allure.step('选择采购员', async () => { 237 await allure.step('选择采购员', async () => {
146 await purchasePage.selectPurchaser(); 238 await purchasePage.selectPurchaser();
147 }); 239 });
148 - 240 +
149 // 步骤10:输入车牌号 241 // 步骤10:输入车牌号
150 await allure.step('输入车牌号', async () => { 242 await allure.step('输入车牌号', async () => {
151 await purchasePage.enterLicensePlate('渝A99999'); 243 await purchasePage.enterLicensePlate('渝A99999');
152 }); 244 });
153 - 245 +
154 // 步骤11:输入备注 246 // 步骤11:输入备注
155 await allure.step('输入备注', async () => { 247 await allure.step('输入备注', async () => {
156 await purchasePage.enterRemark('自动化测试'); 248 await purchasePage.enterRemark('自动化测试');
157 }); 249 });
158 - 250 +
159 // 步骤12:上传图片(暂时跳过) 251 // 步骤12:上传图片(暂时跳过)
160 // await allure.step('上传图片', async () => { 252 // await allure.step('上传图片', async () => {
161 // await purchasePage.uploadImage('test-data/img/苹果.jpg'); 253 // await purchasePage.uploadImage('test-data/img/苹果.jpg');
162 // }); 254 // });
163 - 255 +
164 // 步骤13:点击付款 256 // 步骤13:点击付款
165 await allure.step('点击付款', async () => { 257 await allure.step('点击付款', async () => {
166 await purchasePage.clickPay(); 258 await purchasePage.clickPay();
167 }); 259 });
168 - 260 +
169 // 步骤14:选择结算账户 261 // 步骤14:选择结算账户
170 await allure.step('选择结算账户', async () => { 262 await allure.step('选择结算账户', async () => {
171 await purchasePage.selectSettlementAccount('微信支付'); 263 await purchasePage.selectSettlementAccount('微信支付');
172 }); 264 });
173 - 265 +
174 // 步骤15:确认付款 266 // 步骤15:确认付款
175 await allure.step('确认付款', async () => { 267 await allure.step('确认付款', async () => {
176 await purchasePage.confirmPayment(); 268 await purchasePage.confirmPayment();
177 }); 269 });
178 - 270 +
179 // 步骤16:进入采购列表 271 // 步骤16:进入采购列表
180 await allure.step('进入采购列表', async () => { 272 await allure.step('进入采购列表', async () => {
181 await purchasePage.goToPurchaseList(); 273 await purchasePage.goToPurchaseList();
182 }); 274 });
183 - 275 +
184 // 步骤17:搜索商品 276 // 步骤17:搜索商品
185 await allure.step('搜索商品', async () => { 277 await allure.step('搜索商品', async () => {
186 await purchasePage.searchInPurchaseList(productName); 278 await purchasePage.searchInPurchaseList(productName);
187 }); 279 });
188 - 280 +
189 // 步骤18:验证采购列表中存在该商品 281 // 步骤18:验证采购列表中存在该商品
190 await allure.step('验证采购列表中存在该商品', async () => { 282 await allure.step('验证采购列表中存在该商品', async () => {
191 await purchasePage.expectPurchaseListContainsProduct(productName); 283 await purchasePage.expectPurchaseListContainsProduct(productName);
192 }); 284 });
193 }); 285 });
194 -});  
195 \ No newline at end of file 286 \ No newline at end of file
  287 +});