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:36:30 UTC

[apisix-dashboard] branch master updated: chore: refactored test create_and_edit_upstream_with_no_nodes.spec.js (#1880)

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 783d9bc  chore: refactored test create_and_edit_upstream_with_no_nodes.spec.js (#1880)
783d9bc is described below

commit 783d9bcad159dcaa05804277f75588e59c1f466b
Author: Ayush das <ay...@gmail.com>
AuthorDate: Mon May 17 07:06:23 2021 +0530

    chore: refactored test create_and_edit_upstream_with_no_nodes.spec.js (#1880)
---
 .../create_and_edit_upstream_with_no_nodes.spec.js | 90 ++++++++++++----------
 1 file changed, 51 insertions(+), 39 deletions(-)

diff --git a/web/cypress/integration/upstream/create_and_edit_upstream_with_no_nodes.spec.js b/web/cypress/integration/upstream/create_and_edit_upstream_with_no_nodes.spec.js
index 8ccea8b..e65e7fb 100644
--- a/web/cypress/integration/upstream/create_and_edit_upstream_with_no_nodes.spec.js
+++ b/web/cypress/integration/upstream/create_and_edit_upstream_with_no_nodes.spec.js
@@ -17,54 +17,66 @@
 /* eslint-disable no-undef */
 
 context('Create and Delete Upstream', () => {
-    beforeEach(() => {
-      cy.login();
+  const selector = {
+    name: '#name',
+    description: '#desc',
+    upstreamNodeMinus0: '[data-cy=upstream-node-minus-0]',
+    notification: '.ant-notification-notice-message',
+    nameSelector: '[title=Name]',
+  };
 
-      cy.fixture('selector.json').as('domSelector');
-      cy.fixture('data.json').as('data');
-    });
-
-    it('should create upstream with no nodes', function () {
-      cy.visit('/');
-      cy.contains('Upstream').click();
-      cy.contains('Create').click();
+  const data = {
+    upstreamName: 'test_upstream',
+    description: 'desc_by_autotest',
+    createUpstreamSuccess: 'Create Upstream Successfully',
+    configureUpstreamSuccess: 'Configure Upstream Successfully',
+    deleteUpstreamSuccess: 'Delete Upstream Successfully',
+  };
 
-      cy.get(this.domSelector.name).type(this.data.upstreamName);
-      cy.get(this.domSelector.description).type(this.data.description);
+  beforeEach(() => {
+    cy.login();
+  });
 
-      // delete all nodes
-      cy.get(this.domSelector.upstreamNodeMinus0).click();
+  it('should create upstream with no nodes', function () {
+    cy.visit('/');
+    cy.contains('Upstream').click();
+    cy.contains('Create').click();
 
-      cy.contains('Next').click();
-      cy.contains('Submit').click();
-      cy.get(this.domSelector.notification).should('contain', this.data.createUpstreamSuccess);
-      cy.url().should('contains', 'upstream/list');
-    });
+    cy.get(selector.name).type(data.upstreamName);
+    cy.get(selector.description).type(data.description);
 
-    it('should configure the upstream with no nodes', function () {
-      cy.visit('/');
-      cy.contains('Upstream').click();
+    // delete all nodes
+    cy.get(selector.upstreamNodeMinus0).click();
 
-      cy.get(this.domSelector.nameSelector).type(this.data.upstreamName);
-      cy.contains('Search').click();
-      cy.contains(this.data.upstreamName).siblings().contains('Configure').click();
+    cy.contains('Next').click();
+    cy.contains('Submit').click();
+    cy.get(selector.notification).should('contain', data.createUpstreamSuccess);
+    cy.url().should('contains', 'upstream/list');
+  });
 
-      cy.get(this.domSelector.upstreamNodeMinus0).should('not.exist');
-      cy.contains('Next').click();
-      cy.contains('Submit').click({
-        force: true,
-      });
+  it('should configure the upstream with no nodes', function () {
+    cy.visit('/');
+    cy.contains('Upstream').click();
 
-      cy.get(this.domSelector.notification).should('contain', this.data.configureUpstreamSuccess);
-      cy.url().should('contains', 'upstream/list');
+    cy.get(selector.nameSelector).type(data.upstreamName);
+    cy.contains('Search').click();
+    cy.contains(data.upstreamName).siblings().contains('Configure').click();
 
+    cy.get(selector.upstreamNodeMinus0).should('not.exist');
+    cy.contains('Next').click();
+    cy.contains('Submit').click({
+      force: true,
     });
 
-    it('should delete the upstream', function () {
-      cy.visit('/');
-      cy.contains('Upstream').click();
-      cy.contains(this.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.configureUpstreamSuccess);
+    cy.url().should('contains', 'upstream/list');
+  });
+
+  it('should delete the upstream', function () {
+    cy.visit('/');
+    cy.contains('Upstream').click();
+    cy.contains(data.upstreamName).siblings().contains('Delete').click();
+    cy.contains('button', 'Confirm').click();
+    cy.get(selector.notification).should('contain', data.deleteUpstreamSuccess);
   });
+});