You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by gu...@apache.org on 2022/08/18 06:25:02 UTC

[apisix-dashboard] branch master updated: fix: page refresh causes deletion exception (#2593)

This is an automated email from the ASF dual-hosted git repository.

guoqi 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 d166405d fix: page refresh causes deletion exception (#2593)
d166405d is described below

commit d166405d0e40a63b219462f7f1e63e36837be33a
Author: Morakes <74...@users.noreply.github.com>
AuthorDate: Thu Aug 18 14:24:58 2022 +0800

    fix: page refresh causes deletion exception (#2593)
---
 .../plugin/create-delete-in-drawer-plugin.spec.js  | 88 ++++++++++++++++++++++
 web/src/components/Plugin/PluginPage.tsx           |  2 +-
 2 files changed, 89 insertions(+), 1 deletion(-)

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 9e7a7a47..15e7fd33 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 0a277849..ddc77ea7 100644
--- a/web/src/components/Plugin/PluginPage.tsx
+++ b/web/src/components/Plugin/PluginPage.tsx
@@ -76,7 +76,6 @@ const PluginPage: React.FC<Props> = ({
   const [plugins, setPlugins] = useState({});
 
   useEffect(() => {
-    setPlugins(initialData);
     fetchList().then((data) => {
       const filteredData = data.filter(
         (item) =>
@@ -103,6 +102,7 @@ const PluginPage: React.FC<Props> = ({
     const openPluginList = pluginList.filter(
       (item) => initialData[item.name] && !initialData[item.name].disable,
     );
+    setPlugins(initialData);
     setEnablePluginsList(openPluginList);
   }, [initialData, pluginList]);