container.cy.ts 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. import {
  2. loginIntercept,
  3. menuIntercept,
  4. loginSetup,
  5. intercept,
  6. validateTableList,
  7. validateTableSearch,
  8. selectClick,
  9. optionsIntercept,
  10. validatePut,
  11. successIntercept,
  12. exportIntercept,
  13. validateSelect,
  14. validateDelete,
  15. validateExport,
  16. tableBtnClick,
  17. validateModalOperation,
  18. closeModal,
  19. dictionaryIntercept,
  20. intoMenu,
  21. } from './utils';
  22. describe('容器管理', function() {
  23. beforeEach(function() {
  24. loginIntercept();
  25. menuIntercept();
  26. loginSetup();
  27. optionsIntercept();
  28. dictionaryIntercept();
  29. intoMenu('仓库管理', '容器管理');
  30. });
  31. beforeEach(function() {
  32. intercept(
  33. '/container/getContainer',
  34. function({search, reply}) {
  35. if (search.has('containerName') && search.get('containerName').length)
  36. return reply({fixture: 'container/nameSearch'});
  37. if (search.has('type') && search.get('type').length)
  38. return reply({fixture: 'container/typeSearch'});
  39. if (search.has('department') && search.get('department').length)
  40. return reply({fixture: 'container/depSearch'});
  41. const page = search.get('page');
  42. reply({fixture: `container/list${page}`});
  43. },
  44. );
  45. intercept(
  46. '/container/getScrap',
  47. function({search, reply}) {
  48. if (search.has('startTime') && search.get('startTime').length)
  49. return reply({fixture: 'container/scrapSearch'});
  50. const page = search.get('page');
  51. reply({fixture: `container/scrapList${page}`});
  52. },
  53. );
  54. successIntercept('container/addContainer');
  55. successIntercept('container/updateContainer');
  56. successIntercept('container/delCon');
  57. successIntercept('container/delContainer');
  58. exportIntercept('container/export');
  59. exportIntercept('container/exportScrap');
  60. });
  61. const TABLE_NAME = 'container_table',
  62. MODAL_NAME = 'container_modal',
  63. LABEL = '容器';
  64. it('列表', function() {
  65. validateTableList(TABLE_NAME);
  66. const validate = validateTableSearch(TABLE_NAME);
  67. cy.get('#filter_containerName').type('searchName');
  68. validate('nameSearch');
  69. cy.get('#filter_containerName').clear();
  70. cy.get('#filter_containerType').type('searchType');
  71. validate('typeSearch');
  72. cy.get('#filter_containerType').clear();
  73. selectClick('filter_containerNameDepartment', 2);
  74. validate('depSearch');
  75. validateExport();
  76. });
  77. it('表格操作', function() {
  78. const {validateAdd, validateEdit} = validatePut(
  79. MODAL_NAME,
  80. LABEL,
  81. );
  82. validateAdd(function() {
  83. cy.getTestId('field_containerName').type('name');
  84. cy.getTestId('field_containerType').type('type');
  85. cy.getTestId('field_containerNum').clear().type('2');
  86. selectClick('select_containerDepartment', 2);
  87. });
  88. validateEdit(TABLE_NAME, function() {
  89. cy.getTestId('field_containerName').should('have.value', '仓库1');
  90. cy.getTestId('field_containerType').should('have.value', '随便');
  91. cy.getTestId('field_containerNum').should('have.value', '5');
  92. validateSelect('select_containerDepartment', '仓储部门');
  93. });
  94. validateDelete(TABLE_NAME, LABEL);
  95. // #region 报废
  96. tableBtnClick(TABLE_NAME, 2);
  97. cy.getTestId('container_scrap_modal').find('h3')
  98. .should('have.text', '容器报废');
  99. cy.getTestId('field_scrapNum').clear().type('2');
  100. cy.get('#operation_scrapNote').type('报废理由');
  101. validateModalOperation('container_scrap_modal', '报废成功');
  102. // #endregion
  103. });
  104. it('报废列表', function() {
  105. tableBtnClick(TABLE_NAME, 3);
  106. validateTableList('container_scrap_table', 2, 1);
  107. const validate = validateTableSearch(
  108. 'container_scrap_table',
  109. 'timeSearch',
  110. {
  111. btnTestId: 'container_scrap_search',
  112. },
  113. );
  114. cy.getTestId('date_filter_containerDate').click();
  115. cy.get('.ant-picker-date-panel')
  116. .eq(0).find('.ant-picker-content').find('tbody').find('td')
  117. .first().click();
  118. cy.get('.ant-picker-date-panel')
  119. .eq(1).find('.ant-picker-content').find('tbody').find('td')
  120. .first().click();
  121. validate();
  122. validateExport('container_scrap_export');
  123. closeModal();
  124. cy.getTestId('container_scrap_table').should('not.exist');
  125. });
  126. });