From 7175b66722f7ed54342c4db23c5c8408520d7e4c Mon Sep 17 00:00:00 2001 From: iamayushdas Date: Sat, 8 May 2021 14:58:52 +0530 Subject: [PATCH 1/2] chore: refactored test create-service-with-not-select-upstream.spec.js --- ...e-service-with-not-select-upstream.spec.js | 62 ++++++++++++------- 1 file changed, 41 insertions(+), 21 deletions(-) diff --git a/web/cypress/integration/service/create-service-with-not-select-upstream.spec.js b/web/cypress/integration/service/create-service-with-not-select-upstream.spec.js index aec999a92a..b14b800045 100644 --- a/web/cypress/integration/service/create-service-with-not-select-upstream.spec.js +++ b/web/cypress/integration/service/create-service-with-not-select-upstream.spec.js @@ -17,53 +17,73 @@ /* eslint-disable no-undef */ context('Edit Service with not select Upstream', () => { + const selector = { + name: '#name', + description: '#desc', + nodes_0_host: '#nodes_0_host', + nodes_0_port: '#nodes_0_port', + nodes_0_weight: '#nodes_0_weight', + input: ':input', + notification: '.ant-notification-notice-message', + nameSearch: '[title=Name]', + }; + + const data = { + serviceName: 'test_service', + createServiceSuccess: 'Create Service Successfully', + deleteServiceSuccess: 'Delete Service Successfully', + editServiceSuccess: 'Configure Service Successfully', + port: '80', + weight: 1, + description: 'desc_by_autotest', + ip1: '127.0.0.1', + ip2: '127.0.0.2', + }; + beforeEach(() => { cy.login(); - - cy.fixture('selector.json').as('domSelector'); - cy.fixture('data.json').as('data'); }); it('should create a test service', function () { cy.visit('/'); cy.contains('Service').click(); 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.nodes_0_host).click(); - 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.serviceName); + cy.get(selector.description).type(data.description); + cy.get(selector.nodes_0_host).click(); + 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('Next').click(); - cy.get(this.domSelector.input).should('be.disabled'); + cy.get(selector.input).should('be.disabled'); 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).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.get(this.domSelector.input).should('be.disabled'); + cy.get(selector.input).should('be.disabled'); 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); }); }); From fdd841bc75bee6df48736d468380b7deb59a133c Mon Sep 17 00:00:00 2001 From: iamayushdas Date: Tue, 11 May 2021 21:04:01 +0530 Subject: [PATCH 2/2] chore: added more data --- .../create-service-with-not-select-upstream.spec.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/web/cypress/integration/service/create-service-with-not-select-upstream.spec.js b/web/cypress/integration/service/create-service-with-not-select-upstream.spec.js index b14b800045..53903ab609 100644 --- a/web/cypress/integration/service/create-service-with-not-select-upstream.spec.js +++ b/web/cypress/integration/service/create-service-with-not-select-upstream.spec.js @@ -26,6 +26,7 @@ context('Edit Service with not select Upstream', () => { input: ':input', notification: '.ant-notification-notice-message', nameSearch: '[title=Name]', + notificationCloseIcon: '.ant-notification-close-icon', }; const data = { @@ -38,6 +39,8 @@ context('Edit Service with not select Upstream', () => { description: 'desc_by_autotest', ip1: '127.0.0.1', ip2: '127.0.0.2', + port0: '7000', + weight0: '1', }; beforeEach(() => { @@ -52,8 +55,8 @@ context('Edit Service with not select Upstream', () => { cy.get(selector.description).type(data.description); cy.get(selector.nodes_0_host).click(); 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.get(selector.nodes_0_port).clear().type(data.port0); + cy.get(selector.nodes_0_weight).clear().type(data.weight0); cy.contains('Next').click(); cy.contains('Next').click(); cy.get(selector.input).should('be.disabled'); @@ -85,5 +88,6 @@ context('Edit Service with not select Upstream', () => { cy.contains(data.serviceName).siblings().contains('Delete').click(); cy.contains('button', 'Confirm').click(); cy.get(selector.notification).should('contain', data.deleteServiceSuccess); + cy.get(selector.notificationCloseIcon).click(); }); });