Commit 4675d8dc1ca4dd447b210439e29fd32d938cdbfd
1 parent
14eb0ef2
新增采购单撤销、采购单取消
Showing
2 changed files
with
255 additions
and
0 deletions
pages/purchasePage.ts
| @@ -134,6 +134,13 @@ export class PurchasePage extends BasePage { | @@ -134,6 +134,13 @@ export class PurchasePage extends BasePage { | ||
| 134 | readonly batchAliasInput: Locator; | 134 | readonly batchAliasInput: Locator; |
| 135 | readonly batchAliasClearIcon: Locator; | 135 | readonly batchAliasClearIcon: Locator; |
| 136 | 136 | ||
| 137 | + // 取消 | ||
| 138 | + readonly cancelButton: Locator; | ||
| 139 | + readonly cancelConfirmButton: Locator; | ||
| 140 | + | ||
| 141 | + // 撤销 | ||
| 142 | + readonly revokeButton: Locator; | ||
| 143 | + | ||
| 137 | constructor(page: Page) { | 144 | constructor(page: Page) { |
| 138 | super(page); | 145 | super(page); |
| 139 | 146 | ||
| @@ -208,6 +215,13 @@ export class PurchasePage extends BasePage { | @@ -208,6 +215,13 @@ export class PurchasePage extends BasePage { | ||
| 208 | // 批次别名 | 215 | // 批次别名 |
| 209 | this.batchAliasInput = page.locator('uni-view:nth-child(8) > .nut-cell__value > .nut-form-item__body__slots > .nut-input > .nut-input__value > .nut-input__input > .uni-input-wrapper > .uni-input-input'); | 216 | this.batchAliasInput = page.locator('uni-view:nth-child(8) > .nut-cell__value > .nut-form-item__body__slots > .nut-input > .nut-input__value > .nut-input__input > .uni-input-wrapper > .uni-input-input'); |
| 210 | this.batchAliasClearIcon = page.locator('uni-view:nth-child(8) > .nut-cell__value > .nut-form-item__body__slots > .nut-input > .nut-input__clear > .nut-input__clear-icon'); | 217 | this.batchAliasClearIcon = page.locator('uni-view:nth-child(8) > .nut-cell__value > .nut-form-item__body__slots > .nut-input > .nut-input__clear > .nut-input__clear-icon'); |
| 218 | + | ||
| 219 | + // 取消 | ||
| 220 | + this.cancelButton = page.getByText('取消', { exact: true }); | ||
| 221 | + this.cancelConfirmButton = page.getByText('确定', { exact: true }); | ||
| 222 | + | ||
| 223 | + // 撤销 | ||
| 224 | + this.revokeButton = page.getByText('撤销', { exact: true }); | ||
| 211 | } | 225 | } |
| 212 | 226 | ||
| 213 | /** | 227 | /** |
| @@ -436,6 +450,46 @@ export class PurchasePage extends BasePage { | @@ -436,6 +450,46 @@ export class PurchasePage extends BasePage { | ||
| 436 | } | 450 | } |
| 437 | 451 | ||
| 438 | /** | 452 | /** |
| 453 | + * 点击取消按钮 | ||
| 454 | + */ | ||
| 455 | + async clickCancelButton(): Promise<void> { | ||
| 456 | + await this.cancelButton.click(); | ||
| 457 | + await this.page.waitForTimeout(500); | ||
| 458 | + } | ||
| 459 | + | ||
| 460 | + /** | ||
| 461 | + * 确认取消弹窗 | ||
| 462 | + */ | ||
| 463 | + async confirmCancelDialog(): Promise<void> { | ||
| 464 | + await this.cancelConfirmButton.click(); | ||
| 465 | + await this.page.waitForTimeout(1000); | ||
| 466 | + } | ||
| 467 | + | ||
| 468 | + /** | ||
| 469 | + * 点击撤销按钮 | ||
| 470 | + */ | ||
| 471 | + async clickRevokeButton(): Promise<void> { | ||
| 472 | + await this.revokeButton.click(); | ||
| 473 | + await this.page.waitForTimeout(500); | ||
| 474 | + } | ||
| 475 | + | ||
| 476 | + /** | ||
| 477 | + * 验证采购单状态为已取消 | ||
| 478 | + */ | ||
| 479 | + async expectPurchaseOrderStatusCancelled(): Promise<void> { | ||
| 480 | + const statusLabel = this.page.locator('uni-text').filter({ hasText: '已取消' }).first(); | ||
| 481 | + await expect(statusLabel).toBeVisible({ timeout: 10000 }); | ||
| 482 | + } | ||
| 483 | + | ||
| 484 | + /** | ||
| 485 | + * 验证采购单状态为已撤销 | ||
| 486 | + */ | ||
| 487 | + async expectPurchaseOrderStatusRevoked(): Promise<void> { | ||
| 488 | + const statusLabel = this.page.locator('uni-text').filter({ hasText: '已撤销' }).first(); | ||
| 489 | + await expect(statusLabel).toBeVisible({ timeout: 10000 }); | ||
| 490 | + } | ||
| 491 | + | ||
| 492 | + /** | ||
| 439 | * 创建采购入库草稿(完整流程) | 493 | * 创建采购入库草稿(完整流程) |
| 440 | * @param productName 商品名称 | 494 | * @param productName 商品名称 |
| 441 | * @param supplierName 供应商名称 | 495 | * @param supplierName 供应商名称 |
tests/purchase.spec.ts
| @@ -670,4 +670,205 @@ test.describe('采购入库', () => { | @@ -670,4 +670,205 @@ test.describe('采购入库', () => { | ||
| 670 | await purchasePage.expectPurchaseListContainsProduct(productName); | 670 | await purchasePage.expectPurchaseListContainsProduct(productName); |
| 671 | }); | 671 | }); |
| 672 | }); | 672 | }); |
| 673 | + | ||
| 674 | + test('采购单取消', async ({ page }, testInfo) => { | ||
| 675 | + const purchasePage = new PurchasePage(page); | ||
| 676 | + | ||
| 677 | + // 添加allure元素 | ||
| 678 | + await allure.epic('仓储管理'); | ||
| 679 | + await allure.feature('采购入库'); | ||
| 680 | + await allure.story('采购单取消'); | ||
| 681 | + | ||
| 682 | + // 测试数据 | ||
| 683 | + let supplierName: string; | ||
| 684 | + let warehouseName: string; | ||
| 685 | + let productName: string; | ||
| 686 | + | ||
| 687 | + // 步骤1:进入采购入库页面 | ||
| 688 | + await allure.step('进入采购入库页面', async () => { | ||
| 689 | + await purchasePage.openPurchaseInbound(); | ||
| 690 | + }); | ||
| 691 | + | ||
| 692 | + // 步骤2:随机选择商品 | ||
| 693 | + await allure.step('随机选择商品', async () => { | ||
| 694 | + productName = await purchasePage.selectRandomProduct(); | ||
| 695 | + console.log('商品:', productName); | ||
| 696 | + }); | ||
| 697 | + | ||
| 698 | + // 步骤3:输入数量 | ||
| 699 | + await allure.step('输入数量', async () => { | ||
| 700 | + await purchasePage.enterQuantity('1'); | ||
| 701 | + }); | ||
| 702 | + | ||
| 703 | + // 步骤4:输入单价 | ||
| 704 | + await allure.step('输入单价', async () => { | ||
| 705 | + await purchasePage.enterPrice('1'); | ||
| 706 | + }); | ||
| 707 | + | ||
| 708 | + // 步骤5:点击完成 | ||
| 709 | + await allure.step('点击完成', async () => { | ||
| 710 | + await purchasePage.clickDone(); | ||
| 711 | + }); | ||
| 712 | + | ||
| 713 | + // 步骤6:随机选择供应商 | ||
| 714 | + await allure.step('随机选择供应商', async () => { | ||
| 715 | + supplierName = await purchasePage.getRandomSupplier(); | ||
| 716 | + console.log('供应商:', supplierName); | ||
| 717 | + }); | ||
| 718 | + | ||
| 719 | + // 步骤7:随机选择仓库 | ||
| 720 | + await allure.step('随机选择仓库', async () => { | ||
| 721 | + warehouseName = await purchasePage.getRandomWarehouse(); | ||
| 722 | + console.log('仓库:', warehouseName); | ||
| 723 | + }); | ||
| 724 | + | ||
| 725 | + // 步骤8:点击保存 | ||
| 726 | + await allure.step('点击保存', async () => { | ||
| 727 | + await purchasePage.clickSave(); | ||
| 728 | + }); | ||
| 729 | + | ||
| 730 | + // 步骤9:搜索商品 | ||
| 731 | + await allure.step('搜索商品', async () => { | ||
| 732 | + await purchasePage.searchInPurchaseList(productName); | ||
| 733 | + }); | ||
| 734 | + | ||
| 735 | + // 步骤10:点击取消按钮 | ||
| 736 | + await allure.step('点击取消按钮', async () => { | ||
| 737 | + await purchasePage.clickCancelButton(); | ||
| 738 | + }); | ||
| 739 | + | ||
| 740 | + // 步骤11:确认取消弹窗 | ||
| 741 | + await allure.step('确认取消弹窗', async () => { | ||
| 742 | + await purchasePage.confirmCancelDialog(); | ||
| 743 | + }); | ||
| 744 | + | ||
| 745 | + // 步骤12:清除搜索框并重新搜索商品 | ||
| 746 | + await allure.step('清除搜索并重新搜索', async () => { | ||
| 747 | + await purchasePage.clearSearchInPurchaseList(); | ||
| 748 | + await purchasePage.searchInPurchaseList(productName); | ||
| 749 | + }); | ||
| 750 | + | ||
| 751 | + // 步骤13:验证采购单状态为已取消 | ||
| 752 | + await allure.step('验证采购单状态为已取消', async () => { | ||
| 753 | + await purchasePage.expectPurchaseOrderStatusCancelled(); | ||
| 754 | + }); | ||
| 755 | + }); | ||
| 756 | + | ||
| 757 | + test('采购单撤销', async ({ page }, testInfo) => { | ||
| 758 | + const purchasePage = new PurchasePage(page); | ||
| 759 | + | ||
| 760 | + // 添加allure元素 | ||
| 761 | + await allure.epic('仓储管理'); | ||
| 762 | + await allure.feature('采购入库'); | ||
| 763 | + await allure.story('采购单撤销'); | ||
| 764 | + | ||
| 765 | + // 测试数据 | ||
| 766 | + let supplierName: string; | ||
| 767 | + let warehouseName: string; | ||
| 768 | + let productName: string; | ||
| 769 | + | ||
| 770 | + // 步骤1:进入采购入库页面 | ||
| 771 | + await allure.step('进入采购入库页面', async () => { | ||
| 772 | + await purchasePage.openPurchaseInbound(); | ||
| 773 | + }); | ||
| 774 | + | ||
| 775 | + // 步骤2:随机选择商品 | ||
| 776 | + await allure.step('随机选择商品', async () => { | ||
| 777 | + productName = await purchasePage.selectRandomProduct(); | ||
| 778 | + console.log('商品:', productName); | ||
| 779 | + }); | ||
| 780 | + | ||
| 781 | + // 步骤3:输入数量 | ||
| 782 | + await allure.step('输入数量', async () => { | ||
| 783 | + await purchasePage.enterQuantity('1'); | ||
| 784 | + }); | ||
| 785 | + | ||
| 786 | + // 步骤4:输入单价 | ||
| 787 | + await allure.step('输入单价', async () => { | ||
| 788 | + await purchasePage.enterPrice('1'); | ||
| 789 | + }); | ||
| 790 | + | ||
| 791 | + // 步骤5:点击完成 | ||
| 792 | + await allure.step('点击完成', async () => { | ||
| 793 | + await purchasePage.clickDone(); | ||
| 794 | + }); | ||
| 795 | + | ||
| 796 | + // 步骤6:添加入库费用 | ||
| 797 | + await allure.step('添加入库费用', async () => { | ||
| 798 | + await purchasePage.addExpense(0, '1'); | ||
| 799 | + }); | ||
| 800 | + | ||
| 801 | + // 步骤7:随机选择供应商 | ||
| 802 | + await allure.step('随机选择供应商', async () => { | ||
| 803 | + supplierName = await purchasePage.getRandomSupplier(); | ||
| 804 | + console.log('供应商:', supplierName); | ||
| 805 | + }); | ||
| 806 | + | ||
| 807 | + // 步骤8:随机选择仓库 | ||
| 808 | + await allure.step('随机选择仓库', async () => { | ||
| 809 | + warehouseName = await purchasePage.getRandomWarehouse(); | ||
| 810 | + console.log('仓库:', warehouseName); | ||
| 811 | + }); | ||
| 812 | + | ||
| 813 | + // 步骤9:选择采购员 | ||
| 814 | + await allure.step('选择采购员', async () => { | ||
| 815 | + await purchasePage.selectPurchaser(); | ||
| 816 | + }); | ||
| 817 | + | ||
| 818 | + // 步骤10:输入车牌号 | ||
| 819 | + await allure.step('输入车牌号', async () => { | ||
| 820 | + await purchasePage.enterLicensePlate('渝YUNI99'); | ||
| 821 | + }); | ||
| 822 | + | ||
| 823 | + // 步骤11:输入备注 | ||
| 824 | + await allure.step('输入备注', async () => { | ||
| 825 | + await purchasePage.enterRemark('自动化测试'); | ||
| 826 | + }); | ||
| 827 | + | ||
| 828 | + // 步骤12:点击付款 | ||
| 829 | + await allure.step('点击付款', async () => { | ||
| 830 | + await purchasePage.clickPay(); | ||
| 831 | + }); | ||
| 832 | + | ||
| 833 | + // 步骤13:选择结算账户 | ||
| 834 | + await allure.step('选择结算账户', async () => { | ||
| 835 | + await purchasePage.selectSettlementAccount('微信支付'); | ||
| 836 | + }); | ||
| 837 | + | ||
| 838 | + // 步骤14:确认付款 | ||
| 839 | + await allure.step('确认付款', async () => { | ||
| 840 | + await purchasePage.confirmPayment(); | ||
| 841 | + }); | ||
| 842 | + | ||
| 843 | + // 步骤15:进入采购列表 | ||
| 844 | + await allure.step('进入采购列表', async () => { | ||
| 845 | + await purchasePage.goToPurchaseList(); | ||
| 846 | + }); | ||
| 847 | + | ||
| 848 | + // 步骤16:搜索商品 | ||
| 849 | + await allure.step('搜索商品', async () => { | ||
| 850 | + await purchasePage.searchInPurchaseList(productName); | ||
| 851 | + }); | ||
| 852 | + | ||
| 853 | + // 步骤17:点击撤销按钮 | ||
| 854 | + await allure.step('点击撤销按钮', async () => { | ||
| 855 | + await purchasePage.clickRevokeButton(); | ||
| 856 | + }); | ||
| 857 | + | ||
| 858 | + // 步骤18:确认撤销弹窗 | ||
| 859 | + await allure.step('确认撤销弹窗', async () => { | ||
| 860 | + await purchasePage.confirmCancelDialog(); | ||
| 861 | + }); | ||
| 862 | + | ||
| 863 | + // 步骤19:清除搜索并重新搜索商品 | ||
| 864 | + await allure.step('清除搜索并重新搜索', async () => { | ||
| 865 | + await purchasePage.clearSearchInPurchaseList(); | ||
| 866 | + await purchasePage.searchInPurchaseList(productName); | ||
| 867 | + }); | ||
| 868 | + | ||
| 869 | + // 步骤20:验证采购单状态为已撤销 | ||
| 870 | + await allure.step('验证采购单状态为已撤销', async () => { | ||
| 871 | + await purchasePage.expectPurchaseOrderStatusRevoked(); | ||
| 872 | + }); | ||
| 873 | + }); | ||
| 673 | }); | 874 | }); |
| 674 | \ No newline at end of file | 875 | \ No newline at end of file |