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 9e7a7a47eb..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 @@ -38,6 +38,8 @@ context('Delete Plugin List with the Drawer', () => { const data = { basicAuthPlugin: 'basic-auth', + keyAuthPlugin: 'key-auth', + jwtAuthPlugin: 'jwt-auth', }; beforeEach(() => { @@ -214,4 +216,90 @@ 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'); + }); }); diff --git a/web/src/components/Plugin/PluginPage.tsx b/web/src/components/Plugin/PluginPage.tsx index 0a2778492c..ddc77ea747 100644 --- a/web/src/components/Plugin/PluginPage.tsx +++ b/web/src/components/Plugin/PluginPage.tsx @@ -76,7 +76,6 @@ const PluginPage: React.FC = ({ const [plugins, setPlugins] = useState({}); useEffect(() => { - setPlugins(initialData); fetchList().then((data) => { const filteredData = data.filter( (item) => @@ -103,6 +102,7 @@ const PluginPage: React.FC = ({ const openPluginList = pluginList.filter( (item) => initialData[item.name] && !initialData[item.name].disable, ); + setPlugins(initialData); setEnablePluginsList(openPluginList); }, [initialData, pluginList]);