Browse Source

test: 添加库位管理测试

xyh 2 years ago
parent
commit
f94d71d17e

+ 143 - 0
cypress/e2e/storage.cy.ts

@@ -0,0 +1,143 @@
+import {
+  beforeSetup,
+  exportIntercept,
+  generateNetworkResult,
+  intercept,
+  intoMenu,
+  selectAllFilters,
+  successIntercept,
+  validateDelete,
+  validatePut,
+  validateTableList,
+  validateTableSearch,
+} from './utils';
+
+const basicData = {
+  id: '734',
+  storageLocationCode: 'D6-3-51',
+  storageLocationName: 'D6-3-51',
+  warehouseWhere: 'e7f6bff1-e6ab-49e7-9',
+  storageLocationType: '包装类',
+  materialName: '包装类',
+  materialId: null,
+  storageLocationCapacity: null,
+  isNotDisable: '1',
+  isProduct: '1',
+  wareHouseName: '充电设备事业部原材料库',
+  tldId: 'e7f6bff1-e6ab-49e7-9',
+  createTime: '2023-04-11 14:32:59',
+  modifyUser: 'admin',
+  modifyTime: '2023-04-11 14:32:59',
+  materialTypeId: null,
+  page: 0,
+  limit: 0,
+};
+
+const TABLE_NAME = 'storage_table';
+
+describe('库位管理', function () {
+  beforeEach(function () {
+    beforeSetup(true);
+    intoMenu('基础资料', '库位管理');
+  });
+
+  beforeEach(function () {
+    intercept('/storage/getStorage', function ({search, reply}) {
+      generateNetworkResult({
+        search,
+        reply,
+        basicData,
+        title: 'storageLocationCode',
+      });
+    });
+
+    exportIntercept('/storage/export');
+    successIntercept([
+      '/storage/addStorage',
+      '/storage/updateStorage',
+      '/storage/delStorage',
+    ]);
+  });
+
+  it('table', function () {
+    selectAllFilters('storage_filter', 7);
+    validateTableList(TABLE_NAME);
+
+    validateTableSearch(
+      TABLE_NAME,
+      [
+        'storageLocationName',
+        'storageLocationCode',
+        {id: 'warehouseWhere', type: 'select', value: '2bdf33b8-4326-47e8-b'},
+        {
+          id: 'storageLocationType',
+          type: 'select',
+          value: '危化品',
+        },
+        {
+          id: 'isNotDisable',
+          type: 'select',
+          value: '1',
+          eq: 1,
+        },
+        {
+          id: 'isProduct',
+          type: 'select',
+          value: '1',
+          eq: 1,
+        },
+        'modifyUser',
+      ],
+      {toolId: 'storage_filter', url: '/storage/getStorage'},
+    );
+  });
+
+  it('operation', function () {
+    const {validateAdd, validateEdit} = validatePut(
+      'storage_modal',
+      TABLE_NAME,
+      {
+        label: '库位',
+      },
+    );
+
+    validateAdd([
+      'storageLocationCode',
+      'storageLocationName',
+      {id: 'storageWarehouse', type: 'select'},
+      {id: 'storageIsNotDisable', type: 'select'},
+      {id: 'storageIsProduct', type: 'select'},
+      {id: 'storageMaterialType', type: 'select'},
+    ]);
+
+    validateEdit([
+      {
+        id: 'storageLocationCode',
+        value: basicData.storageLocationCode,
+        type: 'field',
+      },
+      {
+        id: 'storageLocationName',
+        value: basicData.storageLocationName,
+        type: 'field',
+      },
+      {
+        id: 'storageWarehouse',
+        value: basicData.wareHouseName,
+        type: 'select',
+      },
+      {
+        id: 'storageIsNotDisable',
+        value: '是',
+        type: 'select',
+      },
+      {
+        id: 'storageIsProduct',
+        value: '是',
+        type: 'select',
+      },
+    ]);
+
+    validateDelete(TABLE_NAME, '库位', {title: 'D6-3-51'});
+  });
+});

+ 4 - 0
cypress/e2e/utils/setup.ts

@@ -51,6 +51,10 @@ export function dictionaryIntercept() {
     switch (type) {
       case '部门字典':
         return reply({fixture: 'dictonary/department'});
+      case '物料类型':
+        return reply({fixture: 'dictonary/materialType'});
+      case '仓库':
+        return reply({fixture: 'dictonary/warehouse'});
     }
   });
 }

+ 6 - 3
cypress/e2e/utils/utils.ts

@@ -61,7 +61,10 @@ export function validateTableList(tableName: string) {
 /** 校验table search */
 export function validateTableSearch(
   tableName: string,
-  keys: ({id: string; type: 'select' | 'date'; value?: string} | string)[],
+  keys: (
+    | {id: string; type: 'select' | 'date'; value?: string; eq?: number}
+    | string
+  )[],
   options: {
     toolId: string;
     url: string;
@@ -83,7 +86,7 @@ export function validateTableSearch(
 
         if (type === 'select') {
           cy.getTestId(toolId)
-            .getTestId(`filter_${id}`)
+            .find(`[data-testid="filter_${id}"]`)
             .trigger('mouseover')
             .find('.ant-select-clear')
             .click();
@@ -136,7 +139,7 @@ export function validateTableSearch(
       const {id, type, value} = key;
 
       if (type === 'select') {
-        selectClick(`filter_${id}`, 0);
+        selectClick(`filter_${id}`, key?.eq ?? 0);
         validate(value);
       }
     }

File diff suppressed because it is too large
+ 4732 - 0
cypress/fixtures/dictonary/materialType.json


+ 382 - 0
cypress/fixtures/dictonary/warehouse.json

@@ -0,0 +1,382 @@
+{
+  "msg": "200",
+  "data": [
+    {
+      "id": "11",
+      "code": "1090",
+      "name": "充电设备事业部销售库",
+      "tldId": "2bdf33b8-4326-47e8-b",
+      "specificationAndModel": null,
+      "unitOfMeasurement": null,
+      "materialId": null,
+      "num": null,
+      "type": null,
+      "tableName": null,
+      "size": null,
+      "materialType": null,
+      "wllbClass": null,
+      "isNotDisable": null,
+      "isRecommend": null,
+      "partType": null,
+      "page": 0,
+      "limit": 0,
+      "amount": null,
+      "minNum": null,
+      "maxNum": null,
+      "modifyUser": null,
+      "modifyTime": null,
+      "typeVal": null,
+      "companyNumber": null,
+      "warehouseType": null,
+      "nameOrCode": null
+    },
+    {
+      "id": "12",
+      "code": "7000",
+      "name": "充电设备事业部直发库",
+      "tldId": "535b71ef-107b-4e6e-8",
+      "specificationAndModel": null,
+      "unitOfMeasurement": null,
+      "materialId": null,
+      "num": null,
+      "type": null,
+      "tableName": null,
+      "size": null,
+      "materialType": null,
+      "wllbClass": null,
+      "isNotDisable": null,
+      "isRecommend": null,
+      "partType": null,
+      "page": 0,
+      "limit": 0,
+      "amount": null,
+      "minNum": null,
+      "maxNum": null,
+      "modifyUser": null,
+      "modifyTime": null,
+      "typeVal": null,
+      "companyNumber": null,
+      "warehouseType": null,
+      "nameOrCode": null
+    },
+    {
+      "id": "13",
+      "code": "5000",
+      "name": "充电设备事业部借件库",
+      "tldId": "6062e900-b3f0-4a5a-b",
+      "specificationAndModel": null,
+      "unitOfMeasurement": null,
+      "materialId": null,
+      "num": null,
+      "type": null,
+      "tableName": null,
+      "size": null,
+      "materialType": null,
+      "wllbClass": null,
+      "isNotDisable": null,
+      "isRecommend": null,
+      "partType": null,
+      "page": 0,
+      "limit": 0,
+      "amount": null,
+      "minNum": null,
+      "maxNum": null,
+      "modifyUser": null,
+      "modifyTime": null,
+      "typeVal": null,
+      "companyNumber": null,
+      "warehouseType": null,
+      "nameOrCode": null
+    },
+    {
+      "id": "14",
+      "code": "4000",
+      "name": "充电设备事业部返修库",
+      "tldId": "688a9467-18e6-4f32-b",
+      "specificationAndModel": null,
+      "unitOfMeasurement": null,
+      "materialId": null,
+      "num": null,
+      "type": null,
+      "tableName": null,
+      "size": null,
+      "materialType": null,
+      "wllbClass": null,
+      "isNotDisable": null,
+      "isRecommend": null,
+      "partType": null,
+      "page": 0,
+      "limit": 0,
+      "amount": null,
+      "minNum": null,
+      "maxNum": null,
+      "modifyUser": null,
+      "modifyTime": null,
+      "typeVal": null,
+      "companyNumber": null,
+      "warehouseType": null,
+      "nameOrCode": null
+    },
+    {
+      "id": "15",
+      "code": "2010",
+      "name": "充电设备事业部金工原材料库",
+      "tldId": "6dacc1e8-d391-4c97-8",
+      "specificationAndModel": null,
+      "unitOfMeasurement": null,
+      "materialId": null,
+      "num": null,
+      "type": "0",
+      "tableName": null,
+      "size": null,
+      "materialType": null,
+      "wllbClass": null,
+      "isNotDisable": null,
+      "isRecommend": null,
+      "partType": null,
+      "page": 0,
+      "limit": 0,
+      "amount": null,
+      "minNum": null,
+      "maxNum": null,
+      "modifyUser": null,
+      "modifyTime": null,
+      "typeVal": null,
+      "companyNumber": null,
+      "warehouseType": "0",
+      "nameOrCode": null
+    },
+    {
+      "id": "16",
+      "code": "9000",
+      "name": "充电设备事业部寄售库",
+      "tldId": "96bf8349-35e9-446e-a",
+      "specificationAndModel": null,
+      "unitOfMeasurement": null,
+      "materialId": null,
+      "num": null,
+      "type": null,
+      "tableName": null,
+      "size": null,
+      "materialType": null,
+      "wllbClass": null,
+      "isNotDisable": null,
+      "isRecommend": null,
+      "partType": null,
+      "page": 0,
+      "limit": 0,
+      "amount": null,
+      "minNum": null,
+      "maxNum": null,
+      "modifyUser": null,
+      "modifyTime": null,
+      "typeVal": null,
+      "companyNumber": null,
+      "warehouseType": null,
+      "nameOrCode": null
+    },
+    {
+      "id": "17",
+      "code": "1020",
+      "name": "充电设备事业部金工半成品库",
+      "tldId": "a031bb4f-3eb6-49df-9",
+      "specificationAndModel": null,
+      "unitOfMeasurement": null,
+      "materialId": null,
+      "num": null,
+      "type": "0",
+      "tableName": null,
+      "size": null,
+      "materialType": null,
+      "wllbClass": null,
+      "isNotDisable": null,
+      "isRecommend": null,
+      "partType": null,
+      "page": 0,
+      "limit": 0,
+      "amount": null,
+      "minNum": null,
+      "maxNum": null,
+      "modifyUser": null,
+      "modifyTime": null,
+      "typeVal": null,
+      "companyNumber": null,
+      "warehouseType": "1",
+      "nameOrCode": null
+    },
+    {
+      "id": "18",
+      "code": "6000",
+      "name": "充电设备事业部备品备件库",
+      "tldId": "a37a795d-07a7-4f97-9",
+      "specificationAndModel": null,
+      "unitOfMeasurement": null,
+      "materialId": null,
+      "num": null,
+      "type": null,
+      "tableName": null,
+      "size": null,
+      "materialType": null,
+      "wllbClass": null,
+      "isNotDisable": null,
+      "isRecommend": null,
+      "partType": null,
+      "page": 0,
+      "limit": 0,
+      "amount": null,
+      "minNum": null,
+      "maxNum": null,
+      "modifyUser": null,
+      "modifyTime": null,
+      "typeVal": null,
+      "companyNumber": null,
+      "warehouseType": null,
+      "nameOrCode": null
+    },
+    {
+      "id": "19",
+      "code": "4010",
+      "name": "充电设备事业部返修供应商库",
+      "tldId": "aa70a5a8-ee6b-4b4f-b",
+      "specificationAndModel": null,
+      "unitOfMeasurement": null,
+      "materialId": null,
+      "num": null,
+      "type": null,
+      "tableName": null,
+      "size": null,
+      "materialType": null,
+      "wllbClass": null,
+      "isNotDisable": null,
+      "isRecommend": null,
+      "partType": null,
+      "page": 0,
+      "limit": 0,
+      "amount": null,
+      "minNum": null,
+      "maxNum": null,
+      "modifyUser": null,
+      "modifyTime": null,
+      "typeVal": null,
+      "companyNumber": null,
+      "warehouseType": null,
+      "nameOrCode": null
+    },
+    {
+      "id": "20",
+      "code": "3000",
+      "name": "充电设备事业部车间库",
+      "tldId": "c5bf9636-881c-4463-b",
+      "specificationAndModel": null,
+      "unitOfMeasurement": null,
+      "materialId": null,
+      "num": null,
+      "type": null,
+      "tableName": null,
+      "size": null,
+      "materialType": null,
+      "wllbClass": null,
+      "isNotDisable": null,
+      "isRecommend": null,
+      "partType": null,
+      "page": 0,
+      "limit": 0,
+      "amount": null,
+      "minNum": null,
+      "maxNum": null,
+      "modifyUser": null,
+      "modifyTime": null,
+      "typeVal": null,
+      "companyNumber": null,
+      "warehouseType": "",
+      "nameOrCode": null
+    },
+    {
+      "id": "21",
+      "code": "1010",
+      "name": "充电设备事业部电气半成品库",
+      "tldId": "d7f30912-8d52-47e3-b",
+      "specificationAndModel": null,
+      "unitOfMeasurement": null,
+      "materialId": null,
+      "num": null,
+      "type": "0",
+      "tableName": null,
+      "size": null,
+      "materialType": null,
+      "wllbClass": null,
+      "isNotDisable": null,
+      "isRecommend": null,
+      "partType": null,
+      "page": 0,
+      "limit": 0,
+      "amount": null,
+      "minNum": null,
+      "maxNum": null,
+      "modifyUser": null,
+      "modifyTime": null,
+      "typeVal": null,
+      "companyNumber": null,
+      "warehouseType": "1",
+      "nameOrCode": null
+    },
+    {
+      "id": "22",
+      "code": "2000",
+      "name": "充电设备事业部原材料库",
+      "tldId": "e7f6bff1-e6ab-49e7-9",
+      "specificationAndModel": null,
+      "unitOfMeasurement": null,
+      "materialId": null,
+      "num": null,
+      "type": "0",
+      "tableName": null,
+      "size": null,
+      "materialType": null,
+      "wllbClass": null,
+      "isNotDisable": null,
+      "isRecommend": null,
+      "partType": null,
+      "page": 0,
+      "limit": 0,
+      "amount": null,
+      "minNum": null,
+      "maxNum": null,
+      "modifyUser": null,
+      "modifyTime": null,
+      "typeVal": null,
+      "companyNumber": null,
+      "warehouseType": "0",
+      "nameOrCode": null
+    },
+    {
+      "id": "23",
+      "code": "1000",
+      "name": "充电设备事业部成品库",
+      "tldId": "fa4e9d0a-8dac-4d8d-9",
+      "specificationAndModel": null,
+      "unitOfMeasurement": null,
+      "materialId": null,
+      "num": null,
+      "type": "0",
+      "tableName": null,
+      "size": null,
+      "materialType": null,
+      "wllbClass": null,
+      "isNotDisable": null,
+      "isRecommend": null,
+      "partType": null,
+      "page": 0,
+      "limit": 0,
+      "amount": null,
+      "minNum": null,
+      "maxNum": null,
+      "modifyUser": null,
+      "modifyTime": null,
+      "typeVal": null,
+      "companyNumber": null,
+      "warehouseType": "2",
+      "nameOrCode": null
+    }
+  ]
+}

+ 4 - 0
packages/app/src/components/filter-field/Select.tsx

@@ -32,6 +32,10 @@ const Select: FC<Props> = function ({
       </label>
       <div className={css.fieldWrapper}>
         <SelectOri
+          allowClear
+          onClear={() => {
+            onChange?.('');
+          }}
           filterOption={false}
           showSearch
           className={classNames('width-full')}

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

@@ -33,6 +33,7 @@ const Filter: FC = function () {
         onFilter={onShowModal}
         isSearching={isSearching}
         fields={fields}
+        testId='storage_filter'
       />
 
       <FilterSelectorModal