storage.cy.ts 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. import {
  2. loginIntercept,
  3. loginSetup,
  4. menuIntercept,
  5. selectClick,
  6. validateSelect,
  7. validateDelete,
  8. validatePut,
  9. validateTableList,
  10. validateTableSearch,
  11. successIntercept,
  12. intercept,
  13. validateExport,
  14. exportIntercept,
  15. intoMenu,
  16. dictionaryIntercept,
  17. } from './utils';
  18. describe('库位管理', function() {
  19. beforeEach(function() {
  20. loginIntercept();
  21. menuIntercept();
  22. loginSetup();
  23. dictionaryIntercept();
  24. intoMenu('仓库管理', '库位管理');
  25. });
  26. beforeEach(function() {
  27. intercept(
  28. '/storage/getStorage',
  29. function({url: reqUrl, reply}) {
  30. const url = new URL(reqUrl);
  31. const search = new URLSearchParams(url.search);
  32. if (search.has('storageLocationName') && search.get('storageLocationName').length)
  33. return reply({fixture: 'storage/nameSearch'});
  34. if (search.has('storageLocationCode') && search.get('storageLocationCode').length)
  35. return reply({fixture: 'storage/codeSearch'});
  36. if (search.has('storageLocationType') && search.get('storageLocationType').length)
  37. return reply({fixture: 'storage/typeSearch'});
  38. if (search.has('isNotDisable') && search.get('isNotDisable').length)
  39. return reply({fixture: 'storage/disabledSearch'});
  40. if (search.has('id') && search.get('id').length)
  41. return reply({fixture: 'storage/info'});
  42. const page = search.get('page');
  43. reply({fixture: page === '1' ? 'storage/list1' : 'storage/list2'});
  44. },
  45. );
  46. successIntercept('/storage/addStorage');
  47. successIntercept('/storage/updateStorage');
  48. successIntercept('/storage/delStorage');
  49. exportIntercept('/storage/export');
  50. });
  51. const TABLE_NAME = 'storage_table',
  52. MODAL_NAME = 'storage_modal',
  53. LABEL = '库位';
  54. it('表格', function() {
  55. validateTableList(TABLE_NAME);
  56. const validate = validateTableSearch(TABLE_NAME);
  57. cy.get('#filter_storageName').type('库位');
  58. validate('searchName');
  59. cy.get('#filter_storageName').clear();
  60. cy.get('#filter_storageCode').type('code');
  61. validate('searchCode');
  62. cy.get('#filter_storageCode').clear();
  63. selectClick('filter_storageType', 1);
  64. validate('searchType');
  65. selectClick('filter_storageType', 0);
  66. selectClick('filter_storageState', 1);
  67. validate('searchDisabled');
  68. validateExport();
  69. });
  70. it.only('操作', function() {
  71. const {validateAdd, validateEdit} = validatePut(
  72. MODAL_NAME,
  73. LABEL,
  74. );
  75. validateAdd(function() {
  76. cy.getTestId('field_storageLocationCode').type('0001');
  77. cy.getTestId('field_storageLocationName').type('名称');
  78. selectClick('select_storageLocationType', 0);
  79. selectClick('select_storageIsNotDisable', 1);
  80. selectClick('select_storageIsProduct', 0);
  81. });
  82. validateEdit(TABLE_NAME, function() {
  83. cy.getTestId(MODAL_NAME).should('exist').and('be.visible');
  84. cy.getTestId(MODAL_NAME).find('h3').should('include.text', '修改库位');
  85. cy.getTestId('field_storageLocationCode').should('have.value', '0001');
  86. cy.getTestId('field_storageLocationName').should('have.value', '1号库位');
  87. validateSelect('select_storageLocationType', '原材料库位');
  88. validateSelect('select_storageIsNotDisable', '是');
  89. validateSelect('select_storageIsProduct', '是');
  90. });
  91. validateDelete(TABLE_NAME, LABEL);
  92. });
  93. });