manager.cy.ts 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. import {
  2. beforeSetup,
  3. exportIntercept,
  4. generateNetworkResult,
  5. intercept,
  6. intoMenu,
  7. selectAllFilters,
  8. successIntercept,
  9. tableBtnClick,
  10. validateDelete,
  11. validateDialog,
  12. validateExport,
  13. validateMessageContent,
  14. validatePut,
  15. validateTableList,
  16. validateTableSearch,
  17. } from './utils';
  18. const basicData = {
  19. id: '83',
  20. code: 'YH000083',
  21. userName: 'admin2',
  22. password: 'F6BE46C2F900E518',
  23. newPassword: null,
  24. realName: '测试2',
  25. email: '1211@163.com',
  26. landline: null,
  27. phone: '1336131680',
  28. department: '采购中心(公共) ',
  29. role: 'test账户',
  30. roleId: '11',
  31. departmentId: '00029999',
  32. createTime: '2023-04-03 14:01:45',
  33. token: null,
  34. menu: null,
  35. modifyUser: 'admin',
  36. modifyTime: '2023-04-03 14:18:21',
  37. page: 0,
  38. limit: 0,
  39. };
  40. const TABLE_NAME = 'user_table',
  41. MODAL_NAME = 'user_add_modal',
  42. LABEL = '用户',
  43. TOOL_ID = 'user_filter';
  44. describe('首页', function () {
  45. beforeEach(function () {
  46. beforeSetup(true);
  47. intoMenu('系统设置', '用户管理');
  48. });
  49. beforeEach(function () {
  50. intercept('/user/getAllUser', function ({search, reply}) {
  51. generateNetworkResult({search, reply, basicData, title: 'code'});
  52. });
  53. exportIntercept('/user/resetPassword');
  54. successIntercept([
  55. '/user/addUser',
  56. '/user/updateUser',
  57. '/user/delUser',
  58. '/user/resetPassword',
  59. ]);
  60. });
  61. it('table', function () {
  62. selectAllFilters(TOOL_ID, 8);
  63. validateTableList(TABLE_NAME);
  64. validateTableSearch(
  65. TABLE_NAME,
  66. [
  67. 'userName',
  68. 'realName',
  69. 'code',
  70. {id: 'department', type: 'select', value: '00029999'},
  71. 'role',
  72. 'email',
  73. 'phone',
  74. 'modifyUser',
  75. ],
  76. {toolId: TOOL_ID, url: '/user/getAllUser'},
  77. );
  78. });
  79. it('operation', function () {
  80. validateExport(TABLE_NAME);
  81. const {validateAdd, validateEdit} = validatePut(MODAL_NAME, TABLE_NAME, {
  82. label: LABEL,
  83. });
  84. validateAdd([
  85. 'userName',
  86. 'userRealName',
  87. 'userPassword',
  88. {id: 'userDepartment', type: 'select'},
  89. {id: 'userRole', type: 'select'},
  90. 'userEmail',
  91. 'userPhone',
  92. ]);
  93. validateEdit([
  94. {id: 'userName', type: 'field', value: basicData.userName},
  95. {id: 'userRealName', type: 'field', value: basicData.realName},
  96. {id: 'userDepartment', type: 'select', value: basicData.department},
  97. {id: 'userRole', type: 'select', value: basicData.role},
  98. {id: 'userEmail', type: 'field', value: basicData.email},
  99. {id: 'userPhone', type: 'field', value: basicData.phone},
  100. ]);
  101. // 重置密码
  102. const resetBtn = tableBtnClick(TABLE_NAME, 1);
  103. validateDialog('重置密码', '你确定要将测试2的密码重置为123456吗?');
  104. resetBtn().should('have.class', 'ant-btn-loading');
  105. validateMessageContent('重置成功');
  106. validateDelete(TABLE_NAME, LABEL, {eq: 2, title: 'admin2'});
  107. });
  108. });