From ed309463d8fb27964d4e84db1a91302153b346c6 Mon Sep 17 00:00:00 2001 From: guoqqqi <979918879@qq.com> Date: Wed, 10 Feb 2021 22:02:46 +0800 Subject: [PATCH 01/13] test: Remove wait Reduce test time --- web/cypress/support/commands.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/web/cypress/support/commands.js b/web/cypress/support/commands.js index 2fb03a7cf2..3a36f8eeb6 100644 --- a/web/cypress/support/commands.js +++ b/web/cypress/support/commands.js @@ -62,7 +62,7 @@ Cypress.Commands.add('configurePlugins', (cases) => { }); // NOTE: wait for the Drawer to appear on the DOM - cy.wait(300); + cy.get(domSelectors.drawer_wrap).should('be.visible'); cy.get(domSelectors.drawer, { timeout }).within(() => { cy.get(domSelectors.switch).click({ force: true, @@ -80,7 +80,6 @@ Cypress.Commands.add('configurePlugins', (cases) => { }); }); - cy.wait(300); if (shouldValid === true) { cy.get(domSelectors.drawer).should('not.exist'); } else if (shouldValid === false) { From 8ee7351879f57d54b1a679d017a922a8c0f436bb Mon Sep 17 00:00:00 2001 From: guoqqqi <979918879@qq.com> Date: Thu, 11 Feb 2021 00:00:28 +0800 Subject: [PATCH 02/13] fix: CI error --- web/cypress/support/commands.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/cypress/support/commands.js b/web/cypress/support/commands.js index 3a36f8eeb6..f3b2b89fc0 100644 --- a/web/cypress/support/commands.js +++ b/web/cypress/support/commands.js @@ -62,7 +62,7 @@ Cypress.Commands.add('configurePlugins', (cases) => { }); // NOTE: wait for the Drawer to appear on the DOM - cy.get(domSelectors.drawer_wrap).should('be.visible'); + cy.focused(domSelectors.drawer_wrap).should('be.visible'); cy.get(domSelectors.drawer, { timeout }).within(() => { cy.get(domSelectors.switch).click({ force: true, @@ -85,7 +85,7 @@ Cypress.Commands.add('configurePlugins', (cases) => { } else if (shouldValid === false) { cy.get(this.selector.notification).should('contain', 'Invalid plugin data'); - cy.get(domSelectors.close).click({ + cy.get(domSelectors.close).should('be.visible').click({ force: true, multiple: true, }); From f015b2c552a0e9a02542419c172ce649ddf00c68 Mon Sep 17 00:00:00 2001 From: guoqqqi <979918879@qq.com> Date: Thu, 11 Feb 2021 09:16:56 +0800 Subject: [PATCH 03/13] fix: CI error --- web/cypress/integration/plugin/create-edit-delete-plugin.spec.js | 1 + 1 file changed, 1 insertion(+) diff --git a/web/cypress/integration/plugin/create-edit-delete-plugin.spec.js b/web/cypress/integration/plugin/create-edit-delete-plugin.spec.js index d4348fd850..16d5a8a5fa 100644 --- a/web/cypress/integration/plugin/create-edit-delete-plugin.spec.js +++ b/web/cypress/integration/plugin/create-edit-delete-plugin.spec.js @@ -59,6 +59,7 @@ context('Create and Delete Plugin List', () => { it('should delete plugin list', function () { cy.visit('/plugin/list'); + cy.get(this.domSelector.deleteButton).should('exist'); cy.get(this.domSelector.deleteButton, { timeout }).each(function ($el) { cy.wrap($el).click().click({ timeout }); cy.contains('button', 'Confirm').click({ force: true }); From d0f34aab5dc2a29015a4a65002f4fe382c7db501 Mon Sep 17 00:00:00 2001 From: guoqqqi <979918879@qq.com> Date: Thu, 11 Feb 2021 16:49:13 +0800 Subject: [PATCH 04/13] test: update `plugin-list` --- web/cypress/fixtures/plugin-list.json | 4 ++++ .../integration/plugin/create-edit-delete-plugin.spec.js | 2 +- web/cypress/support/commands.js | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/web/cypress/fixtures/plugin-list.json b/web/cypress/fixtures/plugin-list.json index 587b28e331..57b19f8696 100644 --- a/web/cypress/fixtures/plugin-list.json +++ b/web/cypress/fixtures/plugin-list.json @@ -1,6 +1,7 @@ { "api-breaker": [ { + "shouldValid": true, "data": { "break_response_code": 502, "disable": false, @@ -17,6 +18,7 @@ ], "echo": [ { + "shouldValid": true, "data": { "before_body": "before the body modification ", "disable": false @@ -25,6 +27,7 @@ ], "jwt-auth": [ { + "shouldValid": true, "data": { "disable": false } @@ -32,6 +35,7 @@ ], "hmac-auth": [ { + "shouldValid": true, "data": {} } ] diff --git a/web/cypress/integration/plugin/create-edit-delete-plugin.spec.js b/web/cypress/integration/plugin/create-edit-delete-plugin.spec.js index 16d5a8a5fa..f577065e2b 100644 --- a/web/cypress/integration/plugin/create-edit-delete-plugin.spec.js +++ b/web/cypress/integration/plugin/create-edit-delete-plugin.spec.js @@ -59,7 +59,7 @@ context('Create and Delete Plugin List', () => { it('should delete plugin list', function () { cy.visit('/plugin/list'); - cy.get(this.domSelector.deleteButton).should('exist'); + cy.get(this.domSelector.deleteButton).should('be.visible'); cy.get(this.domSelector.deleteButton, { timeout }).each(function ($el) { cy.wrap($el).click().click({ timeout }); cy.contains('button', 'Confirm').click({ force: true }); diff --git a/web/cypress/support/commands.js b/web/cypress/support/commands.js index f3b2b89fc0..58a1b56317 100644 --- a/web/cypress/support/commands.js +++ b/web/cypress/support/commands.js @@ -62,7 +62,7 @@ Cypress.Commands.add('configurePlugins', (cases) => { }); // NOTE: wait for the Drawer to appear on the DOM - cy.focused(domSelectors.drawer_wrap).should('be.visible'); + cy.focused(domSelectors.drawer_wrap).should('exist'); cy.get(domSelectors.drawer, { timeout }).within(() => { cy.get(domSelectors.switch).click({ force: true, From 71089d7cdbf15fd51635008bae4b6a173b22a3a6 Mon Sep 17 00:00:00 2001 From: guoqqqi <979918879@qq.com> Date: Thu, 18 Feb 2021 17:28:41 +0800 Subject: [PATCH 05/13] test: add refresh plugin list --- .../integration/plugin/create-edit-delete-plugin.spec.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/web/cypress/integration/plugin/create-edit-delete-plugin.spec.js b/web/cypress/integration/plugin/create-edit-delete-plugin.spec.js index f577065e2b..41b15942b5 100644 --- a/web/cypress/integration/plugin/create-edit-delete-plugin.spec.js +++ b/web/cypress/integration/plugin/create-edit-delete-plugin.spec.js @@ -59,12 +59,13 @@ context('Create and Delete Plugin List', () => { it('should delete plugin list', function () { cy.visit('/plugin/list'); + cy.get(this.domSelector.refresh).click(); cy.get(this.domSelector.deleteButton).should('be.visible'); cy.get(this.domSelector.deleteButton, { timeout }).each(function ($el) { cy.wrap($el).click().click({ timeout }); cy.contains('button', 'Confirm').click({ force: true }); cy.get(this.domSelector.notification).should('contain', this.data.deletePluginSuccess); - cy.get(this.domSelector.notificationCloseIcon).click(); + cy.get(this.domSelector.notificationCloseIcon).click().should('not.exist'); }); // check if plugin list is empty From da755c763b9fa6a3dcd8df3877b066e359a68eb6 Mon Sep 17 00:00:00 2001 From: guoqqqi <979918879@qq.com> Date: Thu, 18 Feb 2021 20:38:31 +0800 Subject: [PATCH 06/13] fix: CI --- .../integration/plugin/create-edit-delete-plugin.spec.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/web/cypress/integration/plugin/create-edit-delete-plugin.spec.js b/web/cypress/integration/plugin/create-edit-delete-plugin.spec.js index 41b15942b5..1bc513f246 100644 --- a/web/cypress/integration/plugin/create-edit-delete-plugin.spec.js +++ b/web/cypress/integration/plugin/create-edit-delete-plugin.spec.js @@ -60,8 +60,7 @@ context('Create and Delete Plugin List', () => { cy.visit('/plugin/list'); cy.get(this.domSelector.refresh).click(); - cy.get(this.domSelector.deleteButton).should('be.visible'); - cy.get(this.domSelector.deleteButton, { timeout }).each(function ($el) { + cy.get(this.domSelector.deleteButton, { timeout }).should('exist').each(function ($el) { cy.wrap($el).click().click({ timeout }); cy.contains('button', 'Confirm').click({ force: true }); cy.get(this.domSelector.notification).should('contain', this.data.deletePluginSuccess); From a7405f9caef2134631554dd827e3c76afa97106a Mon Sep 17 00:00:00 2001 From: guoqqqi <979918879@qq.com> Date: Fri, 19 Feb 2021 01:39:25 +0800 Subject: [PATCH 07/13] fix: CI --- web/cypress/support/commands.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/web/cypress/support/commands.js b/web/cypress/support/commands.js index 58a1b56317..817aad87ad 100644 --- a/web/cypress/support/commands.js +++ b/web/cypress/support/commands.js @@ -62,7 +62,7 @@ Cypress.Commands.add('configurePlugins', (cases) => { }); // NOTE: wait for the Drawer to appear on the DOM - cy.focused(domSelectors.drawer_wrap).should('exist'); + cy.focused(domSelectors.drawer).should('exist'); cy.get(domSelectors.drawer, { timeout }).within(() => { cy.get(domSelectors.switch).click({ force: true, @@ -77,6 +77,7 @@ Cypress.Commands.add('configurePlugins', (cases) => { cy.contains('Submit').click({ force: true, }); + cy.get(domSelectors.drawer).should('not.exist'); }); }); From b471f695a141bec1a0566d5472f709e6f71d5a25 Mon Sep 17 00:00:00 2001 From: guoqqqi <979918879@qq.com> Date: Fri, 19 Feb 2021 15:40:39 +0800 Subject: [PATCH 08/13] fix: test --- web/cypress/support/commands.js | 1 + 1 file changed, 1 insertion(+) diff --git a/web/cypress/support/commands.js b/web/cypress/support/commands.js index 817aad87ad..5d530e6a88 100644 --- a/web/cypress/support/commands.js +++ b/web/cypress/support/commands.js @@ -73,6 +73,7 @@ Cypress.Commands.add('configurePlugins', (cases) => { if (codemirror) { codemirror.setValue(JSON.stringify(data)); } + cy.get(domSelectors.drawer).should('exist'); cy.get(domSelectors.drawer, { timeout }).within(() => { cy.contains('Submit').click({ force: true, From b4500f8b6b02565c85889abecb3d0a9f1eed3b59 Mon Sep 17 00:00:00 2001 From: guoqqqi <979918879@qq.com> Date: Sat, 20 Feb 2021 15:25:43 +0800 Subject: [PATCH 09/13] test: Merge Plugin test --- web/cypress/fixtures/plugin-list.json | 42 ------------------- .../plugin/create-edit-delete-plugin.spec.js | 8 ++-- .../plugin/schema-smocktest.spec.js | 36 ---------------- 3 files changed, 4 insertions(+), 82 deletions(-) delete mode 100644 web/cypress/fixtures/plugin-list.json delete mode 100644 web/cypress/integration/plugin/schema-smocktest.spec.js diff --git a/web/cypress/fixtures/plugin-list.json b/web/cypress/fixtures/plugin-list.json deleted file mode 100644 index 57b19f8696..0000000000 --- a/web/cypress/fixtures/plugin-list.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "api-breaker": [ - { - "shouldValid": true, - "data": { - "break_response_code": 502, - "disable": false, - "healthy": { - "successes": 3 - }, - "max_breaker_sec": 10, - "unhealthy": { - "failures": 1, - "http_statuses": [500, 503] - } - } - } - ], - "echo": [ - { - "shouldValid": true, - "data": { - "before_body": "before the body modification ", - "disable": false - } - } - ], - "jwt-auth": [ - { - "shouldValid": true, - "data": { - "disable": false - } - } - ], - "hmac-auth": [ - { - "shouldValid": true, - "data": {} - } - ] -} diff --git a/web/cypress/integration/plugin/create-edit-delete-plugin.spec.js b/web/cypress/integration/plugin/create-edit-delete-plugin.spec.js index 1bc513f246..a601a752de 100644 --- a/web/cypress/integration/plugin/create-edit-delete-plugin.spec.js +++ b/web/cypress/integration/plugin/create-edit-delete-plugin.spec.js @@ -21,21 +21,20 @@ context('Create and Delete Plugin List', () => { const data = { name: 'hmac-auth', }; - + beforeEach(() => { cy.login(); - cy.fixture('plugin-list.json').as('cases'); cy.fixture('selector.json').as('domSelector'); cy.fixture('data.json').as('data'); + cy.fixture('plugin-dataset.json').as('cases'); }); - it('should create plugins', function () { + it('should visit plugin market', function () { cy.visit('/'); cy.contains('Plugin').click(); cy.contains('Create').click(); - // add test plugins cy.get('@cases').then((cases) => { cy.configurePlugins(cases); }); @@ -43,6 +42,7 @@ context('Create and Delete Plugin List', () => { it('should edit the plugin', function () { cy.visit('/plugin/list'); + cy.get(this.domSelector.refresh).click(); cy.contains(data.name).should('exist').siblings().contains('Edit').click({ force: true, diff --git a/web/cypress/integration/plugin/schema-smocktest.spec.js b/web/cypress/integration/plugin/schema-smocktest.spec.js deleted file mode 100644 index 65510525f1..0000000000 --- a/web/cypress/integration/plugin/schema-smocktest.spec.js +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* eslint-disable no-undef */ - -context('smoke test for plugin schema', () => { - beforeEach(() => { - cy.login(); - - cy.fixture('selector.json').as('selector'); - cy.fixture('plugin-dataset.json').as('cases'); - }); - - it('should visit plugin market', function () { - cy.visit('/'); - cy.contains('Plugin').click(); - cy.contains('Create').click(); - - cy.get('@cases').then((cases) => { - cy.configurePlugins(cases); - }); - }); -}); From 5a5eaf1c197e20b710aead126692ff7c0b63d580 Mon Sep 17 00:00:00 2001 From: guoqqqi <979918879@qq.com> Date: Sat, 20 Feb 2021 15:31:59 +0800 Subject: [PATCH 10/13] fix: format codes --- .../integration/plugin/create-edit-delete-plugin.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/cypress/integration/plugin/create-edit-delete-plugin.spec.js b/web/cypress/integration/plugin/create-edit-delete-plugin.spec.js index a601a752de..e950aa7348 100644 --- a/web/cypress/integration/plugin/create-edit-delete-plugin.spec.js +++ b/web/cypress/integration/plugin/create-edit-delete-plugin.spec.js @@ -21,7 +21,7 @@ context('Create and Delete Plugin List', () => { const data = { name: 'hmac-auth', }; - + beforeEach(() => { cy.login(); From c045ace81d86791588c1498c7aefd6db2866ae56 Mon Sep 17 00:00:00 2001 From: guoqqqi <979918879@qq.com> Date: Sat, 20 Feb 2021 15:40:47 +0800 Subject: [PATCH 11/13] fix: CI error --- web/cypress/support/commands.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/cypress/support/commands.js b/web/cypress/support/commands.js index 5d530e6a88..59e8ad5b0d 100644 --- a/web/cypress/support/commands.js +++ b/web/cypress/support/commands.js @@ -85,7 +85,7 @@ Cypress.Commands.add('configurePlugins', (cases) => { if (shouldValid === true) { cy.get(domSelectors.drawer).should('not.exist'); } else if (shouldValid === false) { - cy.get(this.selector.notification).should('contain', 'Invalid plugin data'); + cy.get(this.domSelector.notification).should('contain', 'Invalid plugin data'); cy.get(domSelectors.close).should('be.visible').click({ force: true, From 413cb9e749cc32bd13240a82058bd7c5b676a0c8 Mon Sep 17 00:00:00 2001 From: guoqqqi <979918879@qq.com> Date: Sat, 20 Feb 2021 16:24:37 +0800 Subject: [PATCH 12/13] fix: CI --- .../integration/plugin/create-edit-delete-plugin.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/cypress/integration/plugin/create-edit-delete-plugin.spec.js b/web/cypress/integration/plugin/create-edit-delete-plugin.spec.js index e950aa7348..bde2856a8c 100644 --- a/web/cypress/integration/plugin/create-edit-delete-plugin.spec.js +++ b/web/cypress/integration/plugin/create-edit-delete-plugin.spec.js @@ -19,7 +19,7 @@ context('Create and Delete Plugin List', () => { const timeout = 5000; const data = { - name: 'hmac-auth', + name: 'api-breaker', }; beforeEach(() => { From 4272e987951bcb748861d53ba9fb6f2b64665a43 Mon Sep 17 00:00:00 2001 From: guoqqqi <979918879@qq.com> Date: Sat, 20 Feb 2021 17:14:25 +0800 Subject: [PATCH 13/13] fix: update code --- .../integration/plugin/create-edit-delete-plugin.spec.js | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/web/cypress/integration/plugin/create-edit-delete-plugin.spec.js b/web/cypress/integration/plugin/create-edit-delete-plugin.spec.js index bde2856a8c..017a5cd584 100644 --- a/web/cypress/integration/plugin/create-edit-delete-plugin.spec.js +++ b/web/cypress/integration/plugin/create-edit-delete-plugin.spec.js @@ -18,9 +18,6 @@ context('Create and Delete Plugin List', () => { const timeout = 5000; - const data = { - name: 'api-breaker', - }; beforeEach(() => { cy.login(); @@ -44,16 +41,13 @@ context('Create and Delete Plugin List', () => { cy.visit('/plugin/list'); cy.get(this.domSelector.refresh).click(); - cy.contains(data.name).should('exist').siblings().contains('Edit').click({ - force: true, - }); + cy.contains('Edit').click(); cy.get(this.domSelector.codemirror) .first() .then(() => { cy.get(this.domSelector.disabledSwitcher).click(); cy.contains('button', 'Submit').click(); }); - cy.contains(data.name).should('not.exist'); }); it('should delete plugin list', function () {