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 02:27:29 UTC

[apisix-dashboard] branch master updated: chore: refactored test create-plugin-template-with-route.spec.js (#1857)

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 e599dc2  chore: refactored test create-plugin-template-with-route.spec.js (#1857)
e599dc2 is described below

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

    chore: refactored test create-plugin-template-with-route.spec.js (#1857)
---
 .../create-plugin-template-with-route.spec.js      | 98 ++++++++++++++--------
 1 file changed, 64 insertions(+), 34 deletions(-)

diff --git a/web/cypress/integration/pluginTemplate/create-plugin-template-with-route.spec.js b/web/cypress/integration/pluginTemplate/create-plugin-template-with-route.spec.js
index 4a3b703..83954d5 100644
--- a/web/cypress/integration/pluginTemplate/create-plugin-template-with-route.spec.js
+++ b/web/cypress/integration/pluginTemplate/create-plugin-template-with-route.spec.js
@@ -17,76 +17,104 @@
 /* eslint-disable no-undef */
 
 context('Create PluginTemplate Binding To Route', () => {
+  const selector = {
+    empty: '.ant-empty-normal',
+    description: '#desc',
+    notification: '.ant-notification-notice-message',
+    refresh: '.anticon-reload',
+    descriptionSelector: '[title=Description]',
+    name: '#name',
+    nodes_0_host: '#nodes_0_host',
+    nodes_0_port: '#nodes_0_port',
+    nodes_0_weight: '#nodes_0_weight',
+    customSelector: '[title=Custom]',
+    notificationClose: '.anticon-close',
+    nameSelector: '[title=Name]',
+    redirectURIInput: '#redirectURI',
+    redirectCodeSelector: '#ret_code',
+  };
+
+  const data = {
+    createPluginTemplateSuccess: 'Create Plugin Template Successfully',
+    pluginTemplateName: 'test_plugin_template1',
+    pluginTemplateName2: 'test_plugin_template2',
+    pluginTemplateErrorAlert: 'Request Error Code: 10000',
+    routeName: 'test_route',
+    submitSuccess: 'Submit Successfully',
+    deletePluginTemplateSuccess: 'Delete Plugin Template Successfully',
+    deleteRouteSuccess: 'Delete Route Successfully',
+    ip1: '127.0.0.1',
+    port: '80',
+    weight: 1,
+  };
+
   beforeEach(() => {
     cy.login();
-
-    cy.fixture('selector.json').as('domSelector');
-    cy.fixture('data.json').as('data');
   });
 
   it('should create test pluginTemplate', function () {
     cy.visit('/');
     cy.contains('Route').click();
-    cy.get(this.domSelector.empty).should('be.visible');
+    cy.get(selector.empty).should('be.visible');
     cy.contains('Advanced').should('be.visible').click();
     cy.contains('Plugin Template Config').should('be.visible').click();
-    cy.get(this.domSelector.empty).should('be.visible');
+    cy.get(selector.empty).should('be.visible');
     cy.contains('Create').click();
-    cy.get(this.domSelector.description).type(this.data.pluginTemplateName);
+    cy.get(selector.description).type(data.pluginTemplateName);
     cy.contains('Next').click();
     cy.contains('Next').click();
     cy.contains('Submit').click();
-    cy.get(this.domSelector.notification).should('contain', this.data.createPluginTemplateSuccess);
+    cy.get(selector.notification).should('contain', data.createPluginTemplateSuccess);
 
     cy.visit('/routes/list');
     cy.contains('Create').click();
 
     // NOTE: make sure all components rerender done
     cy.contains('Next').click().click();
-    cy.get(this.domSelector.name).type(this.data.routeName);
+    cy.get(selector.name).type(data.routeName);
     cy.contains('Next').click();
-    cy.get(this.domSelector.nodes_0_host).type(this.data.ip1);
-    cy.get(this.domSelector.nodes_0_port).clear().type(this.data.port);
-    cy.get(this.domSelector.nodes_0_weight).clear().type(this.data.weight);
+    cy.get(selector.nodes_0_host).type(data.ip1);
+    cy.get(selector.nodes_0_port).clear().type(data.port);
+    cy.get(selector.nodes_0_weight).clear().type(data.weight);
     cy.contains('Next').click();
     cy.contains('Custom').should('be.visible');
-    cy.get(this.domSelector.customSelector).click();
-    cy.contains(this.data.pluginTemplateName).click();
+    cy.get(selector.customSelector).click();
+    cy.contains(data.pluginTemplateName).click();
 
     cy.contains('Next').click();
     cy.contains('Submit').click();
-    cy.contains(this.data.submitSuccess);
+    cy.contains(data.submitSuccess);
     cy.contains('Goto List').click();
     cy.url().should('contains', 'routes/list');
   });
 
   it('should delete the pluginTemplate failure', function () {
     cy.visit('plugin-template/list');
-    cy.get(this.domSelector.refresh).click();
+    cy.get(selector.refresh).click();
 
-    cy.get(this.domSelector.descriptionSelector).type(this.data.pluginTemplateName);
+    cy.get(selector.descriptionSelector).type(data.pluginTemplateName);
     cy.contains('button', 'Search').click();
-    cy.contains(this.data.pluginTemplateName).siblings().contains('Delete').click();
+    cy.contains(data.pluginTemplateName).siblings().contains('Delete').click();
     cy.contains('button', 'Confirm').click();
-    cy.get(this.domSelector.notification).should('contain', this.data.pluginTemplateErrorAlert);
-    cy.get(this.domSelector.notificationClose).should('be.visible').click();
+    cy.get(selector.notification).should('contain', data.pluginTemplateErrorAlert);
+    cy.get(selector.notificationClose).should('be.visible').click();
   });
 
   it('should edit the route with pluginTemplate', function () {
     cy.visit('routes/list');
 
-    cy.get(this.domSelector.nameSelector).type(this.data.routeName);
+    cy.get(selector.nameSelector).type(data.routeName);
     cy.contains('Search').click();
-    cy.contains(this.data.routeName).siblings().contains('Configure').click();
+    cy.contains(data.routeName).siblings().contains('Configure').click();
 
     cy.contains('Forbidden').click();
     cy.contains('Custom').click();
-    cy.get(this.domSelector.redirectURIInput).clear().type('123');
-    cy.get(this.domSelector.redirectCodeSelector).click();
+    cy.get(selector.redirectURIInput).clear().type('123');
+    cy.get(selector.redirectCodeSelector).click();
     cy.contains('301(Permanent Redirect)').click();
     cy.contains('Next').click();
     cy.contains('Submit').click();
-    cy.contains(this.data.submitSuccess);
+    cy.contains(data.submitSuccess);
     cy.contains('Goto List').click();
     cy.url().should('contains', 'routes/list');
   });
@@ -94,21 +122,23 @@ context('Create PluginTemplate Binding To Route', () => {
   it('should delete the pluginTemplate successfully', function () {
     cy.visit('plugin-template/list');
 
-    cy.get(this.domSelector.refresh).click();
-    cy.get(this.domSelector.descriptionSelector).type(this.data.pluginTemplateName);
+    cy.get(selector.refresh).click();
+    cy.get(selector.descriptionSelector).type(data.pluginTemplateName);
     cy.contains('button', 'Search').click();
-    cy.contains(this.data.pluginTemplateName).siblings().contains('Delete').click();
+    cy.contains(data.pluginTemplateName).siblings().contains('Delete').click();
     cy.contains('button', 'Confirm').click();
-    cy.get(this.domSelector.notification).should('contain', this.data.deletePluginTemplateSuccess);
+    cy.get(selector.notification).should('contain', data.deletePluginTemplateSuccess);
 
     cy.visit('/routes/list');
-    cy.get(this.domSelector.nameSelector).type(this.data.routeName);
+    cy.get(selector.nameSelector).type(data.routeName);
     cy.contains('Search').click();
-    cy.contains(this.data.routeName).siblings().contains('More').click();
+    cy.contains(data.routeName).siblings().contains('More').click();
     cy.contains('Delete').should('be.visible').click();
-    cy.get('.ant-modal-content').should('be.visible').within(() => {
-      cy.contains('OK').click();
-    });
-    cy.get(this.domSelector.notification).should('contain', this.data.deleteRouteSuccess);
+    cy.get('.ant-modal-content')
+      .should('be.visible')
+      .within(() => {
+        cy.contains('OK').click();
+      });
+    cy.get(selector.notification).should('contain', data.deleteRouteSuccess);
   });
 });