This is an automated email from the ASF dual-hosted git repository. juzhiyuan 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 6b997d1 fix:When create the upstream, some properties can still be edited on … (#1828) 6b997d1 is described below commit 6b997d1fddf47ed62561a4599647884c7168b617 Author: jiemoxiaolong <shishuanglong1...@163.com> AuthorDate: Mon May 3 15:54:05 2021 +0800 fix:When create the upstream, some properties can still be edited on … (#1828) Co-authored-by: guoqqqi <72343596+guoq...@users.noreply.github.com> --- ...create-route-when-not-select-upsteam-id.spec.js | 101 +++++++++++++++++++++ ...create-service-with-not-select-upstream.spec.js | 69 ++++++++++++++ .../upstream/create_and_delete_upstream.spec.js | 1 + web/src/components/Upstream/UpstreamForm.tsx | 1 + 4 files changed, 172 insertions(+) diff --git a/web/cypress/integration/route/create-route-when-not-select-upsteam-id.spec.js b/web/cypress/integration/route/create-route-when-not-select-upsteam-id.spec.js new file mode 100644 index 0000000..71f3fa2 --- /dev/null +++ b/web/cypress/integration/route/create-route-when-not-select-upsteam-id.spec.js @@ -0,0 +1,101 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* eslint-disable no-undef */ + +context('Create Route without Upstream', () => { + beforeEach(() => { + cy.login(); + + cy.fixture('selector.json').as('domSelector'); + cy.fixture('data.json').as('data'); + }); + + + it('should create route wittout upstream ', function () { + cy.visit('/'); + cy.get('[role=menu]').should('be.visible').within(() => { + cy.contains('Route').click(); + }); + cy.contains('Create').click(); + + cy.contains('Next').click().click(); + cy.get(this.domSelector.name).type(this.data.routeName); + cy.contains('Next').click(); + + cy.get(this.domSelector.nodes_0_host).clear().type(this.data.ip1); + cy.get(this.domSelector.nodes_0_port).type(this.data.port); + cy.get(this.domSelector.nodes_0_weight).type(this.data.weight); + cy.contains('Next').click(); + cy.contains('Next').click(); + cy.get(this.domSelector.input).should('be.disabled'); + cy.contains('Submit').click(); + cy.contains(this.data.submitSuccess).should('be.visible'); + cy.contains('Goto List').click(); + cy.url().should('contains', 'routes/list'); + }); + + it('should edit this route ', function () { + cy.visit('/'); + cy.contains('Route').click(); + cy.get(this.domSelector.nameSelector).type(this.data.routeName); + + cy.contains('Search').click(); + cy.contains(this.data.routeName).siblings().contains('Configure').click(); + + cy.get(this.domSelector.name).should('value', this.data.routeName); + cy.contains('Next').click({ + force: true + }); + + // check if the changes have been saved + cy.get(this.domSelector.nodes_0_host).should('value', this.data.ip1); + cy.get(this.domSelector.nodes_0_host).clear().type(this.data.ip2); + cy.get(this.domSelector.nodes_0_port).type(this.data.port); + cy.get(this.domSelector.nodes_0_weight).type(this.data.weight); + cy.contains('Next').click(); + cy.contains('Next').click(); + cy.get(this.domSelector.input).should('be.disabled'); + cy.contains('Submit').click(); + cy.contains(this.data.submitSuccess).should('be.visible'); + cy.contains('Goto List').click(); + cy.url().should('contains', 'routes/list'); + + // check if the changes have been saved + cy.get(this.domSelector.nameSelector).type(this.data.routeName); + cy.contains('Search').click(); + + cy.contains(this.data.routeName).siblings().contains('Configure').click(); + // ensure it has already changed to edit page + cy.get(this.domSelector.name).should('value', this.data.routeName); + cy.contains('Next').click({ + force: true + }); + cy.get(this.domSelector.nodes_0_host).should('value', this.data.ip2); + }); + + it('should delete this test route', function () { + cy.visit('/routes/list'); + cy.get(this.domSelector.nameSelector).type(this.data.routeName); + cy.contains('Search').click(); + cy.contains(this.data.routeName).siblings().contains('More').click(); + cy.contains('Delete').click(); + cy.get(this.domSelector.deleteAlert).should('be.visible').within(() => { + cy.contains('OK').click(); + }); + cy.get(this.domSelector.notification).should('contain', this.data.deleteRouteSuccess); + }); +}); diff --git a/web/cypress/integration/service/create-service-with-not-select-upstream.spec.js b/web/cypress/integration/service/create-service-with-not-select-upstream.spec.js new file mode 100644 index 0000000..aec999a --- /dev/null +++ b/web/cypress/integration/service/create-service-with-not-select-upstream.spec.js @@ -0,0 +1,69 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* eslint-disable no-undef */ + +context('Edit Service with not select Upstream', () => { + beforeEach(() => { + cy.login(); + + cy.fixture('selector.json').as('domSelector'); + cy.fixture('data.json').as('data'); + }); + + it('should create a test service', function () { + cy.visit('/'); + cy.contains('Service').click(); + cy.contains('Create').click(); + cy.get(this.domSelector.name).type(this.data.serviceName); + cy.get(this.domSelector.description).type(this.data.description); + cy.get(this.domSelector.nodes_0_host).click(); + cy.get(this.domSelector.nodes_0_host).type(this.data.ip1); + cy.get(this.domSelector.nodes_0_port).clear().type('7000'); + cy.get(this.domSelector.nodes_0_weight).clear().type(1); + cy.contains('Next').click(); + cy.contains('Next').click(); + cy.get(this.domSelector.input).should('be.disabled'); + cy.contains('Submit').click(); + cy.get(this.domSelector.notification).should('contain', this.data.createServiceSuccess); + }); + + it('should edit the service', function () { + cy.visit('/service/list'); + + cy.get(this.domSelector.nameSearch).type(this.data.serviceName); + cy.contains('Search').click(); + cy.contains(this.data.serviceName).siblings().contains('Configure').click(); + cy.wait(500); + cy.get(this.domSelector.nodes_0_host).should('not.be.disabled').clear().type(this.data.ip2); + cy.get(this.domSelector.nodes_0_port).type(this.data.port); + cy.get(this.domSelector.nodes_0_weight).type(this.data.weight); + cy.contains('Next').click(); + cy.contains('Next').click(); + cy.get(this.domSelector.input).should('be.disabled'); + cy.contains('Submit').click(); + cy.get(this.domSelector.notification).should('contain', this.data.editServiceSuccess); + }); + + it('should delete this service and upstream', function () { + cy.visit('/service/list'); + cy.get(this.domSelector.nameSearch).type(this.data.serviceName); + cy.contains('Search').click(); + cy.contains(this.data.serviceName).siblings().contains('Delete').click(); + cy.contains('button', 'Confirm').click(); + cy.get(this.domSelector.notification).should('contain', this.data.deleteServiceSuccess); + }); +}); diff --git a/web/cypress/integration/upstream/create_and_delete_upstream.spec.js b/web/cypress/integration/upstream/create_and_delete_upstream.spec.js index 4f2c0fa..86c672d 100644 --- a/web/cypress/integration/upstream/create_and_delete_upstream.spec.js +++ b/web/cypress/integration/upstream/create_and_delete_upstream.spec.js @@ -36,6 +36,7 @@ context('Create and Delete Upstream', () => { cy.get(this.domSelector.nodes_0_port).clear().type('7000'); cy.get(this.domSelector.nodes_0_weight).clear().type(1); cy.contains('Next').click(); + cy.get(this.domSelector.input).should('be.disabled'); cy.contains('Submit').click(); cy.get(this.domSelector.notification).should('contain', this.data.createUpstreamSuccess); cy.contains(this.data.createUpstreamSuccess); diff --git a/web/src/components/Upstream/UpstreamForm.tsx b/web/src/components/Upstream/UpstreamForm.tsx index c8a606b..8f07e6e 100644 --- a/web/src/components/Upstream/UpstreamForm.tsx +++ b/web/src/components/Upstream/UpstreamForm.tsx @@ -83,6 +83,7 @@ const UpstreamForm: React.FC<Props> = forwardRef( const resetForm = (upstream_id: string) => { if (upstream_id === undefined) { + setReadonly(disabled); return }