Parcourir la source

test: 增加字典列表测试

xyh il y a 2 ans
Parent
commit
4a2185e066

+ 94 - 0
cypress/e2e/dictionary.cy.ts

@@ -0,0 +1,94 @@
+import {
+  beforeSetup,
+  generateNetworkResult,
+  intercept,
+  intoMenu,
+  successIntercept,
+  validateDelete,
+  validatePut,
+  validateTableList,
+  validateTableSearch,
+} from './utils';
+
+const basicData = {
+  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: '产成品仓库',
+  nameOrCode: null,
+};
+
+describe('字典列表, 只用仓库管理做测试', function () {
+  beforeEach(function () {
+    beforeSetup(true);
+    intoMenu('基础资料', '仓库管理');
+  });
+
+  beforeEach(function () {
+    intercept('/dictionary/getDictionaryPage', function ({reply, search}) {
+      generateNetworkResult({
+        reply,
+        search,
+        basicData,
+        title: 'tldId',
+        skipCondition: name => name === 'type',
+      });
+    });
+
+    successIntercept([
+      '/dictionary/updateDictionary',
+      '/dictionary/addDictionary',
+      '/dictionary/deleteDictionary',
+      '/maintenance/updateWarehouse',
+    ]);
+  });
+
+  it('table', function () {
+    validateTableList('dictionary_table');
+    validateTableSearch(
+      'dictionary_table',
+      [
+        'dictionaryName',
+        'dictionaryCode',
+        {id: 'warehouseType', type: 'select', value: '0'},
+      ],
+      {toolId: 'dictionary_filter', url: '/dictionary/getDictionaryPage'},
+    );
+  });
+
+  it('operation', function () {
+    const {validateAdd, validateEdit} = validatePut(
+      'dicionary_modal',
+      'dictionary_table',
+      {label: '仓库'},
+    );
+
+    validateAdd(['dictionaryId', 'dictionaryName', 'dictionaryCode']);
+
+    validateEdit([{id: 'storageType', type: 'select', value: '产成品仓库'}]);
+
+    validateDelete('dictionary_table', '仓库', {title: basicData.name});
+  });
+});

+ 13 - 10
cypress/fixtures/login.json

@@ -1,22 +1,25 @@
 {
   "msg": "200",
   "data": {
-    "id": 3,
+    "id": "3",
     "code": "TLD0003",
     "userName": "admin",
     "password": "706C20B26C94BB14",
-    "realName": "超级管理员",
-    "email": null,
-    "landline": null,
-    "phone": null,
-    "department": "2",
-    "role": "5",
+    "newPassword": null,
+    "realName": "超管",
+    "email": "123@11.com",
+    "landline": "2",
+    "phone": "3",
+    "department": "000300030002",
+    "role": "1",
     "roleId": null,
     "departmentId": null,
     "createTime": null,
-    "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhdWQiOiIwIiwidXNlcl9uYW1lIjoiYWRtaW4iLCJ1c2VySWQiOiIwIn0.sVk6itAHdnBDpSJlyyfJZrRpsC7xB0FNoLOavectsKA",
-    "menu": "15,23,16,24,13,14,25,26,27,",
+    "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhdWQiOiJudWxsIiwidXNlcl9uYW1lIjoiYWRtaW4iLCJ1c2VySWQiOiJudWxsIn0.NXm91i0EmT_tw-5q_CRL6GcIYPiFYMmGwT-cVWJEb1U",
+    "menu": "28,7,27,65,45,64,63,44,62,61,59,58,43,57,56,55,54,52,50,46,51,49,48,47,42,41,66,69,76,75,74,73,72,71,70,79,78,80,81,83,85,88,89,93,95,96,",
+    "modifyUser": null,
+    "modifyTime": null,
     "page": 0,
     "limit": 0
   }
-}
+}

+ 0 - 1
packages/app/src/components/table/index.tsx

@@ -10,7 +10,6 @@ import {PAGE_SIZE_LIST, calcColumnsWidth} from '@utils';
 import {ReactElement, useMemo} from 'react';
 
 type Props<T> = {
-  testId?: string;
   columns: ColumnsType<T>;
   data: T[];
   pageContext: ReturnType<typeof createPageContext>;

+ 1 - 2
packages/app/src/pages/dictionary/filter/index.tsx

@@ -15,7 +15,6 @@ import {context, searchContext} from '../context';
 import {useDicionaryType} from '../hooks';
 
 const options = [
-  {label: '全部', value: ''},
   {label: '原材料仓库', value: '0'},
   {label: '半成品仓库', value: '1'},
   {label: '产成品仓库', value: '2'},
@@ -42,7 +41,7 @@ const Filter: FC = function () {
 
   return (
     <Card>
-      <FilterFieldWrapper onSearch={onSearch}>
+      <FilterFieldWrapper onSearch={onSearch} testId='dictionary_filter'>
         <FilterField
           name='dictionaryName'
           label='名称'

+ 1 - 0
packages/app/src/pages/dictionary/table/index.tsx

@@ -50,6 +50,7 @@ const TableList: FC = function () {
           count={count}
           pageContext={pageContext}
           searchContext={searchContext}
+          data-testid='dictionary_table'
         />
       </Card>
 

+ 1 - 0
packages/app/src/pages/dictionary/table/type-modal/index.tsx

@@ -40,6 +40,7 @@ const StorageModal: FC<Props> = function ({
       visible={visible}
       onSubmit={onSubmit}
       onClose={onClose}
+      testId='dicionary_modal'
     >
       <ModalSelect
         label='仓库类型'