| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153 |
- import {NETWORK_URL, loginIntercept, loginSetup, menuIntercept} from './utils/setup';
- import {menuTrigger, selectClick, selectGetValue} from './utils/utils';
- describe('库位管理', function() {
- beforeEach(function() {
- loginIntercept();
- menuIntercept();
- loginSetup();
- menuTrigger(2, 0);
- });
- beforeEach(function() {
- cy.intercept(
- `${NETWORK_URL}/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'});
- },
- );
- cy.intercept(`${NETWORK_URL}/storage/addStorage*`, {fixture: 'success', delay: 100});
- cy.intercept(`${NETWORK_URL}/storage/updateStorage*`, {fixture: 'success', delay: 100});
- cy.intercept(`${NETWORK_URL}/storage/delStorage*`, {fixture: 'success', delay: 100});
- });
- it('表格', function() {
- cy.getTestId('storage_table').find('table').find('.ant-table-tbody')
- .children('.ant-table-row').should('have.length', 3);
- cy.get('.ant-pagination').find('li[title="2"]').click();
- cy.getTestId('storage_table').find('table').find('.ant-table-tbody')
- .children('.ant-table-row').should('have.length', 2);
- });
- it('搜索', function() {
- cy.get('.ant-pagination').find('li[title="2"]').click();
- cy.get('#filter_storageName').type('库位');
- cy.getTestId('search_btn').click();
- cy.get('.ant-pagination').find('li[title="1"]')
- .should('have.class', 'ant-pagination-item-active');
- cy.getTestId('storage_table').find('table').find('.ant-table-tbody')
- .children('.ant-table-row').first().find('td').first()
- .should('include.html', 'searchName');
- cy.get('#filter_storageName').clear();
- cy.get('#filter_storageCode').type('code');
- cy.getTestId('search_btn').click();
- cy.getTestId('storage_table').find('table').find('.ant-table-tbody')
- .children('.ant-table-row').first().find('td').first()
- .should('include.html', 'searchCode');
- cy.get('#filter_storageCode').clear();
- cy.get('#filter_storageType').type('type');
- cy.getTestId('search_btn').click();
- cy.getTestId('storage_table').find('table').find('.ant-table-tbody')
- .children('.ant-table-row').first().find('td').first()
- .should('include.html', 'searchType');
- cy.get('#filter_storageType').clear();
- selectClick('filter_storageState', 1);
- cy.getTestId('search_btn').click();
- cy.getTestId('storage_table').find('table').find('.ant-table-tbody')
- .children('.ant-table-row').first().find('td').first()
- .should('include.html', 'searchDisabled');
- });
- it('删除', function() {
- cy.getTestId('storage_table').find('table').find('.ant-table-tbody')
- .children('.ant-table-row').first().find('td').last().find('.ant-btn')
- .last().click();
- cy.get('.ant-modal-content').should('be.visible');
- cy.get('.ant-modal-confirm-btns').children().last().trigger('click');
- cy.getTestId('storage_table').find('table').find('.ant-table-tbody')
- .children('.ant-table-row').first().find('td').last().children().last()
- .should('have.class', 'ant-btn-loading');
- cy.getTestId('storage_table').find('table').find('.ant-table-tbody')
- .children('.ant-table-row').first().find('td').last().children().first()
- .should('have.attr', 'disabled');
- cy.get('.ant-message-notice-content').should('include.text', '删除成功');
- });
- it('新增', function() {
- cy.getTestId('add_btn').click();
- cy.getTestId('storage_modal').should('exist').and('be.visible');
- cy.getTestId('storage_modal').find('h3').should('include.text', '新增库位');
- 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);
- cy.getTestId('storage_modal').find('form').submit();
- cy.getTestId('modal_btn_group').find('.ant-btn').first()
- .should('have.class', 'ant-btn-loading');
- cy.getTestId('modal_btn_group').find('.ant-btn').last()
- .should('have.attr', 'disabled');
- cy.get('.ant-message-notice-content').should('include.text', '新增成功');
- cy.getTestId('storage_modal').should('not.exist');
- });
- it('修改', function() {
- cy.getTestId('storage_table').find('table').find('.ant-table-tbody')
- .children('.ant-table-row').first().find('td').last().find('.ant-btn')
- .first().click();
- 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号仓库');
- selectGetValue('select_storageIsNotDisable', '启用');
- cy.getTestId('storage_modal').find('form').submit();
- cy.getTestId('modal_btn_group').find('.ant-btn').first()
- .should('have.class', 'ant-btn-loading');
- cy.getTestId('modal_btn_group').find('.ant-btn').last()
- .should('have.attr', 'disabled');
- cy.get('.ant-message-notice-content').should('include.text', '修改成功');
- cy.getTestId('storage_modal').should('not.exist');
- });
- });
|