container.cy.ts 4.1 KB

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