From 688afa2099b1782bb401083085b2384f27c9cc6a Mon Sep 17 00:00:00 2001 From: Baoyuan Date: Fri, 20 Jan 2023 16:16:31 +0800 Subject: [PATCH] fix: plugin configuration lost in editor (#2718) --- web/cypress/e2e/plugin/plugin-schema.cy.js | 30 ++++++++++++++++++++++ web/src/components/Plugin/PluginDetail.tsx | 2 +- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/web/cypress/e2e/plugin/plugin-schema.cy.js b/web/cypress/e2e/plugin/plugin-schema.cy.js index 1619413843..41bebe3c21 100644 --- a/web/cypress/e2e/plugin/plugin-schema.cy.js +++ b/web/cypress/e2e/plugin/plugin-schema.cy.js @@ -109,5 +109,35 @@ describe('Plugin Schema Test', () => { // check if plugin list is empty cy.get(domSelector.empty).should('be.visible'); }); + + it('click plugin Edit button the existing configuration should display', () => { + cy.visit('/'); + cy.contains('Consumer').click(); + cy.get('.ant-empty-normal').should('be.visible'); + cy.contains('Create').click(); + + cy.get('#username').type('test'); + cy.contains('Next').click(); + cy.contains('.ant-card', 'client-control').within(() => { + cy.contains('Enable').click({ + force: true, + }); + }); + cy.focused('.ant-drawer-content').should('exist'); + cy.get('.view-zones').should('exist'); + cy.contains('max_body_size').should('be.visible'); + cy.window().then((window) => { + window.monacoEditor.setValue(JSON.stringify({ max_body_size: 1024 })); + cy.contains('button', 'Submit').click(); + }); + cy.wait(3000); + cy.contains('.ant-card', 'client-control').within(() => { + cy.contains('Enable').click({ + force: true, + }); + }); + cy.focused('.ant-drawer-content').should('exist'); + cy.contains('1024').should('be.visible'); + }); }); }); diff --git a/web/src/components/Plugin/PluginDetail.tsx b/web/src/components/Plugin/PluginDetail.tsx index 0e0fc8f962..69c7a268f8 100644 --- a/web/src/components/Plugin/PluginDetail.tsx +++ b/web/src/components/Plugin/PluginDetail.tsx @@ -490,7 +490,7 @@ const PluginDetail: React.FC = ({ // NOTE: for debug & test // @ts-ignore window.monacoEditor = editor; - if (targetModel) editor.setValue(targetModelCode); + if (targetModel && content === '{}') editor.setValue(targetModelCode); }} options={{ scrollbar: {