import { loginIntercept, loginSetup, menuIntercept, selectClick, validateSelect, validateDelete, validatePut, validateTableList, validateTableSearch, successIntercept, intercept, validateExport, exportIntercept, intoMenu, dictionaryIntercept, } from './utils'; describe('库位管理', function () { beforeEach(function () { loginIntercept(); menuIntercept(); loginSetup(); dictionaryIntercept(); intoMenu('基础数据管理', '库位管理'); }); 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'); exportIntercept('/storage/export'); }); const TABLE_NAME = 'storage_table', MODAL_NAME = 'storage_modal', LABEL = '库位'; it('表格', function () { validateTableList(TABLE_NAME); const validate = validateTableSearch(TABLE_NAME); 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(); selectClick('filter_storageType', 1); validate('searchType'); selectClick('filter_storageType', 0); selectClick('filter_storageState', 1); validate('searchDisabled'); validateExport(); }); it.only('操作', function () { const {validateAdd, validateEdit} = validatePut(MODAL_NAME, LABEL); validateAdd(function () { cy.getTestId('field_storageLocationCode').type('0001'); cy.getTestId('field_storageLocationName').type('名称'); selectClick('select_storageLocationType', 0); selectClick('select_storageIsNotDisable', 1); selectClick('select_storageIsProduct', 0); }); validateEdit(TABLE_NAME, function () { cy.getTestId(MODAL_NAME).should('exist').and('be.visible'); cy.getTestId(MODAL_NAME).find('h3').should('include.text', '修改库位'); cy.getTestId('field_storageLocationCode').should('have.value', '0001'); cy.getTestId('field_storageLocationName').should('have.value', '1号库位'); validateSelect('select_storageLocationType', '原材料库位'); validateSelect('select_storageIsNotDisable', '是'); validateSelect('select_storageIsProduct', '是'); }); validateDelete(TABLE_NAME, LABEL); }); });