Browse Source

test: 增加物料管理测试

xyh 2 years ago
parent
commit
e846e691c3

+ 97 - 0
cypress/e2e/material.cy.ts

@@ -0,0 +1,97 @@
+import {
+  beforeSetup,
+  generateNetworkResult,
+  intercept,
+  intoMenu,
+  selectAllFilters,
+  successIntercept,
+  validatePut,
+  validateTableSearch,
+} from './utils';
+
+const basicData = {
+  id: '84874',
+  code: 'test_3015040242',
+  name: '稳压二极管',
+  tldId: '00000000000000000104',
+  specificationAndModel:
+    '瞬态抑制二极管-双向,CAN数据端口专用-26.2V-44V-350W-8.00A-SOT-23-/-',
+  unitOfMeasurement: '00000000000000000001',
+  materialId: null,
+  num: null,
+  type: '0',
+  tableName: null,
+  size: '10',
+  materialType: null,
+  wllbClass: '危化品',
+  isNotDisable: '1',
+  isRecommend: '1',
+  partType: '产成品',
+  page: 0,
+  limit: 0,
+  amount: null,
+  minNum: '6',
+  maxNum: '12',
+  modifyUser: 'admin',
+  modifyTime: '2023-04-12 17:05:01',
+  typeVal: null,
+  companyNumber: '0',
+  warehouseType: null,
+  nameOrCode: null,
+};
+
+describe('物料管理', function () {
+  beforeEach(function () {
+    beforeSetup(true);
+    intoMenu('基础资料', '物料管理');
+  });
+
+  beforeEach(function () {
+    intercept('/dictionary/getDictionaryPage', function ({search, reply}) {
+      generateNetworkResult({
+        search,
+        reply,
+        basicData,
+        title: 'code',
+        skipCondition(name) {
+          return name === 'type';
+        },
+      });
+    });
+
+    successIntercept('/materialClass/updateMaterial');
+  });
+
+  it('table', function () {
+    selectAllFilters('material_filter', 7);
+    validateTableSearch(
+      'goods_table',
+      [
+        'code',
+        'name',
+        'materialType',
+        {id: 'wllbClass', type: 'select', value: '危化品'},
+        {id: 'isNotDisable', type: 'select', eq: 1, value: '1'},
+        {id: 'isRecommend', type: 'select', eq: 2, value: '0'},
+        'modifyUser',
+      ],
+      {toolId: 'material_filter', url: '/dictionary/getDictionaryPage'},
+    );
+  });
+
+  it.only('operation', function () {
+    const {validateEdit} = validatePut('goods_modal', 'goods_table', {
+      label: '物料',
+    });
+
+    validateEdit([
+      {id: 'goodsPartType', type: 'field', value: '产成品'},
+      {id: 'goodsType', type: 'select', value: '危化品'},
+      {id: 'goodsSize', type: 'field', value: '10'},
+      {id: 'goodsMaxNum', type: 'field', value: '12'},
+      {id: 'goodsMinNum', type: 'field', value: '6'},
+      {id: 'goodsMixin', type: 'select', value: '是'},
+      {id: 'goodsRecommend', type: 'select', value: '是'},
+    ]);
+  });
+});

+ 1 - 1
cypress/e2e/utils/utils.ts

@@ -62,7 +62,7 @@ export function validateTableList(tableName: string) {
 export function validateTableSearch(
   tableName: string,
   keys: (
-    | {id: string; type: 'select' | 'date'; value?: string; eq?: number}
+    | {id: string; type: 'select' | 'date'; value: string; eq?: number}
     | string
   )[],
   options: {

+ 2 - 2
cypress/fixtures/menu/basic.json

@@ -259,7 +259,7 @@
     },
     {
       "id": "49",
-      "name": "物料管理\t",
+      "name": "物料管理",
       "url": "/goods",
       "pId": "46",
       "idCode": null,
@@ -738,4 +738,4 @@
       "pid": "46"
     }
   ]
-}
+}

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

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

+ 2 - 2
packages/app/src/pages/goods/table/modal/hooks.ts

@@ -50,7 +50,7 @@ export function useFormState({
   const formInstance = useForm<FormState>({
     defaultValues: {
       goodsType: '',
-      goodsSize: 1,
+      goodsSize: 0,
       goodsMixin: '',
       goodsRecommend: '',
       goodsPartType: '',
@@ -121,7 +121,7 @@ export function useWatchId(id: string) {
   useEffect(
     function () {
       setValue('goodsType', data?.wllbClass ?? '');
-      setValue('goodsSize', Number(data?.size ?? '1'));
+      setValue('goodsSize', Number(data?.size ?? '0'));
       setValue('goodsMixin', data?.isNotDisable ?? '');
       setValue('goodsRecommend', data?.isRecommend ?? '');
       setValue('goodsPartType', data?.partType ?? '');