From 988c59939f5dbb58338c5000300ad5aeb416600f Mon Sep 17 00:00:00 2001 From: "1328735450@qq.com" Date: Tue, 16 Aug 2022 20:06:45 +0800 Subject: [PATCH 1/5] fix refresh problem --- web/src/components/Plugin/PluginPage.tsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/web/src/components/Plugin/PluginPage.tsx b/web/src/components/Plugin/PluginPage.tsx index d5301228a0..9dd34f0f32 100644 --- a/web/src/components/Plugin/PluginPage.tsx +++ b/web/src/components/Plugin/PluginPage.tsx @@ -96,6 +96,11 @@ const PluginPage: React.FC = ({ form.setFieldsValue({ plugin_config_id }); }); }, []); + + useEffect(() => { + setPlugins(initialData); + }, [initialData]); + const openPluginList = pluginList.filter( (item) => initialData[item.name] && !initialData[item.name].disable, ); From e6dfda85dc121bd9c5e9527b990366aaf45b08b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B1=AA=E5=98=89=E9=BE=99?= <1328735450@qq.com> Date: Tue, 16 Aug 2022 21:27:58 +0800 Subject: [PATCH 2/5] fix refresh problem --- web/src/components/Plugin/PluginPage.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/web/src/components/Plugin/PluginPage.tsx b/web/src/components/Plugin/PluginPage.tsx index 9dd34f0f32..7d5327bbec 100644 --- a/web/src/components/Plugin/PluginPage.tsx +++ b/web/src/components/Plugin/PluginPage.tsx @@ -74,7 +74,6 @@ const PluginPage: React.FC = ({ const [plugins, setPlugins] = useState({}); useEffect(() => { - setPlugins(initialData); fetchList().then((data) => { const filteredData = data.filter( (item) => From f6051aa6ac2745edead19df6c93d0393944f0b8b Mon Sep 17 00:00:00 2001 From: "1328735450@qq.com" Date: Wed, 17 Aug 2022 09:16:06 +0800 Subject: [PATCH 3/5] fix refresh problem --- web/src/components/Plugin/PluginPage.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/web/src/components/Plugin/PluginPage.tsx b/web/src/components/Plugin/PluginPage.tsx index 7d5327bbec..7a6a6ae426 100644 --- a/web/src/components/Plugin/PluginPage.tsx +++ b/web/src/components/Plugin/PluginPage.tsx @@ -73,6 +73,10 @@ const PluginPage: React.FC = ({ const [typeList, setTypeList] = useState([]); const [plugins, setPlugins] = useState({}); + useEffect(() => { + setPlugins(initialData); + }, [initialData]); + useEffect(() => { fetchList().then((data) => { const filteredData = data.filter( @@ -96,10 +100,6 @@ const PluginPage: React.FC = ({ }); }, []); - useEffect(() => { - setPlugins(initialData); - }, [initialData]); - const openPluginList = pluginList.filter( (item) => initialData[item.name] && !initialData[item.name].disable, ); From bc5ba2ae4e512838109f83490116946b6b99991d Mon Sep 17 00:00:00 2001 From: "1328735450@qq.com" Date: Wed, 17 Aug 2022 11:51:45 +0800 Subject: [PATCH 4/5] add test case --- .../create-delete-in-drawer-plugin.spec.js | 89 +++++++++++++++++++ 1 file changed, 89 insertions(+) diff --git a/web/cypress/integration/plugin/create-delete-in-drawer-plugin.spec.js b/web/cypress/integration/plugin/create-delete-in-drawer-plugin.spec.js index af73c261fb..ab81f6ead8 100644 --- a/web/cypress/integration/plugin/create-delete-in-drawer-plugin.spec.js +++ b/web/cypress/integration/plugin/create-delete-in-drawer-plugin.spec.js @@ -36,6 +36,8 @@ context('Delete Plugin List with the Drawer', () => { const data = { basicAuthPlugin: 'basic-auth', + keyAuthPlugin: 'key-auth', + jwtAuthPlugin: 'jwt-auth', }; beforeEach(() => { @@ -162,4 +164,91 @@ context('Delete Plugin List with the Drawer', () => { cy.visit('/plugin/list'); cy.get(selector.empty).should('be.visible'); }); + + it('should be deleted one of the plugins instead of all', function () { + cy.visit('/plugin/list'); + cy.get(selector.refresh).click(); + cy.contains('Enable').click(); + + const pluginList = [data.jwtAuthPlugin, data.basicAuthPlugin, data.keyAuthPlugin]; + pluginList.forEach((item) => { + cy.contains(item) + .parents(selector.pluginCardBordered) + .within(() => { + cy.get('button').click({ + force: true, + }); + }); + cy.get(selector.drawer) + .should('be.visible') + .within(() => { + cy.get(selector.disabledSwitcher).click(); + cy.get(selector.checkedSwitcher).should('exist'); + }); + cy.contains('button', 'Submit').click(); + + cy.get(selector.drawer, { + timeout, + }).should('not.exist'); + cy.get(selector.notification).should('contain', 'Configure Plugin Successfully'); + cy.get(selector.notificationCloseIcon).click({ multiple: true }); + }); + + cy.reload(); + cy.contains(data.basicAuthPlugin) + .parents(selector.pluginCardBordered) + .within(() => { + cy.get('button').click({ + force: true, + }); + }); + cy.get(selector.drawer).should('be.visible'); + cy.contains('button', 'Delete').click(); + cy.contains('button', 'Confirm').click({ + force: true, + }); + cy.get(selector.drawer, { + timeout, + }).should('not.exist'); + cy.get(selector.notification).should('contain', 'Delete Plugin Successfully'); + cy.get(selector.notificationCloseIcon).click({ multiple: true }); + + const remainPlugin = pluginList.filter((item) => item !== data.basicAuthPlugin); + remainPlugin.forEach((item) => + cy + .contains(item) + .parents(selector.pluginCardBordered) + .within(() => { + cy.get('button').should('contain', 'Edit'); + }), + ); + + cy.visit('/plugin/list'); + cy.contains('Enable').click(); + + remainPlugin.forEach((item) => { + cy.contains(item) + .parents(selector.pluginCardBordered) + .within(() => { + cy.get('button').click(); + }); + cy.get(selector.drawer) + .should('be.visible') + .within(() => { + cy.get(selector.checkedSwitcher).should('exist'); + }); + cy.contains('button', 'Delete').click(); + cy.contains('button', 'Confirm').click({ + force: true, + }); + cy.get(selector.drawer, { + timeout, + }).should('not.exist'); + cy.get(selector.notification).should('contain', 'Delete Plugin Successfully'); + cy.get(selector.notificationCloseIcon).click({ multiple: true }); + }); + + cy.visit('/plugin/list'); + cy.get(selector.empty).should('be.visible'); + }); }); From 49573c12e39991604bb51d832e7ae4f45f85be32 Mon Sep 17 00:00:00 2001 From: "1328735450@qq.com" Date: Thu, 18 Aug 2022 11:59:11 +0800 Subject: [PATCH 5/5] resolve the conflict --- .../create-delete-in-drawer-plugin.spec.js | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/web/cypress/integration/plugin/create-delete-in-drawer-plugin.spec.js b/web/cypress/integration/plugin/create-delete-in-drawer-plugin.spec.js index 1e282d08f6..15e7fd336b 100644 --- a/web/cypress/integration/plugin/create-delete-in-drawer-plugin.spec.js +++ b/web/cypress/integration/plugin/create-delete-in-drawer-plugin.spec.js @@ -167,7 +167,7 @@ context('Delete Plugin List with the Drawer', () => { cy.get(selector.empty).should('be.visible'); }); - it('should be switched tabs to distinguish enable ', function () { + it('should be switched tabs to distinguish enable ', function () { cy.visit('/plugin/list'); cy.get(selector.refresh).click(); cy.contains('button', 'Enable').click(); @@ -191,26 +191,14 @@ context('Delete Plugin List with the Drawer', () => { force: true, }); }); - cy.contains(data.basicAuthPlugin) + + cy.contains(data.basicAuthPlugin) .parents(selector.pluginCardBordered) .within(() => { cy.get('button').click({ force: true, }); }); - cy.contains('button', 'Delete').click({ - force: true, - }); - cy.contains('button', 'Confirm').click({ - force: true, - }); - - cy.get(selector.tab).within(() => { - cy.contains(selector.tabBtn, 'All').click({ - force: true, - }); - }); - cy.contains(data.basicAuthPlugin).should('exist'); cy.contains('button', 'Delete').click({ force: true, @@ -225,7 +213,6 @@ context('Delete Plugin List with the Drawer', () => { }); }); cy.contains(data.basicAuthPlugin).should('exist'); - cy.visit('/plugin/list'); cy.get(selector.empty).should('be.visible'); });