Parcourir la source

test: 增加采购单列表测试

xyh il y a 2 ans
Parent
commit
8d5d4668e9

+ 82 - 0
cypress/e2e/purchase.cy.ts

@@ -0,0 +1,82 @@
+import {
+  beforeSetup,
+  generateNetworkResult,
+  intercept,
+  intoMenu,
+  validateTableList,
+  validateTableSearch,
+} from './utils';
+
+const basicData = {
+  id: '7',
+  supplierId: 'PER00556',
+  supplierName: '赵东林',
+  orderId: null,
+  orderNumber: null,
+  materialName: '清洁纸;酒精擦纸,含酒精纯度≥99.5%,300x300mm',
+  materialId: '00000000000000012033',
+  measurementId: null,
+  purchaseNum: '15',
+  arrivalNum: '1',
+  arrivalTime: '2023-04-10',
+  type: '0',
+  qualifiedNum: null,
+  disqualificationNum: null,
+  orderCode: 'CG62058902',
+  companyNumber: null,
+  compName: null,
+  wbs: null,
+  orderType: null,
+  sourceType: null,
+  entryNumber: null,
+  moveType: null,
+  page: 0,
+  limit: 0,
+  startTime: null,
+  endTime: null,
+  warehousingNum: null,
+  wllbCode: '2205010010020004',
+};
+
+describe('采购单列表', function () {
+  beforeEach(function () {
+    beforeSetup(true);
+    intoMenu('入库管理', '采购单列表');
+  });
+
+  beforeEach(function () {
+    intercept('/receiveGoods/getPurchase', function ({search, reply}) {
+      generateNetworkResult({
+        search,
+        reply,
+        basicData,
+        title: 'orderCode',
+        skipCondition: name => name === 'type',
+      });
+    });
+
+    intercept('/receiveGoods/timeoutPurchase', function ({search, reply}) {
+      generateNetworkResult({
+        search,
+        reply,
+        basicData,
+        title: 'orderCode',
+        skipCondition: name => name === 'type',
+        replaceValue: 'timeout',
+      });
+    });
+  });
+
+  it('table', function () {
+    validateTableList('purchase_order_table');
+
+    validateTableSearch(
+      'purchase_order_table',
+      ['orderCode', {id: 'type', type: 'select', value: 'timeout', eq: 1}],
+      {
+        toolId: 'purchase_filter',
+        url: '/receiveGoods/getPurchase',
+      },
+    );
+  });
+});

+ 4 - 2
cypress/e2e/utils/utils.ts

@@ -439,6 +439,7 @@ export function generateNetworkResult<
   reply: (params: StaticResponse) => void;
   title: keyof T;
   skipCondition?: (name: string) => boolean;
+  replaceValue?: string;
 }) {
   const {
     search,
@@ -446,6 +447,7 @@ export function generateNetworkResult<
     reply,
     title,
     skipCondition = () => false,
+    replaceValue,
   } = options;
 
   const page = search.get('page'),
@@ -469,7 +471,7 @@ export function generateNetworkResult<
           value:
             name === 'startTime' || name === 'endTime'
               ? 'searchTime'
-              : searchValue,
+              : replaceValue ?? searchValue,
         }),
       });
     }
@@ -486,7 +488,7 @@ export function generateNetworkResult<
       limit,
       isList: true,
       title,
-      value: `page-${page}`,
+      value: replaceValue ?? `page-${page}`,
     }),
   });
 }

+ 1 - 0
packages/app/src/pages/purchase-order/filter/index.tsx

@@ -58,6 +58,7 @@ const Filter: FC = function () {
         isSearching={isSearching}
         filterData={filterList}
         onFilter={onShowModal}
+        testId='purchase_filter'
       />
 
       <FilterSelectorModal