You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by su...@apache.org on 2021/05/17 01:45:13 UTC

[apisix-dashboard] branch master updated: chore: refactored test create-service-with-not-select-upstream.spec.js (#1874)

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 e133373  chore: refactored test create-service-with-not-select-upstream.spec.js (#1874)
e133373 is described below

commit e1333738eee5658465d5234ae698fdfa8ace6f73
Author: Ayush das <ay...@gmail.com>
AuthorDate: Mon May 17 07:15:02 2021 +0530

    chore: refactored test create-service-with-not-select-upstream.spec.js (#1874)
---
 ...create-service-with-not-select-upstream.spec.js | 66 +++++++++++++++-------
 1 file changed, 45 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 aec999a..53903ab 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,77 @@
 /* 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]',
+    notificationCloseIcon: '.ant-notification-close-icon',
+  };
+
+  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',
+    port0: '7000',
+    weight0: '1',
+  };
+
   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(data.port0);
+    cy.get(selector.nodes_0_weight).clear().type(data.weight0);
     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);
+    cy.get(selector.notificationCloseIcon).click();
   });
 });