Sfoglia il codice sorgente

test: 增加角色e2e测试

xyh 2 anni fa
parent
commit
2268640fd6

+ 119 - 0
cypress/e2e/role.cy.ts

@@ -0,0 +1,119 @@
+import {
+  beforeSetup,
+  exportIntercept,
+  generateNetworkResult,
+  intercept,
+  intoMenu,
+  normalIntercept,
+  successIntercept,
+  tableBtnClick,
+  validateDelete,
+  validateExport,
+  validateModalBtnGroup,
+  validatePut,
+  validateTableList,
+  validateTableSearch,
+} from './utils';
+
+const basicData = {
+  id: 11,
+  roleCode: 'BH000011',
+  roleName: 'test账户',
+  createTime: '2023-03-30 14:50:46',
+  remarks: '测试用账户',
+  menu: '78,93,88,79,',
+  menuBefore: '93,88,79',
+  menuPda: '29,30,31,32,',
+  modifyUser: 'admin',
+  modifyTime: '2023-04-12 15:16:15',
+  page: 0,
+  limit: 0,
+};
+
+const TABLE_NAME = 'role_table',
+  MODAL_NAME = 'role_modal';
+
+describe('角色', function () {
+  beforeEach(function () {
+    beforeSetup(true);
+    intoMenu('系统设置', '角色管理');
+  });
+
+  beforeEach(function () {
+    intercept('/role/getRole', function ({search, reply}) {
+      generateNetworkResult({search, basicData, reply, title: 'roleCode'});
+    });
+
+    successIntercept(['/role/delRole', '/role/addRole', '/role/updateRole']);
+    exportIntercept('/role/export');
+    normalIntercept('/menu/getMenu', 'menu/all');
+    normalIntercept('/menu/getPage', 'menu/pda');
+  });
+
+  it('table', function () {
+    validateTableList(TABLE_NAME);
+
+    validateTableSearch(TABLE_NAME, ['roleCode', 'roleName', 'modifyUser'], {
+      toolId: 'role_filter',
+      url: '/role/getRole',
+    });
+  });
+
+  it('operation', function () {
+    const {validateAdd, validateEdit} = validatePut(MODAL_NAME, TABLE_NAME, {
+      label: '角色',
+    });
+
+    validateAdd(['roleName', 'roleRemarks']);
+
+    validateEdit([
+      {id: 'roleName', type: 'field', value: basicData.roleName},
+      {id: 'roleRemarks', type: 'field', value: basicData.remarks},
+    ]);
+
+    validateDelete(TABLE_NAME, '角色', {eq: 3, title: basicData.roleName});
+
+    validateExport(TABLE_NAME);
+
+    // 菜单权限
+    tableBtnClick(TABLE_NAME, 1);
+
+    cy.getTestId('role_tree_modal')
+      .find('h3')
+      .should('include.html', '菜单权限');
+    cy.getTestId('role_tree_modal').should('exist').and('be.visible');
+
+    cy.getTestId('role_tree')
+      .find('.ant-tree-list-holder-inner')
+      .find('.ant-tree-treenode')
+      .each(function (res, idx) {
+        idx <= 3
+          ? expect(res.hasClass('ant-tree-treenode-checkbox-checked')).to.true
+          : expect(res.hasClass('ant-tree-treenode-checkbox-checked')).to.false;
+      })
+      .should('have.length', 17);
+
+    cy.getTestId('role_tree_modal').find('form').submit();
+
+    validateModalBtnGroup('role_tree_modal');
+    cy.get('.ant-message-notice-content').should('include.text', '设置成功');
+    cy.getTestId('role_tree_modal').should('not.exist');
+
+    // pda权限
+    tableBtnClick(TABLE_NAME, 2);
+    cy.get('.ant-transfer-list')
+      .eq(0)
+      .find('.ant-transfer-list-content')
+      .children('.ant-transfer-list-content-item')
+      .should('have.length', 10);
+    cy.get('.ant-transfer-list')
+      .eq(1)
+      .find('.ant-transfer-list-content')
+      .children('.ant-transfer-list-content-item')
+      .should('have.length', 4);
+    cy.getTestId('role_pda_menu_modal').find('form').submit();
+    validateModalBtnGroup('role_pda_menu_modal');
+    cy.get('.ant-message-notice-content').should('include.text', '设置成功');
+    cy.getTestId('role_tree_modal').should('not.exist');
+  });
+});

+ 289 - 27
cypress/fixtures/menu/all.json

@@ -5,67 +5,329 @@
       "children": [
         {
           "children": [],
-          "key": "23",
-          "pId": "15",
-          "title": "用户管理",
-          "url": "/user"
+          "key": "93",
+          "pId": "78",
+          "title": "GS错误日志",
+          "url": "/log/error"
         },
         {
           "children": [],
-          "key": "16",
-          "pId": "15",
-          "title": "角色管理",
-          "url": "/role"
+          "key": "88",
+          "pId": "78",
+          "title": "单据删除日志",
+          "url": "/log/order"
         },
         {
           "children": [],
-          "key": "24",
-          "pId": "15",
-          "title": "部门管理",
-          "url": "/department"
+          "key": "79",
+          "pId": "78",
+          "title": "接口日志",
+          "url": "/log/gsinterface"
         }
       ],
-      "key": "15",
+      "key": "78",
       "pId": "0",
-      "title": "用户设置",
+      "title": "系统日志",
       "url": "."
     },
     {
       "children": [
         {
           "children": [],
-          "key": "26",
-          "pId": "25",
-          "title": "库位管理",
-          "url": "/storage"
+          "key": "96",
+          "pId": "44",
+          "title": "半成品其他出库",
+          "url": "/putout/other"
         },
         {
           "children": [],
-          "key": "27",
-          "pId": "25",
-          "title": "货品管理",
+          "key": "81",
+          "pId": "44",
+          "title": "销售单明细",
+          "url": "/sellorder"
+        },
+        {
+          "children": [],
+          "key": "80",
+          "pId": "44",
+          "title": "生产领料明细",
+          "url": "/production/requisition"
+        },
+        {
+          "children": [],
+          "key": "63",
+          "pId": "44",
+          "title": "销售发货明细",
+          "url": "/stream/productout"
+        },
+        {
+          "children": [],
+          "key": "62",
+          "pId": "44",
+          "title": "半成品出库明细",
+          "url": "/stream/semiout"
+        },
+        {
+          "children": [],
+          "key": "59",
+          "pId": "44",
+          "title": "半成品领料单管理",
+          "url": "/semi/draw"
+        },
+        {
+          "children": [],
+          "key": "61",
+          "pId": "44",
+          "title": "原材料出库明细",
+          "url": "/stream/rawout"
+        }
+      ],
+      "key": "44",
+      "pId": "0",
+      "title": "出库管理",
+      "url": "."
+    },
+    {
+      "children": [
+        {
+          "children": [],
+          "key": "89",
+          "pId": "45",
+          "title": "盘点明细",
+          "url": "/inventory"
+        },
+        {
+          "children": [],
+          "key": "83",
+          "pId": "45",
+          "title": "移库单明细",
+          "url": "/relocation"
+        },
+        {
+          "children": [],
+          "key": "66",
+          "pId": "45",
+          "title": "库存明细",
+          "url": "/stock"
+        },
+        {
+          "children": [],
+          "key": "65",
+          "pId": "45",
+          "title": "物料储量预警",
+          "url": "/reservewarning"
+        },
+        {
+          "children": [],
+          "key": "64",
+          "pId": "45",
+          "title": "呆滞品明细",
+          "url": "/deadproduct"
+        }
+      ],
+      "key": "45",
+      "pId": "0",
+      "title": "库内管理",
+      "url": "."
+    },
+    {
+      "children": [
+        {
+          "children": [],
+          "key": "95",
+          "pId": "43",
+          "title": "半成品其他入库",
+          "url": "/putin/other"
+        },
+        {
+          "children": [],
+          "key": "58",
+          "pId": "43",
+          "title": "产成品入库明细",
+          "url": "/stream/productin"
+        },
+        {
+          "children": [],
+          "key": "57",
+          "pId": "43",
+          "title": "半成品入库明细",
+          "url": "/stream/semiin"
+        },
+        {
+          "children": [],
+          "key": "85",
+          "pId": "43",
+          "title": "产成品报工单",
+          "url": "/product/report"
+        },
+        {
+          "children": [],
+          "key": "55",
+          "pId": "43",
+          "title": "半成品报工单管理",
+          "url": "/semi/report"
+        },
+        {
+          "children": [],
+          "key": "56",
+          "pId": "43",
+          "title": "原材料入库明细",
+          "url": "/stream/rawin"
+        },
+        {
+          "children": [],
+          "key": "54",
+          "pId": "43",
+          "title": "质检单列表",
+          "url": "/quality"
+        },
+        {
+          "children": [],
+          "key": "52",
+          "pId": "43",
+          "title": "采购单列表",
+          "url": "/purchase"
+        }
+      ],
+      "key": "43",
+      "pId": "0",
+      "title": "入库管理",
+      "url": "."
+    },
+    {
+      "children": [
+        {
+          "children": [],
+          "key": "76",
+          "pId": "46",
+          "title": "物料类型管理",
+          "url": "/dictionary/type"
+        },
+        {
+          "children": [],
+          "key": "75",
+          "pId": "46",
+          "title": "供应商/客户管理",
+          "url": "/dictionary/supplier"
+        },
+        {
+          "children": [],
+          "key": "74",
+          "pId": "46",
+          "title": "WBS管理",
+          "url": "/dictionary/wbs"
+        },
+        {
+          "children": [],
+          "key": "73",
+          "pId": "46",
+          "title": "计量单位管理",
+          "url": "/dictionary/unit"
+        },
+        {
+          "children": [],
+          "key": "72",
+          "pId": "46",
+          "title": "仓库管理",
+          "url": "/dictionary/storehouse"
+        },
+        {
+          "children": [],
+          "key": "71",
+          "pId": "46",
+          "title": "库存组织管理",
+          "url": "/dictionary/inventory"
+        },
+        {
+          "children": [],
+          "key": "70",
+          "pId": "46",
+          "title": "公司管理",
+          "url": "/dictionary/corporation"
+        },
+        {
+          "children": [],
+          "key": "50",
+          "pId": "46",
+          "title": "容器管理",
+          "url": "/container"
+        },
+        {
+          "children": [],
+          "key": "69",
+          "pId": "46",
+          "title": "部门管理",
+          "url": "/dictionary/department"
+        },
+        {
+          "children": [],
+          "key": "51",
+          "pId": "46",
+          "title": "物料绑定管理",
+          "url": "/materialbind"
+        },
+        {
+          "children": [],
+          "key": "49",
+          "pId": "46",
+          "title": "物料管理\t",
           "url": "/goods"
+        },
+        {
+          "children": [],
+          "key": "48",
+          "pId": "46",
+          "title": "库位绑定管理",
+          "url": "/matter"
+        },
+        {
+          "children": [],
+          "key": "47",
+          "pId": "46",
+          "title": "库位管理",
+          "url": "/storage"
         }
       ],
-      "key": "25",
+      "key": "46",
       "pId": "0",
-      "title": "仓库管理",
+      "title": "基础资料",
       "url": "."
     },
     {
       "children": [
         {
           "children": [],
-          "key": "14",
-          "pId": "13",
+          "key": "28",
+          "pId": "7",
+          "title": "PDA菜单管理",
+          "url": "/pda"
+        },
+        {
+          "children": [],
+          "key": "27",
+          "pId": "7",
           "title": "菜单管理",
           "url": "/menu"
+        },
+        {
+          "children": [],
+          "key": "42",
+          "pId": "7",
+          "title": "角色管理",
+          "url": "/role"
+        },
+        {
+          "children": [],
+          "key": "41",
+          "pId": "7",
+          "title": "用户管理",
+          "url": "/user"
         }
       ],
-      "key": "13",
+      "key": "7",
       "pId": "0",
       "title": "系统设置",
       "url": "."
     }
   ]
-}
+}

+ 172 - 24
cypress/fixtures/menu/pda.json

@@ -1,92 +1,238 @@
 {
   "msg": "200",
   "data": {
-    "total": 6,
+    "total": 14,
     "list": [
       {
-        "id": "31",
-        "name": "收货",
+        "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"
+      },
+      {
+        "id": "30",
+        "name": "计划出库",
         "url": "2",
         "pId": "0",
         "idCode": null,
         "type": "PDA",
         "page": 0,
         "limit": 0,
-        "orderBy": "0",
+        "orderBy": "2",
+        "menu": null,
+        "img": "",
+        "modifyUser": "admin",
+        "modifyTime": "2023-03-22 10:57:34",
+        "pid": "0"
+      },
+      {
+        "id": "31",
+        "name": "非生产领料",
+        "url": "3",
+        "pId": "0",
+        "idCode": null,
+        "type": "PDA",
+        "page": 0,
+        "limit": 0,
+        "orderBy": "3",
         "menu": null,
+        "img": "",
+        "modifyUser": "admin",
+        "modifyTime": "2023-04-11 11:14:11",
+        "pid": "0"
+      },
+      {
+        "id": "32",
+        "name": "半成品入库",
+        "url": "4",
+        "pId": "0",
+        "idCode": null,
+        "type": "PDA",
+        "page": 0,
+        "limit": 0,
+        "orderBy": "4",
+        "menu": null,
+        "img": "",
+        "modifyUser": "admin",
+        "modifyTime": "2023-03-22 10:57:34",
         "pid": "0"
       },
       {
         "id": "33",
-        "name": "上架",
-        "url": "12",
+        "name": "半成品出库",
+        "url": "5",
         "pId": "0",
         "idCode": null,
         "type": "PDA",
         "page": 0,
         "limit": 0,
-        "orderBy": "0",
+        "orderBy": "5",
         "menu": null,
+        "img": "",
+        "modifyUser": "admin",
+        "modifyTime": "2023-03-22 10:57:34",
         "pid": "0"
       },
       {
         "id": "34",
-        "name": "下架",
-        "url": "33",
+        "name": "产成品入库",
+        "url": "6",
         "pId": "0",
         "idCode": null,
         "type": "PDA",
         "page": 0,
         "limit": 0,
-        "orderBy": "0",
+        "orderBy": "6",
         "menu": null,
+        "img": "",
+        "modifyUser": "admin",
+        "modifyTime": "2023-03-22 10:57:34",
         "pid": "0"
       },
       {
         "id": "35",
-        "name": "出库",
-        "url": "54",
+        "name": "销售发货",
+        "url": "7",
         "pId": "0",
         "idCode": null,
         "type": "PDA",
         "page": 0,
         "limit": 0,
-        "orderBy": "0",
+        "orderBy": "7",
         "menu": null,
+        "img": "",
+        "modifyUser": "admin",
+        "modifyTime": "2023-04-11 18:08:00",
         "pid": "0"
       },
       {
         "id": "36",
-        "name": "入库",
-        "url": "21",
+        "name": "移库",
+        "url": "8",
+        "pId": "0",
+        "idCode": null,
+        "type": "PDA",
+        "page": 0,
+        "limit": 0,
+        "orderBy": "8",
+        "menu": null,
+        "img": "",
+        "modifyUser": "admin",
+        "modifyTime": "2023-03-22 10:57:34",
+        "pid": "0"
+      },
+      {
+        "id": "38",
+        "name": "其他入库",
+        "url": "9",
         "pId": "0",
         "idCode": null,
         "type": "PDA",
         "page": 0,
         "limit": 0,
-        "orderBy": "0",
+        "orderBy": "9",
         "menu": null,
+        "img": "",
+        "modifyUser": "admin",
+        "modifyTime": "2023-03-22 10:57:34",
         "pid": "0"
       },
       {
-        "id": "37",
-        "name": "AGV",
-        "url": "90",
+        "id": "39",
+        "name": "其他出库",
+        "url": "10",
         "pId": "0",
         "idCode": null,
         "type": "PDA",
         "page": 0,
         "limit": 0,
-        "orderBy": "0",
+        "orderBy": "10",
         "menu": null,
+        "img": "",
+        "modifyUser": "admin",
+        "modifyTime": "2023-03-22 10:57:34",
+        "pid": "0"
+      },
+      {
+        "id": "77",
+        "name": "标签打印",
+        "url": "11",
+        "pId": "0",
+        "idCode": null,
+        "type": "PDA",
+        "page": 0,
+        "limit": 0,
+        "orderBy": "11",
+        "menu": null,
+        "img": "",
+        "modifyUser": "admin",
+        "modifyTime": "2023-03-24 09:21:57",
+        "pid": "0"
+      },
+      {
+        "id": "87",
+        "name": "库存查询",
+        "url": "12",
+        "pId": "0",
+        "idCode": null,
+        "type": "PDA",
+        "page": 0,
+        "limit": 0,
+        "orderBy": "12",
+        "menu": null,
+        "img": "",
+        "modifyUser": "admin",
+        "modifyTime": "2023-04-11 11:51:13",
+        "pid": "0"
+      },
+      {
+        "id": "90",
+        "name": "库存盘点",
+        "url": "13",
+        "pId": "0",
+        "idCode": null,
+        "type": "PDA",
+        "page": 0,
+        "limit": 0,
+        "orderBy": "13",
+        "menu": null,
+        "img": "",
+        "modifyUser": "admin",
+        "modifyTime": "2023-03-31 13:11:47",
+        "pid": "0"
+      },
+      {
+        "id": "94",
+        "name": "托码打印",
+        "url": "14",
+        "pId": "0",
+        "idCode": null,
+        "type": "PDA",
+        "page": 0,
+        "limit": 0,
+        "orderBy": "14",
+        "menu": null,
+        "img": "",
+        "modifyUser": "admin",
+        "modifyTime": "2023-04-03 18:33:37",
         "pid": "0"
       }
     ],
     "pageNum": 1,
     "pageSize": 10000,
-    "size": 6,
+    "size": 14,
     "startRow": 1,
-    "endRow": 6,
+    "endRow": 14,
     "pages": 1,
     "prePage": 0,
     "nextPage": 0,
@@ -95,8 +241,10 @@
     "hasPreviousPage": false,
     "hasNextPage": false,
     "navigatePages": 8,
-    "navigatepageNums": [1],
+    "navigatepageNums": [
+      1
+    ],
     "navigateFirstPage": 1,
     "navigateLastPage": 1
   }
-}
+}

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

@@ -21,7 +21,7 @@ const Filter: FC = function () {
 
   return (
     <Card>
-      <FilterFieldWrapper onSearch={onSearch}>
+      <FilterFieldWrapper onSearch={onSearch} testId='role_filter'>
         <FilterField
           label='角色编号'
           name='roleCode'