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 10:09:38 UTC

[apisix-dashboard] branch master updated: chore: refactored test create-upstream-with-cors-form (#1848)

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 59d6f73  chore: refactored test create-upstream-with-cors-form (#1848)
59d6f73 is described below

commit 59d6f73dc428bf80e3001211d5e0b7679cb7897c
Author: Ayush das <ay...@gmail.com>
AuthorDate: Mon May 17 15:39:31 2021 +0530

    chore: refactored test create-upstream-with-cors-form (#1848)
---
 .../create-upstream-with-cors-form.spec.js         | 68 +++++++++++++---------
 1 file changed, 42 insertions(+), 26 deletions(-)

diff --git a/web/cypress/integration/consumer/create-upstream-with-cors-form.spec.js b/web/cypress/integration/consumer/create-upstream-with-cors-form.spec.js
index 9afa316..f6450a0 100644
--- a/web/cypress/integration/consumer/create-upstream-with-cors-form.spec.js
+++ b/web/cypress/integration/consumer/create-upstream-with-cors-form.spec.js
@@ -17,42 +17,58 @@
 /* eslint-disable no-undef */
 
 context('Create and Delete Consumer', () => {
-  beforeEach(() => {
-    cy.login();
-
-    cy.fixture('selector.json').as('domSelector');
-    cy.fixture('data.json').as('data');
-  });
 
   const selector = {
-    max_age: "#max_age",
-    allow_origins_by_regex: "#allow_origins_by_regex_0"
+    empty:'.ant-empty-normal',
+    username: '#username',
+    description: '#desc',
+    pluginCard: '.ant-card',
+    drawer: '.ant-drawer-content',
+    dropdown: '.rc-virtual-list',
+    disabledSwitcher: '#disable',
+    codeMirror: '.CodeMirror',
+    notification: '.ant-notification-notice-message',
+    notificationCloseIcon: '.ant-notification-close-icon',
+    rate: '#rate',
+    burst: '#burst',
+    key: '#key',
+    remote_addr: '[title=remote_addr]',
+    max_age: '#max_age',
+    allow_origins_by_regex: '#allow_origins_by_regex_0'
   }
 
   const data = {
+    consumerName: 'test_consumer',
+    description: 'desc_by_autotest',
+    createConsumerSuccess: 'Create Consumer Successfully',
+    deleteConsumerSuccess: 'Delete Consumer Successfully',
     time: 2,
   }
 
+  beforeEach(() => {
+    cy.login();
+  });
+
   it('creates consumer with cors form', function () {
     cy.visit('/');
     cy.contains('Consumer').click();
-    cy.get(this.domSelector.empty).should('be.visible');
+    cy.get(selector.empty).should('be.visible');
     cy.contains('Create').click();
     // basic information
-    cy.get(this.domSelector.username).type(this.data.consumerName);
-    cy.get(this.domSelector.description).type(this.data.description);
+    cy.get(selector.username).type(data.consumerName);
+    cy.get(selector.description).type(data.description);
     cy.contains('Next').click();
 
     // config auth plugin
-    cy.contains(this.domSelector.pluginCard, 'key-auth').within(() => {
+    cy.contains(selector.pluginCard, 'key-auth').within(() => {
       cy.contains('Enable').click({
         force: true
       });
     });
-    cy.focused(this.domSelector.drawer).should('exist');
-    cy.get(this.domSelector.disabledSwitcher).click().should('have.class', 'ant-switch-checked');
+    cy.focused(selector.drawer).should('exist');
+    cy.get(selector.disabledSwitcher).click().should('have.class', 'ant-switch-checked');
     // edit codemirror
-    cy.get(this.domSelector.codeMirror)
+    cy.get(selector.codeMirror)
       .first()
       .then((editor) => {
         editor[0].CodeMirror.setValue(
@@ -63,43 +79,43 @@ context('Create and Delete Consumer', () => {
         cy.contains('button', 'Submit').click();
       });
 
-    cy.contains(this.domSelector.pluginCard, 'cors').within(() => {
+    cy.contains(selector.pluginCard, 'cors').within(() => {
       cy.contains('Enable').click({
         force: true,
       });
     });
 
-    cy.get(this.domSelector.drawer).should('be.visible');
+    cy.get(selector.drawer).should('be.visible');
 
     cy.get(selector.max_age).clear();
     // config cors form
-    cy.get(this.domSelector.drawer).within(() => {
+    cy.get(selector.drawer).within(() => {
       cy.contains('Submit').click({
         force: true,
       });
     });
-    cy.get(this.domSelector.notification).should('contain', 'Invalid plugin data');
-    cy.get(this.domSelector.notificationCloseIcon).click().should('not.exist');
+    cy.get(selector.notification).should('contain', 'Invalid plugin data');
+    cy.get(selector.notificationCloseIcon).click().should('not.exist');
 
     cy.get(selector.max_age).type(data.time);
     cy.get(selector.allow_origins_by_regex).type('.*.test.com');
-    cy.get(this.domSelector.drawer).within(() => {
+    cy.get(selector.drawer).within(() => {
       cy.contains('Submit').click({
         force: true,
       });
     });
-    cy.get(this.domSelector.drawer).should('not.exist');
+    cy.get(selector.drawer).should('not.exist');
 
     cy.contains('button', 'Next').click();
     cy.contains('button', 'Submit').click();
-    cy.get(this.domSelector.notification).should('contain', this.data.createConsumerSuccess);
-    cy.get(this.domSelector.notificationCloseIcon).click().should('not.exist');
+    cy.get(selector.notification).should('contain', data.createConsumerSuccess);
+    cy.get(selector.notificationCloseIcon).click().should('not.exist');
   });
 
   it('delete the consumer', function () {
     cy.visit('/consumer/list');
-    cy.contains(this.data.consumerName).should('be.visible').siblings().contains('Delete').click();
+    cy.contains(data.consumerName).should('be.visible').siblings().contains('Delete').click();
     cy.contains('button', 'Confirm').click();
-    cy.get(this.domSelector.notification).should('contain', this.data.deleteConsumerSuccess);
+    cy.get(selector.notification).should('contain', data.deleteConsumerSuccess);
   });
 });