container.cy.ts 3.5 KB

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