Sfoglia il codice sorgente

test: 增加PDA菜单测试

xyh 2 anni fa
parent
commit
6928e7c053

+ 6 - 1
cypress/e2e/menu.cy.ts

@@ -98,7 +98,12 @@ describe('菜单管理', function () {
       },
     );
 
-    validateAdd(['menuName', 'menuUrl', 'menuOrderBy']);
+    validateAdd([
+      'menuName',
+      'menuUrl',
+      {id: 'menuOrderBy', type: 'field', value: '2'},
+    ]);
+
     validateEdit([
       {id: 'menuName', type: 'field', value: basicData.name},
       {id: 'menuUrl', type: 'field', value: basicData.url},

+ 81 - 0
cypress/e2e/pdaMenu.cy.ts

@@ -0,0 +1,81 @@
+import {
+  beforeSetup,
+  generateNetworkResult,
+  intercept,
+  intoMenu,
+  successIntercept,
+  validateDelete,
+  validatePut,
+  validateTableList,
+  validateTableSearch,
+} from './utils';
+
+const basicData = {
+  id: '29',
+  name: '上架入库',
+  url: '1',
+  pId: '0',
+  idCode: null,
+  type: 'PDA',
+  page: 0,
+  limit: 0,
+  orderBy: '1',
+  menu: null,
+  img: '',
+  modifyUser: 'admin',
+  modifyTime: '2023-03-22 10:57:34',
+  pid: '0',
+};
+
+const TABLE_NAME = 'menu_table';
+
+describe('pda菜单', function () {
+  beforeEach(function () {
+    beforeSetup(true);
+    intoMenu('系统设置', 'PDA菜单管理');
+  });
+
+  beforeEach(function () {
+    intercept('/menu/getPage', function ({search, reply}) {
+      generateNetworkResult({
+        search,
+        reply,
+        basicData,
+        title: 'url',
+        skipCondition(name) {
+          return name === 'pId' || name === 'type';
+        },
+      });
+    });
+
+    successIntercept(['/menu/addMenu', '/menu/updateMenu', '/menu/delMenu']);
+  });
+
+  it('table', function () {
+    validateTableList(TABLE_NAME);
+
+    validateTableSearch(TABLE_NAME, ['menuName', 'modifyUser'], {
+      toolId: 'pda_menu_filter',
+      url: '/menu/getPage',
+    });
+  });
+
+  it('operation', function () {
+    const {validateAdd, validateEdit} = validatePut('menu_modal', TABLE_NAME, {
+      label: 'PDA菜单',
+    });
+
+    validateAdd([
+      'menuID',
+      'menuName',
+      {id: 'menuOrderBy', type: 'field', value: '2'},
+    ]);
+    validateEdit([
+      {id: 'menuID', type: 'field', value: basicData.url},
+      {id: 'menuName', type: 'field', value: basicData.name},
+      {id: 'menuOrderBy', type: 'field', value: basicData.orderBy},
+    ]);
+
+    validateDelete(TABLE_NAME, 'PDA菜单', {title: basicData.name});
+  });
+});

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

@@ -212,7 +212,13 @@ export function validatePut(
 ) {
   const {label} = options;
 
-  function validateAdd(keys: (string | {id: string; type: 'select'})[]) {
+  function validateAdd(
+    keys: (
+      | string
+      | {id: string; type: 'select'}
+      | {id: string; type: 'field'; value: string}
+    )[],
+  ) {
     cy.getTestId(tableName)
       .closest('.ant-card-body')
       .find('[data-testid="add_btn"]')
@@ -231,6 +237,9 @@ export function validatePut(
           case 'select':
             selectClick(`field_${id}`, 0);
             break;
+          case 'field':
+            cy.getTestId(`field_${id}`).clear().type(key.value);
+            break;
         }
       }
     });

+ 1 - 1
packages/app/src/pages/pda-menu/filter/index.tsx

@@ -20,7 +20,7 @@ const Filter: FC = function () {
 
   return (
     <Card>
-      <FilterFieldWrapper onSearch={onSearch}>
+      <FilterFieldWrapper onSearch={onSearch} testId='pda_menu_filter'>
         <FilterField
           name='menuName'
           label='菜单名称'