Skip to content

Commit

Permalink
feat: user can skip upstream when select service_id (#1302)
Browse files Browse the repository at this point in the history
* feat: user can skip upstream when select service_id

* feat: update code

* feat: update upstream

* fix: manual input

* feat: update CreateStep4

* fix: Select Upstream show empty string

* merge LiteSun/feat-route into test-route

* feat: auto fill DEFAULT_UPSTREAM

* test:  create route can skip upstream

* feat: update upstreamForm

* feat: update testcase

* feat: update upstream testcase

Co-authored-by: guoqqqi <[email protected]>
  • Loading branch information
LiteSun and guoqqqi authored Jan 22, 2021
1 parent bb0a057 commit 6c3f35c
Show file tree
Hide file tree
Showing 10 changed files with 300 additions and 141 deletions.
132 changes: 132 additions & 0 deletions web/cypress/integration/route/create-route-can-skip-upstream.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
/*
* 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('Can select service_id skip upstream in route', () => {
const data = {
upstreamName: 'test_upstream',
serviceName: 'test_service',
routeName: 'test_route',
ip: '127.0.0.1',
}
const domSelector = {
name: '#name',
nodes_0_host: '#nodes_0_host',
upstream_id: '#upstream_id',
input: ':input',
customUpstream: '[title=Custom]',
titleName: '[title=Name]',
testService: '[title=test_service]',
notification: '.ant-notification-notice-message',
};

beforeEach(() => {
cy.login();
});

it('should create test upstream and service', () => {
cy.visit('/');
cy.contains('Upstream').click();
cy.contains('Create').click();

cy.get(domSelector.name).type(data.upstreamName);
cy.get(domSelector.nodes_0_host).type(data.ip);
cy.contains('Next').click();
cy.contains('Submit').click();
cy.get(domSelector.notification).should('contain', 'Create Upstream Successfully');

cy.visit('/');
cy.contains('Service').click();
cy.contains('Create').click();
cy.get(domSelector.name).type(data.serviceName);
cy.get(domSelector.customUpstream).click();
cy.contains(data.upstreamName).click();
cy.contains('Next').click();
cy.contains('Next').click();
cy.contains('Submit').click();
cy.get(domSelector.notification).should('contain', 'Create Service Successfully');
});

it('should skip upstream module after service is selected when creating route', () => {
cy.visit('/');
cy.contains('Route').click();
cy.contains('Create').click();

// The None option doesn't exist when service isn't selected
cy.get(domSelector.name).type(data.routeName);
cy.contains('Next').click();
cy.get(domSelector.customUpstream).click();
cy.contains('None').should('not.exist');

cy.contains('Previous').click();
cy.contains('None').click();
cy.contains(data.serviceName).click();
cy.contains('Next').click();

// make sure upstream data can be saved
cy.get(domSelector.customUpstream).click();
cy.contains(data.upstreamName).click();
cy.get(domSelector.input).should('be.disabled');

cy.contains(data.upstreamName).click();
cy.contains('None').click();
cy.contains('Next').click();
cy.contains('Next').click();
cy.contains('Submit').click();
cy.contains('Goto List').click();
});

it('should skip Upstream module after service is selected when editing route', () => {
cy.visit('/');
cy.contains('Route').click();

cy.get(domSelector.titleName).type(data.routeName);
cy.contains('Search').click();
cy.contains(data.routeName).siblings().contains('Edit').click();
cy.get(domSelector.testService).click();
cy.contains('None').click();
cy.contains('Next').click();
cy.get(domSelector.upstream_id).click();
cy.contains('None').should('not.exist');
cy.contains(data.upstreamName).click();
cy.contains('Next').click();
cy.contains('Next').click();
cy.contains('Submit').click();
cy.contains('Submit Successfully');
});

it('should delete upstream, service and route', () => {
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', 'Delete Upstream Successfully');

cy.visit('/');
cy.contains('Service').click();
cy.contains(data.serviceName).siblings().contains('Delete').click();
cy.contains('button', 'Confirm').click();
cy.get(domSelector.notification).should('contain', 'Delete Service Successfully');

cy.visit('/');
cy.contains('Route').click();
cy.contains(data.routeName).siblings().contains('Delete').click();
cy.contains('button', 'Confirm').click();
cy.get(domSelector.notification).should('contain', 'Delete Route Successfully');
});
});

Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ context('Create and Delete Upstream', () => {
cy.get('#nodes_0_port').clear().type('7000');
cy.contains('Next').click();
cy.contains('Submit').click();
cy.get(domSelectors.notification).should('contain', 'Create upstream successfully');
cy.contains('Create upstream successfully');
cy.get(domSelectors.notification).should('contain', 'Create Upstream Successfully');
cy.contains('Create Upstream Successfully');
cy.wait(sleepTime * 5);
cy.url().should('contains', 'upstream/list');
});
Expand All @@ -57,7 +57,7 @@ context('Create and Delete Upstream', () => {
cy.wait(sleepTime * 5);
cy.contains(name).siblings().contains('Delete').click();
cy.contains('button', 'Confirm').click();
cy.get(domSelectors.notification).should('contain', 'Delete successfully');
cy.get(domSelectors.notification).should('contain', 'Delete Upstream Successfully');
});

it('should create chash upstream', () => {
Expand Down Expand Up @@ -101,7 +101,7 @@ context('Create and Delete Upstream', () => {
// next to finish
cy.contains('Next').click();
cy.contains('Submit').click();
cy.get(domSelectors.notification).should('contain', 'Create upstream successfully');
cy.get(domSelectors.notification).should('contain', 'Create Upstream Successfully');
cy.wait(sleepTime * 5);
cy.url().should('contains', 'upstream/list');
});
Expand All @@ -112,6 +112,6 @@ context('Create and Delete Upstream', () => {
cy.wait(sleepTime * 5);
cy.contains(name).siblings().contains('Delete').click();
cy.contains('button', 'Confirm').click();
cy.get(domSelectors.notification).should('contain', 'Delete successfully');
cy.get(domSelectors.notification).should('contain', 'Delete Upstream Successfully');
});
});
Loading

0 comments on commit 6c3f35c

Please sign in to comment.