This is an automated email from the ASF dual-hosted git repository. sunyi pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/apisix-dashboard.git
The following commit(s) were added to refs/heads/master by this push: new e0dfc48 chore: refactored test edit-service-with-upstream.sepc.js (#1875) e0dfc48 is described below commit e0dfc484d80deca256e4ae387f2741500ad6f149 Author: Ayush das <ayush24...@gmail.com> AuthorDate: Mon May 17 07:13:40 2021 +0530 chore: refactored test edit-service-with-upstream.sepc.js (#1875) --- .../service/edit-service-with-upstream.spec.js | 91 ++++++++++++++-------- 1 file changed, 59 insertions(+), 32 deletions(-) diff --git a/web/cypress/integration/service/edit-service-with-upstream.spec.js b/web/cypress/integration/service/edit-service-with-upstream.spec.js index 150a9e4..39878bb 100644 --- a/web/cypress/integration/service/edit-service-with-upstream.spec.js +++ b/web/cypress/integration/service/edit-service-with-upstream.spec.js @@ -17,24 +17,49 @@ /* eslint-disable no-undef */ context('Edit Service with Upstream', () => { + const selector = { + empty: '.ant-empty-normal', + name: '#name', + description: '#desc', + nodes_0_host: '#nodes_0_host', + nodes_0_port: '#nodes_0_port', + nodes_0_weight: '#nodes_0_weight', + notification: '.ant-notification-notice-message', + upstreamSelector: '[data-cy=upstream_selector]', + input: ':input', + nameSearch: '[title=Name]', + }; + + const data = { + upstreamName: 'test_upstream', + description: 'desc_by_autotest', + ip1: '127.0.0.1', + createUpstreamSuccess: 'Create Upstream Successfully', + serviceName: 'test_service', + createServiceSuccess: 'Create Service Successfully', + ip2: '127.0.0.2', + port: '80', + weight: 1, + editServiceSuccess: 'Configure Service Successfully', + deleteServiceSuccess: 'Delete Service Successfully', + deleteUpstreamSuccess: 'Delete Upstream Successfully', + }; + beforeEach(() => { cy.login(); - - cy.fixture('selector.json').as('domSelector'); - cy.fixture('data.json').as('data'); }); it('should create a test upstream', function () { cy.visit('/upstream/list'); - cy.get(this.domSelector.empty).should('be.visible'); + cy.get(selector.empty).should('be.visible'); cy.contains('Create').click(); - cy.get(this.domSelector.name).type(this.data.upstreamName); - cy.get(this.domSelector.nodes_0_host).type(this.data.ip1); - cy.get(this.domSelector.nodes_0_port).clear().type('7000'); - cy.get(this.domSelector.nodes_0_weight).clear().type(1); + cy.get(selector.name).type(data.upstreamName); + cy.get(selector.nodes_0_host).type(data.ip1); + cy.get(selector.nodes_0_port).clear().type('7000'); + cy.get(selector.nodes_0_weight).clear().type(1); cy.contains('Next').click(); cy.contains('Submit').click(); - cy.get(this.domSelector.notification).should('contain', this.data.createUpstreamSuccess); + cy.get(selector.notification).should('contain', data.createUpstreamSuccess); cy.url().should('contains', 'upstream/list'); }); @@ -42,56 +67,58 @@ context('Edit Service with Upstream', () => { cy.visit('/'); cy.get('.ant-empty').should('be.visible'); cy.contains('Service').click(); - cy.get(this.domSelector.empty).should('be.visible'); + cy.get(selector.empty).should('be.visible'); cy.contains('Create').click(); - cy.get(this.domSelector.name).type(this.data.serviceName); - cy.get(this.domSelector.description).type(this.data.description); - cy.get(this.domSelector.upstreamSelector).click(); - cy.contains(this.data.upstreamName).click(); - cy.get(this.domSelector.input).should('be.disabled'); + cy.get(selector.name).type(data.serviceName); + cy.get(selector.description).type(data.description); + cy.get(selector.upstreamSelector).click(); + cy.contains(data.upstreamName).click(); + cy.get(selector.input).should('be.disabled'); cy.contains('Next').click(); cy.contains('Next').click(); cy.contains('Submit').click(); - cy.get(this.domSelector.notification).should('contain', this.data.createServiceSuccess); + cy.get(selector.notification).should('contain', data.createServiceSuccess); }); it('should edit the service', function () { cy.visit('/service/list'); - cy.get(this.domSelector.nameSearch).type(this.data.serviceName); + cy.get(selector.nameSearch).type(data.serviceName); cy.contains('Search').click(); - cy.contains(this.data.serviceName).siblings().contains('Configure').click(); + cy.contains(data.serviceName).siblings().contains('Configure').click(); cy.wait(500); - cy.get(this.domSelector.nodes_0_host).click({ - force: true - }).should('value', this.data.ip1); - cy.get(this.domSelector.input).should('be.disabled'); + cy.get(selector.nodes_0_host) + .click({ + force: true, + }) + .should('value', data.ip1); + cy.get(selector.input).should('be.disabled'); - cy.get(this.domSelector.upstreamSelector).click(); + cy.get(selector.upstreamSelector).click(); cy.contains('.ant-select-item-option-content', 'Custom').click(); - cy.get(this.domSelector.nodes_0_host).should('not.be.disabled').clear().type(this.data.ip2); - cy.get(this.domSelector.nodes_0_port).type(this.data.port); - cy.get(this.domSelector.nodes_0_weight).type(this.data.weight); + cy.get(selector.nodes_0_host).should('not.be.disabled').clear().type(data.ip2); + cy.get(selector.nodes_0_port).type(data.port); + cy.get(selector.nodes_0_weight).type(data.weight); cy.contains('Next').click(); cy.contains('Next').click(); cy.contains('Submit').click(); - cy.get(this.domSelector.notification).should('contain', this.data.editServiceSuccess); + cy.get(selector.notification).should('contain', data.editServiceSuccess); }); it('should delete this service and upstream', function () { cy.visit('/service/list'); - cy.get(this.domSelector.nameSearch).type(this.data.serviceName); + cy.get(selector.nameSearch).type(data.serviceName); cy.contains('Search').click(); - cy.contains(this.data.serviceName).siblings().contains('Delete').click(); + cy.contains(data.serviceName).siblings().contains('Delete').click(); cy.contains('button', 'Confirm').click(); - cy.get(this.domSelector.notification).should('contain', this.data.deleteServiceSuccess); + cy.get(selector.notification).should('contain', data.deleteServiceSuccess); cy.visit('/'); cy.contains('Upstream').click(); - cy.contains(this.data.upstreamName).siblings().contains('Delete').click(); + cy.contains(data.upstreamName).siblings().contains('Delete').click(); cy.contains('button', 'Confirm').click(); - cy.get(this.domSelector.notification).should('contain', this.data.deleteUpstreamSuccess); + cy.get(selector.notification).should('contain', data.deleteUpstreamSuccess); }); });