container.cy.ts 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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('/container/getContainer', 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. intercept('/container/getScrap', function ({search, reply}) {
  43. if (search.has('startTime') && search.get('startTime').length)
  44. return reply({fixture: 'container/scrapSearch'});
  45. const page = search.get('page');
  46. reply({fixture: `container/scrapList${page}`});
  47. });
  48. successIntercept('container/addContainer');
  49. successIntercept('container/updateContainer');
  50. successIntercept('container/delCon');
  51. successIntercept('container/delContainer');
  52. exportIntercept('container/export');
  53. exportIntercept('container/exportScrap');
  54. });
  55. const TABLE_NAME = 'container_table',
  56. MODAL_NAME = 'container_modal',
  57. LABEL = '容器';
  58. it('列表', function () {
  59. validateTableList(TABLE_NAME);
  60. const validate = validateTableSearch(TABLE_NAME);
  61. cy.get('#filter_containerName').type('searchName');
  62. validate('nameSearch');
  63. cy.get('#filter_containerName').clear();
  64. cy.get('#filter_containerType').type('searchType');
  65. validate('typeSearch');
  66. cy.get('#filter_containerType').clear();
  67. selectClick('filter_containerNameDepartment', 2);
  68. validate('depSearch');
  69. validateExport();
  70. });
  71. it('表格操作', function () {
  72. const {validateAdd, validateEdit} = validatePut(MODAL_NAME, LABEL);
  73. validateAdd(function () {
  74. cy.getTestId('field_containerName').type('name');
  75. cy.getTestId('field_containerType').type('type');
  76. cy.getTestId('field_containerNum').clear().type('2');
  77. selectClick('select_containerDepartment', 2);
  78. });
  79. validateEdit(TABLE_NAME, function () {
  80. cy.getTestId('field_containerName').should('have.value', '仓库1');
  81. cy.getTestId('field_containerType').should('have.value', '随便');
  82. cy.getTestId('field_containerNum').should('have.value', '5');
  83. validateSelect('select_containerDepartment', '仓储部门');
  84. });
  85. validateDelete(TABLE_NAME, LABEL);
  86. // #region 报废
  87. tableBtnClick(TABLE_NAME, 2);
  88. cy.getTestId('container_scrap_modal').find('h3').should('have.text', '容器报废');
  89. cy.getTestId('field_scrapNum').clear().type('2');
  90. cy.get('#operation_scrapNote').type('报废理由');
  91. validateModalOperation('container_scrap_modal', '报废成功');
  92. // #endregion
  93. });
  94. it('报废列表', function () {
  95. tableBtnClick(TABLE_NAME, 3);
  96. validateTableList('container_scrap_table', 2, 1);
  97. const validate = validateTableSearch('container_scrap_table', 'timeSearch', {
  98. btnTestId: 'container_scrap_search',
  99. });
  100. cy.getTestId('date_filter_containerDate').click();
  101. cy.get('.ant-picker-date-panel')
  102. .eq(0)
  103. .find('.ant-picker-content')
  104. .find('tbody')
  105. .find('td')
  106. .first()
  107. .click();
  108. cy.get('.ant-picker-date-panel')
  109. .eq(1)
  110. .find('.ant-picker-content')
  111. .find('tbody')
  112. .find('td')
  113. .first()
  114. .click();
  115. validate();
  116. validateExport('container_scrap_export');
  117. closeModal();
  118. cy.getTestId('container_scrap_table').should('not.exist');
  119. });
  120. });