You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by ju...@apache.org on 2021/01/23 15:06:22 UTC
[apisix-dashboard] branch master updated: test: Create Upstream in
Route. (#1308)
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 ab5b1d9 test: Create Upstream in Route. (#1308)
ab5b1d9 is described below
commit ab5b1d94582fab0267d134ef342d19fde6114554
Author: guoqqqi <72...@users.noreply.github.com>
AuthorDate: Sat Jan 23 23:06:14 2021 +0800
test: Create Upstream in Route. (#1308)
* E2E: Create Upstream in Route.
* fix: format codes
* fix: e2e test error
* fix: i18n
* fix: e2e error
* fix: format codes
* delete unnecessary cy.wait()
* format codes
* move public data to data file
* notification move to domSelector
* Delete useless comments
* Update create-route-with-upstream.spec.js
* Update create-route-with-upstream.spec.js
* Update create-route-with-upstream.spec.js
* delete wait
* Code is clearer
* Update create-route-with-upstream.spec.js
Co-authored-by: 琚致远 <ju...@apache.org>
---
.../route/create-route-with-upstream.spec.js | 141 +++++++++++++++++++++
1 file changed, 141 insertions(+)
diff --git a/web/cypress/integration/route/create-route-with-upstream.spec.js b/web/cypress/integration/route/create-route-with-upstream.spec.js
new file mode 100644
index 0000000..22d86ef
--- /dev/null
+++ b/web/cypress/integration/route/create-route-with-upstream.spec.js
@@ -0,0 +1,141 @@
+/*
+ * 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 with Upstream', () => {
+ const domSelector = {
+ input: ':input',
+ notification: '.ant-notification-notice-message',
+ node_0_host: '#nodes_0_host',
+ name: '#name',
+ description: '#desc',
+ upstreamSelector: '#upstream_id',
+ searchName: '[title=Name]',
+ };
+
+ const data = {
+ upstreamName: 'test_upstream',
+ routeName: 'test_route',
+ description: 'desc_by_autotes',
+ host: '10.89.90.237',
+ ip1: '127.0.0.1',
+ ip2: '127.0.0.2',
+ deleteRouteSuccess: 'Delete Route Successfully',
+ deleteUpstreamSuccess: 'Delete successfully',
+ };
+
+ beforeEach(() => {
+ cy.login();
+ });
+
+ it('should create an upstream', () => {
+ cy.visit('/');
+ cy.contains('Upstream').click();
+ cy.contains('Create').click();
+
+ cy.get(domSelector.name).type(data.upstreamName);
+ cy.get(domSelector.description).type(data.description);
+ cy.get(domSelector.node_0_host).type(data.host);
+ cy.contains('Next').click();
+ cy.contains('Submit').click();
+ });
+
+ it('should enter the Route creator', () => {
+ cy.visit('/');
+ cy.contains('Route').click();
+ cy.contains('Create').click();
+
+ cy.get(domSelector.name).type(data.routeName);
+ cy.contains('Next').click();
+ });
+
+ it('should disable Upstream input boxes after selecting an existing upstream', () => {
+ cy.contains('Custom').click();
+ cy.contains(data.upstreamName).click();
+ cy.get(domSelector.input).should('be.disabled');
+ });
+
+ it('should enable Upstream input boxes after selecting Custom mode', () => {
+ cy.contains(data.upstreamName).click();
+ cy.contains('Custom').click();
+ cy.get(domSelector.input).should('not.be.disabled');
+ });
+
+ it('should submit custom Upstream properties successfully', () => {
+ cy.get(domSelector.node_0_host).clear().type(data.ip1);
+ cy.contains('Next').click();
+ cy.contains('Next').click();
+ cy.contains('Submit').click();
+ cy.contains('Goto List').click();
+ cy.url().should('contains', 'routes/list');
+ });
+
+ it('should edit this route with upstream', () => {
+ cy.visit('/');
+ cy.contains('Route').click();
+
+ cy.get(domSelector.searchName).type(data.routeName);
+ cy.contains('Search').click();
+ cy.contains(data.routeName).siblings().contains('Edit').click();
+
+ cy.get(domSelector.name).click().should('value', data.routeName);
+ cy.contains('Next').click();
+
+ // check if the changes have been saved
+ cy.get(domSelector.node_0_host).should('value', data.ip1);
+
+ cy.get(domSelector.upstreamSelector).click();
+ cy.contains(data.upstreamName).click();
+ cy.get(domSelector.input).should('be.disabled');
+
+ cy.contains(data.upstreamName).click();
+ cy.contains('Custom').click();
+ cy.get(domSelector.input).should('not.be.disabled');
+
+ cy.get(domSelector.node_0_host).clear().type(data.ip2);
+ cy.contains('Next').click();
+ cy.contains('Next').click();
+ cy.contains('Submit').click();
+ cy.contains('Goto List').click();
+ cy.url().should('contains', 'routes/list');
+
+ // check if the changes have been saved
+ cy.get(domSelector.searchName).type(data.routeName);
+ cy.contains('Search').click();
+ cy.contains(data.routeName).siblings().contains('Edit').click();
+ cy.contains('Next').click();
+ cy.get(domSelector.node_0_host).should('value', data.ip2);
+ });
+
+ it('should delete this test route and upstream', () => {
+ cy.visit('/routes/list');
+ cy.get(domSelector.searchName).type(data.routeName);
+ cy.contains('Search').click();
+ cy.contains(data.routeName).siblings().contains('Delete').click();
+ cy.contains('button', 'Confirm').click();
+ cy.get(domSelector.notification).should('contain', data.deleteRouteSuccess);
+
+ cy.visit('/');
+ cy.contains('Upstream').click();
+ cy.contains(data.upstreamName).siblings().contains('Delete').click();
+ cy.contains('button', 'Confirm').click();
+ cy.get(domSelector.notification).should(
+ 'contain',
+ data.deleteUpstreamSuccess,
+ );
+ });
+});