Commit a744361f1f5e87d06e90cc2b4cf33d562a158658

Authored by 赵旭婷
1 parent e066ca9c

新增采购入库保存

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