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 6030d95 chore: refactored test create-route-with-limit-count-plugin-form.spec.js (#1864) 6030d95 is described below commit 6030d95ba943b33cddf90b78899ee8e72529230a Author: Ayush das <ayush24...@gmail.com> AuthorDate: Mon May 17 07:36:30 2021 +0530 chore: refactored test create-route-with-limit-count-plugin-form.spec.js (#1864) --- ...eate-route-with-limit-count-plugin-form.spec.js | 87 +++++++++++++--------- 1 file changed, 51 insertions(+), 36 deletions(-) diff --git a/web/cypress/integration/route/create-route-with-limit-count-plugin-form.spec.js b/web/cypress/integration/route/create-route-with-limit-count-plugin-form.spec.js index b1df99e..0d1bea3 100644 --- a/web/cypress/integration/route/create-route-with-limit-count-plugin-form.spec.js +++ b/web/cypress/integration/route/create-route-with-limit-count-plugin-form.spec.js @@ -18,6 +18,18 @@ context('Create and delete route with limit-count form', () => { const selector = { + empty: '.ant-empty-normal', + name: '#name', + description: '#desc', + disabledSwitcher: '#disable', + drawer: '.ant-drawer-content', + nodes_0_host: '#nodes_0_host', + nodes_0_port: '#nodes_0_port', + nodes_0_weight: '#nodes_0_weight', + deleteAlert: '.ant-modal-body', + notificationCloseIcon: '.ant-notification-close-icon', + notification: '.ant-notification-notice-message', + pluginCard: '.ant-card', count: '#count', time_window: '#time_window', redis_timeout: '#time_window', @@ -28,82 +40,87 @@ context('Create and delete route with limit-count form', () => { redis_port: '#redis_port', redis_password: '#redis_password', redis_database: '#redis_database', - redis_timeout: '#redis_timeout', redis_cluster_name: '#redis_cluster_name', redis_cluster_nodes_0: '#redis_cluster_nodes_0', redis_cluster_nodes_1: '#redis_cluster_nodes_1', + dropdown: '.rc-virtual-list', + }; + + const data = { + deleteRouteSuccess: 'Delete Route Successfully', + submitSuccess: 'Submit Successfully', + port: '80', + weight: 1, } + beforeEach(() => { cy.login(); - - cy.fixture('selector.json').as('domSelector'); - cy.fixture('data.json').as('data'); }); it('should create route with limit-count form', function () { cy.visit('/'); cy.contains('Route').click(); - cy.get(this.domSelector.empty).should('be.visible'); + cy.get(selector.empty).should('be.visible'); cy.contains('Create').click(); cy.contains('Next').click().click(); - cy.get(this.domSelector.name).type('routeName'); - cy.get(this.domSelector.description).type('desc'); + cy.get(selector.name).type('routeName'); + cy.get(selector.description).type('desc'); cy.contains('Next').click(); - cy.get(this.domSelector.nodes_0_host).type('127.0.0.1'); - 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('127.0.0.1'); + cy.get(selector.nodes_0_port).clear().type(data.port); + cy.get(selector.nodes_0_weight).clear().type(data.weight); cy.contains('Next').click(); // config limit-count form with local policy - cy.contains(this.domSelector.pluginCard, 'limit-count').within(() => { + cy.contains(selector.pluginCard, 'limit-count').within(() => { cy.get('button').click({ force: true, }); }); - cy.focused(this.domSelector.drawer).should('exist'); - cy.get(this.domSelector.disabledSwitcher).click(); + cy.focused(selector.drawer).should('exist'); + cy.get(selector.disabledSwitcher).click(); cy.get(selector.count).type(1); cy.get(selector.time_window).type(1); cy.get(selector.rejected_code).type(500); - 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'); // config limit-count form with redis policy - cy.contains(this.domSelector.pluginCard, 'limit-count').within(() => { + cy.contains(selector.pluginCard, 'limit-count').within(() => { cy.get('button').click({ force: true, }); }); - cy.focused(this.domSelector.drawer).should('exist'); + cy.focused(selector.drawer).should('exist'); cy.contains('local').click(); - cy.get(this.domSelector.dropdown).within(() => { + cy.get(selector.dropdown).within(() => { cy.contains('redis').click({ force: true, }); }); cy.get(selector.redis_host).type('127.0.0.1'); cy.get(selector.redis_password).type('redis_password'); - 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'); // config limit-count form with redis policy - cy.contains(this.domSelector.pluginCard, 'limit-count').within(() => { + cy.contains(selector.pluginCard, 'limit-count').within(() => { cy.get('button').click({ force: true, }); }); - cy.focused(this.domSelector.drawer).should('exist'); + cy.focused(selector.drawer).should('exist'); cy.contains('redis').click(); - cy.get(this.domSelector.dropdown).within(() => { + cy.get(selector.dropdown).within(() => { cy.contains('redis-cluster').click({ force: true, }); @@ -111,16 +128,16 @@ context('Create and delete route with limit-count form', () => { cy.get(selector.redis_cluster_name).type('redis_cluster_name'); cy.get(selector.redis_cluster_nodes_0).type('127.0.0.1:5000'); cy.get(selector.redis_cluster_nodes_1).type('127.0.0.1:5001'); - 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.contains(this.data.submitSuccess); + cy.contains(data.submitSuccess); // back to route list page cy.contains('Goto List').click(); @@ -129,19 +146,17 @@ context('Create and delete route with limit-count form', () => { it('should delete the route', function () { cy.visit('/routes/list'); - const { - domSelector, - data - } = this; - cy.get(domSelector.name).clear().type('routeName'); + cy.get(selector.name).clear().type('routeName'); cy.contains('Search').click(); cy.contains('routeName').siblings().contains('More').click(); cy.contains('Delete').click(); - cy.get(domSelector.deleteAlert).should('be.visible').within(() => { - cy.contains('OK').click(); - }); - cy.get(domSelector.notification).should('contain', data.deleteRouteSuccess); - cy.get(domSelector.notificationCloseIcon).click(); + cy.get(selector.deleteAlert) + .should('be.visible') + .within(() => { + cy.contains('OK').click(); + }); + cy.get(selector.notification).should('contain', data.deleteRouteSuccess); + cy.get(selector.notificationCloseIcon).click(); }); });