import { loginIntercept, loginSetup, menuIntercept, menuTrigger, selectClick, validateSelect, validateDelete, validatePut, validateTableList, validateTableSearch, successIntercept, intercept, } from './utils'; describe('库位管理', function() { beforeEach(function() { loginIntercept(); menuIntercept(); loginSetup(); menuTrigger(2, 0); }); beforeEach(function() { intercept( '/storage/getStorage', function({url: reqUrl, reply}) { const url = new URL(reqUrl); const search = new URLSearchParams(url.search); if (search.has('storageLocationName') && search.get('storageLocationName').length) return reply({fixture: 'storage/nameSearch'}); if (search.has('storageLocationCode') && search.get('storageLocationCode').length) return reply({fixture: 'storage/codeSearch'}); if (search.has('storageLocationType') && search.get('storageLocationType').length) return reply({fixture: 'storage/typeSearch'}); if (search.has('isNotDisable') && search.get('isNotDisable').length) return reply({fixture: 'storage/disabledSearch'}); if (search.has('id') && search.get('id').length) return reply({fixture: 'storage/info'}); const page = search.get('page'); reply({fixture: page === '1' ? 'storage/list1' : 'storage/list2'}); }, ); successIntercept('/storage/addStorage'); successIntercept('/storage/updateStorage'); successIntercept('/storage/delStorage'); }); it('表格', function() { validateTableList('storage_table'); }); it('搜索', function() { const validate = validateTableSearch('storage_table'); cy.get('#filter_storageName').type('库位'); validate('searchName'); cy.get('#filter_storageName').clear(); cy.get('#filter_storageCode').type('code'); validate('searchCode'); cy.get('#filter_storageCode').clear(); cy.get('#filter_storageType').type('type'); validate('searchType'); cy.get('#filter_storageType').clear(); selectClick('filter_storageState', 1); validate('searchDisabled'); }); it('删除', function() { validateDelete('storage_table'); }); const {validateAdd, validateEdit} = validatePut( 'storage_modal', '库位', ); it('新增', function() { validateAdd(function() { cy.getTestId('field_storageLocationCode').type('0001'); cy.getTestId('field_storageLocationName').type('名称'); cy.getTestId('field_storageLocationType').type('类型'); cy.getTestId('field_storageWarehouseWhere').type('1号仓库'); selectClick('select_storageIsNotDisable', 1); }); }); it('修改', function() { validateEdit('storage_table', function() { cy.getTestId('storage_modal').should('exist').and('be.visible'); cy.getTestId('storage_modal').find('h3').should('include.text', '修改库位'); cy.getTestId('field_storageLocationCode').should('have.value', '0001'); cy.getTestId('field_storageLocationName').should('have.value', '1号库位'); cy.getTestId('field_storageLocationType').should('have.value', '原材料库位'); cy.getTestId('field_storageWarehouseWhere').should('have.value', '1号仓库'); validateSelect('select_storageIsNotDisable', '启用'); }); }); });