Commit d965ffe9065026d12e649c1e2dfcababf1200165

Authored by 赵旭婷
2 parents 99ac3e2d 0d197765

merge: purchase copy create payment feature

pages/purchasePage.ts
... ... @@ -115,6 +115,15 @@ export class PurchasePage extends BasePage {
115 115 readonly purchaseListMenu: Locator;
116 116 readonly purchaseSearchInput: Locator;
117 117  
  118 + // 复制创建
  119 + readonly copyCreateButton: Locator;
  120 +
  121 + // 货款小计
  122 + readonly subtotalField: Locator;
  123 +
  124 + // 存储温度
  125 + readonly storageTemperatureInput: Locator;
  126 +
118 127 constructor(page: Page) {
119 128 super(page);
120 129  
... ... @@ -170,6 +179,15 @@ export class PurchasePage extends BasePage {
170 179 // 采购列表
171 180 this.purchaseListMenu = page.getByText('采购列表');
172 181 this.purchaseSearchInput = page.getByRole('textbox');
  182 +
  183 + // 复制创建
  184 + this.copyCreateButton = page.getByText('复制创建');
  185 +
  186 + // 货款小计
  187 + this.subtotalField = page.locator('uni-view:nth-child(2) > .nut-cell__value > .nut-form-item__body__slots > .nut-input > .nut-input__value > .nut-input__mask');
  188 +
  189 + // 存储温度
  190 + this.storageTemperatureInput = page.locator('uni-view:nth-child(9) > .nut-cell__value > .nut-form-item__body__slots > .nut-input > .nut-input__value > .nut-input__input > .uni-input-wrapper > .uni-input-input');
173 191 }
174 192  
175 193 /**
... ... @@ -567,6 +585,43 @@ export class PurchasePage extends BasePage {
567 585 }
568 586  
569 587 /**
  588 + * 点击复制创建按钮
  589 + */
  590 + async clickCopyCreate(): Promise<void> {
  591 + await this.copyCreateButton.click();
  592 + await this.page.waitForLoadState('networkidle', { timeout: 30000 });
  593 + await this.page.waitForTimeout(1000);
  594 + }
  595 +
  596 + /**
  597 + * 点击货款小计输入框(触发键盘)
  598 + */
  599 + async clickSubtotal(): Promise<void> {
  600 + await this.subtotalField.click();
  601 + await this.page.waitForTimeout(500);
  602 + }
  603 +
  604 + /**
  605 + * 输入货款小计金额(通过数字键盘)
  606 + * @param amount 金额
  607 + */
  608 + async enterSubtotalAmount(amount: string): Promise<void> {
  609 + await this.page.locator(`.number-keyboard uni-view[data-key="${amount}"]`).click();
  610 + await this.page.waitForTimeout(300);
  611 + await this.page.getByText('完成').click();
  612 + await this.page.waitForTimeout(500);
  613 + }
  614 +
  615 + /**
  616 + * 输入存储温度
  617 + * @param value 温度值
  618 + */
  619 + async enterStorageTemperature(value: string): Promise<void> {
  620 + await this.storageTemperatureInput.click();
  621 + await this.storageTemperatureInput.fill(value);
  622 + }
  623 +
  624 + /**
570 625 * 在采购列表搜索商品
571 626 * @param productName 商品名称
572 627 */
... ... @@ -583,6 +638,15 @@ export class PurchasePage extends BasePage {
583 638 }
584 639  
585 640 /**
  641 + * 清除采购列表搜索框内容
  642 + */
  643 + async clearSearchInPurchaseList(): Promise<void> {
  644 + const searchInput = this.page.locator('uni-input').filter({ hasText: '供应商/商品名称' }).locator('input[type="text"]');
  645 + await searchInput.clear();
  646 + await this.page.waitForTimeout(500);
  647 + }
  648 +
  649 + /**
586 650 * 验证采购列表中存在商品
587 651 * @param productName 商品名称
588 652 */
... ...
tests/purchase.spec.ts
... ... @@ -411,4 +411,128 @@ test.describe(&#39;采购入库&#39;, () =&gt; {
411 411 await purchasePage.expectPurchaseOrderStatusPaid();
412 412 });
413 413 });
  414 +
  415 + test('采购单复制创建付款', async ({ page }, testInfo) => {
  416 + const purchasePage = new PurchasePage(page);
  417 +
  418 + // 添加allure元素
  419 + await allure.epic('仓储管理');
  420 + await allure.feature('采购入库');
  421 + await allure.story('采购单复制创建付款');
  422 +
  423 + // 测试数据
  424 + let supplierName: string;
  425 + let warehouseName: string;
  426 + let productName: string;
  427 +
  428 + // 步骤1:进入采购入库页面
  429 + await allure.step('进入采购入库页面', async () => {
  430 + await purchasePage.openPurchaseInbound();
  431 + });
  432 +
  433 + // 步骤2:随机选择商品
  434 + await allure.step('随机选择商品', async () => {
  435 + productName = await purchasePage.selectRandomProduct();
  436 + console.log('商品:', productName);
  437 + });
  438 +
  439 + // 步骤3:输入数量
  440 + await allure.step('输入数量', async () => {
  441 + await purchasePage.enterQuantity('1');
  442 + });
  443 +
  444 + // 步骤4:输入单价
  445 + await allure.step('输入单价', async () => {
  446 + await purchasePage.enterPrice('1');
  447 + });
  448 +
  449 + // 步骤5:点击完成
  450 + await allure.step('点击完成', async () => {
  451 + await purchasePage.clickDone();
  452 + });
  453 +
  454 + // 步骤6:随机选择供应商
  455 + await allure.step('随机选择供应商', async () => {
  456 + supplierName = await purchasePage.getRandomSupplier();
  457 + console.log('供应商:', supplierName);
  458 + });
  459 +
  460 + // 步骤7:随机选择仓库
  461 + await allure.step('随机选择仓库', async () => {
  462 + warehouseName = await purchasePage.getRandomWarehouse();
  463 + console.log('仓库:', warehouseName);
  464 + });
  465 +
  466 + // 步骤8:点击保存
  467 + await allure.step('点击保存', async () => {
  468 + await purchasePage.clickSave();
  469 + });
  470 +
  471 + // 步骤9:搜索商品
  472 + await allure.step('搜索商品', async () => {
  473 + await purchasePage.searchInPurchaseList(productName);
  474 + });
  475 +
  476 + // 步骤10:点击复制创建
  477 + await allure.step('点击复制创建', async () => {
  478 + await purchasePage.clickCopyCreate();
  479 + });
  480 +
  481 + // 步骤11:点击货款小计并输入
  482 + await allure.step('点击货款小计并输入金额', async () => {
  483 + await purchasePage.clickSubtotal();
  484 + await purchasePage.enterSubtotalAmount('1');
  485 + });
  486 +
  487 + // 步骤12:添加入库费用
  488 + await allure.step('添加入库费用', async () => {
  489 + await purchasePage.addExpense(0, '1');
  490 + });
  491 +
  492 + // 步骤13:输入存储温度
  493 + await allure.step('输入存储温度', async () => {
  494 + await purchasePage.enterStorageTemperature('6');
  495 + });
  496 +
  497 + // 步骤14:选择采购员
  498 + await allure.step('选择采购员', async () => {
  499 + await purchasePage.selectPurchaser();
  500 + });
  501 +
  502 + // 步骤15:输入车牌号
  503 + await allure.step('输入车牌号', async () => {
  504 + await purchasePage.enterLicensePlate('渝YUNI99');
  505 + });
  506 +
  507 + // 步骤16:输入备注
  508 + await allure.step('输入备注', async () => {
  509 + await purchasePage.enterRemark('1111111');
  510 + });
  511 +
  512 + // 步骤17:点击付款
  513 + await allure.step('点击付款', async () => {
  514 + await purchasePage.clickPay();
  515 + });
  516 +
  517 + // 步骤18:选择结算账户
  518 + await allure.step('选择结算账户', async () => {
  519 + await purchasePage.selectSettlementAccount('微信支付');
  520 + });
  521 +
  522 + // 步骤19:确认付款
  523 + await allure.step('确认付款', async () => {
  524 + await purchasePage.confirmPayment();
  525 + });
  526 +
  527 + // 步骤20:清除搜索结果并重新搜索
  528 + await allure.step('清除搜索结果并重新搜索', async () => {
  529 + await purchasePage.clearSearchInPurchaseList();
  530 + await purchasePage.searchInPurchaseList(productName);
  531 + });
  532 +
  533 + // 步骤21:验证采购单状态为已支付
  534 + await allure.step('验证采购单状态为已支付', async () => {
  535 + await purchasePage.expectPurchaseOrderStatusPaid();
  536 + });
  537 + });
414 538 });
415 539 \ No newline at end of file
... ...