storage.cy.ts 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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('/storage/getStorage', function ({url: reqUrl, reply}) {
  28. const url = new URL(reqUrl);
  29. const search = new URLSearchParams(url.search);
  30. if (search.has('storageLocationName') && search.get('storageLocationName').length)
  31. return reply({fixture: 'storage/nameSearch'});
  32. if (search.has('storageLocationCode') && search.get('storageLocationCode').length)
  33. return reply({fixture: 'storage/codeSearch'});
  34. if (search.has('storageLocationType') && search.get('storageLocationType').length)
  35. return reply({fixture: 'storage/typeSearch'});
  36. if (search.has('isNotDisable') && search.get('isNotDisable').length)
  37. return reply({fixture: 'storage/disabledSearch'});
  38. if (search.has('id') && search.get('id').length) return reply({fixture: 'storage/info'});
  39. const page = search.get('page');
  40. reply({fixture: page === '1' ? 'storage/list1' : 'storage/list2'});
  41. });
  42. successIntercept('/storage/addStorage');
  43. successIntercept('/storage/updateStorage');
  44. successIntercept('/storage/delStorage');
  45. exportIntercept('/storage/export');
  46. });
  47. const TABLE_NAME = 'storage_table',
  48. MODAL_NAME = 'storage_modal',
  49. LABEL = '库位';
  50. it('表格', function () {
  51. validateTableList(TABLE_NAME);
  52. const validate = validateTableSearch(TABLE_NAME);
  53. cy.get('#filter_storageName').type('库位');
  54. validate('searchName');
  55. cy.get('#filter_storageName').clear();
  56. cy.get('#filter_storageCode').type('code');
  57. validate('searchCode');
  58. cy.get('#filter_storageCode').clear();
  59. selectClick('filter_storageType', 1);
  60. validate('searchType');
  61. selectClick('filter_storageType', 0);
  62. selectClick('filter_storageState', 1);
  63. validate('searchDisabled');
  64. validateExport();
  65. });
  66. it.only('操作', function () {
  67. const {validateAdd, validateEdit} = validatePut(MODAL_NAME, LABEL);
  68. validateAdd(function () {
  69. cy.getTestId('field_storageLocationCode').type('0001');
  70. cy.getTestId('field_storageLocationName').type('名称');
  71. selectClick('select_storageLocationType', 0);
  72. selectClick('select_storageIsNotDisable', 1);
  73. selectClick('select_storageIsProduct', 0);
  74. });
  75. validateEdit(TABLE_NAME, function () {
  76. cy.getTestId(MODAL_NAME).should('exist').and('be.visible');
  77. cy.getTestId(MODAL_NAME).find('h3').should('include.text', '修改库位');
  78. cy.getTestId('field_storageLocationCode').should('have.value', '0001');
  79. cy.getTestId('field_storageLocationName').should('have.value', '1号库位');
  80. validateSelect('select_storageLocationType', '原材料库位');
  81. validateSelect('select_storageIsNotDisable', '是');
  82. validateSelect('select_storageIsProduct', '是');
  83. });
  84. validateDelete(TABLE_NAME, LABEL);
  85. });
  86. });