container.cy.ts 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. import {
  2. beforeSetup,
  3. exportIntercept,
  4. generateNetworkResult,
  5. intercept,
  6. intoMenu,
  7. successIntercept,
  8. tableBtnClick,
  9. validateDelete,
  10. validateExport,
  11. validateModalOperation,
  12. validatePut,
  13. validateTableList,
  14. validateTableSearch,
  15. } from './utils';
  16. const basicData = {
  17. id: '5',
  18. department: '涂装班组',
  19. departmentId: '000300010012',
  20. type: '充电桩底座+1',
  21. containerName: '特来电002',
  22. code: '00002',
  23. num: '9',
  24. createTime: '2023-03-31 10:11:27',
  25. modifyUser: 'admin',
  26. modifyTime: '2023-03-31 10:46:30',
  27. page: 0,
  28. limit: 0,
  29. };
  30. const scrapBasicData = {
  31. id: '6',
  32. operationName: 'admin',
  33. name: null,
  34. scrapCause: '1',
  35. scrapTime: '2023-03-31 10:46:30',
  36. scrapNum: '1',
  37. startTime: null,
  38. endTime: null,
  39. containerName: '特来电002',
  40. page: 0,
  41. limit: 0,
  42. };
  43. describe('容器管理', function() {
  44. beforeEach(function() {
  45. beforeSetup();
  46. intoMenu('基础资料', '容器管理');
  47. });
  48. beforeEach(function() {
  49. intercept('/container/getContainer', function({reply, search}) {
  50. generateNetworkResult({reply, search, basicData, title: 'code'});
  51. });
  52. intercept('/container/getScrap', function({reply, search}) {
  53. generateNetworkResult({
  54. reply,
  55. search,
  56. basicData: scrapBasicData,
  57. title: 'operationName',
  58. skipCondition: name => name === 'containerName',
  59. });
  60. });
  61. successIntercept([
  62. '/container/addContainer',
  63. '/container/updateContainer',
  64. '/container/delCon',
  65. '/container/delContainer',
  66. ]);
  67. exportIntercept('/container/exportScrap');
  68. exportIntercept('/container/export');
  69. });
  70. it('table', function() {
  71. validateTableList('container_table');
  72. validateTableSearch(
  73. 'container_table',
  74. [
  75. 'containerCode',
  76. 'containerName',
  77. 'containerType',
  78. {id: 'department', type: 'select', value: '00029999'},
  79. 'modifyUser',
  80. ],
  81. {toolId: 'container_filter', url: '/container/getContainer'},
  82. );
  83. validateExport('container_table');
  84. });
  85. it('operation', function() {
  86. const {validateAdd, validateEdit} = validatePut(
  87. 'container_modal',
  88. 'container_table',
  89. {
  90. label: '容器',
  91. },
  92. );
  93. validateAdd([
  94. 'containerName',
  95. 'containerCode',
  96. 'containerType',
  97. {id: 'containerNum', type: 'field', value: '10'},
  98. {id: 'containerDepartment', type: 'select'},
  99. ]);
  100. validateEdit([
  101. {id: 'containerName', type: 'field', value: basicData.containerName},
  102. {id: 'containerCode', type: 'field', value: basicData.code},
  103. {id: 'containerType', type: 'field', value: basicData.type},
  104. {id: 'containerNum', type: 'field', value: basicData.num},
  105. {id: 'containerDepartment', type: 'select', value: basicData.department},
  106. ]);
  107. validateDelete('container_table', '容器', {
  108. eq: 3,
  109. title: basicData.containerName,
  110. });
  111. //报废
  112. tableBtnClick('container_table', 1);
  113. cy.getTestId('container_scrap_modal')
  114. .find('h3')
  115. .should('have.text', '容器报废');
  116. cy.getTestId('field_scrapNum').clear().type('2');
  117. cy.getTestId('field_scrapNote').type('报废理由');
  118. validateModalOperation('container_scrap_modal', '报废成功');
  119. });
  120. it('报废列表', function() {
  121. tableBtnClick('container_table', 2);
  122. validateTableList('container_scrap_table');
  123. validateTableSearch(
  124. 'container_scrap_table',
  125. ['operationName', {id: 'containerDate', type: 'date'}],
  126. {toolId: 'container_scrap_filter', url: '/container/getScrap'},
  127. );
  128. validateExport('container_scrap_table');
  129. });
  130. });