This is an automated email from the ASF dual-hosted git repository.
baoyuan 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 d517c1daa fix: edit comsumer without plugin (#2809)
d517c1daa is described below
commit d517c1daa5e370186a40aeb582cd527fd7b93bd9
Author: Baoyuan <[email protected]>
AuthorDate: Fri May 19 15:03:16 2023 +0800
fix: edit comsumer without plugin (#2809)
---
.../e2e/consumer/create_and_delete_consumer.cy.js | 16 ++++++++++++++++
web/src/pages/Consumer/Create.tsx | 2 +-
web/src/pages/Consumer/typing.d.ts | 2 +-
3 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/web/cypress/e2e/consumer/create_and_delete_consumer.cy.js
b/web/cypress/e2e/consumer/create_and_delete_consumer.cy.js
index 3dce5e713..e7582cf52 100644
--- a/web/cypress/e2e/consumer/create_and_delete_consumer.cy.js
+++ b/web/cypress/e2e/consumer/create_and_delete_consumer.cy.js
@@ -38,6 +38,7 @@ context('Create and Delete Consumer', () => {
description: 'desc_by_autotest',
createConsumerSuccess: 'Create Consumer Successfully',
deleteConsumerSuccess: 'Delete Consumer Successfully',
+ editConsumerSuccess: 'Edit Consumer Successfully',
pluginErrorAlert: 'Invalid plugin data',
};
@@ -60,6 +61,21 @@ context('Create and Delete Consumer', () => {
cy.contains('button', 'Submit').click();
cy.get(selector.notification).should('contain',
data.createConsumerSuccess);
+ // should configure the comsumer
+ cy.contains(data.noPluginsConsumerName)
+ .should('be.visible')
+ .siblings()
+ .contains('Configure')
+ .click();
+ cy.url().should('contain', `/${data.noPluginsConsumerName}/edit`);
+ cy.get('#username').should('have.value', data.noPluginsConsumerName);
+ cy.get('#desc').should('have.value', data.description);
+ cy.contains('button', 'Next').click();
+ cy.get('[data-cy-plugin-name="basic-auth"]').should('be.visible');
+ cy.contains('button', 'Next').click();
+ cy.contains('button', 'Submit').click();
+ cy.get(selector.notification).should('contain', data.editConsumerSuccess);
+
cy.contains(data.noPluginsConsumerName)
.should('be.visible')
.siblings()
diff --git a/web/src/pages/Consumer/Create.tsx
b/web/src/pages/Consumer/Create.tsx
index e417c5d21..bdc0053cc 100644
--- a/web/src/pages/Consumer/Create.tsx
+++ b/web/src/pages/Consumer/Create.tsx
@@ -39,7 +39,7 @@ const Page: React.FC = (props) => {
fetchItem(username).then(({ data }) => {
const { desc, ...rest } = data;
form1.setFieldsValue({ username, desc });
- setPlugins(rest.plugins);
+ setPlugins(rest?.plugins || {});
});
}
}, []);
diff --git a/web/src/pages/Consumer/typing.d.ts
b/web/src/pages/Consumer/typing.d.ts
index bd7cc3027..d0f5f120e 100644
--- a/web/src/pages/Consumer/typing.d.ts
+++ b/web/src/pages/Consumer/typing.d.ts
@@ -18,7 +18,7 @@ declare namespace ConsumerModule {
type Entity = {
username: string;
desc: string;
- plugins: Record<string, any>;
+ plugins?: Record<string, any>;
};
type ResEntity = Entity & {