Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add frontend e2e test (create_and_delete_upstream) #1066

Merged
merged 28 commits into from
Dec 28, 2020
Merged
Changes from 9 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
e0c39bf
test: add e2e for web-create_and_delete_upstream
idbeta Dec 18, 2020
aa2be78
move to upstream folder
idbeta Dec 18, 2020
69dc364
chore: fix code style
idbeta Dec 18, 2020
14584a4
chore: fix code style
idbeta Dec 18, 2020
6d680f9
chore: fix code style
idbeta Dec 18, 2020
2ea5c6d
Merge branch 'master' into add-e2e-smoketest
idbeta Dec 21, 2020
a99940a
test: use camelCase, modify upstream name, method to access upstream…
idbeta Dec 21, 2020
6d7a742
remove useless code
idbeta Dec 21, 2020
85be9c8
Merge branch 'master' into add-e2e-smoketest
idbeta Dec 21, 2020
a518452
fixed: CI failed
idbeta Dec 22, 2020
e6fa8be
chore: modify comment
idbeta Dec 22, 2020
372a11c
Merge branch 'master' into add-e2e-smoketest
juzhiyuan Dec 22, 2020
5b7e9f1
Merge branch 'master' into add-e2e-smoketest
juzhiyuan Dec 22, 2020
10df523
Merge branch 'master' into add-e2e-smoketest
membphis Dec 23, 2020
02fdebd
add comment
idbeta Dec 23, 2020
6318965
Merge branch 'master' into add-e2e-smoketest
idbeta Dec 23, 2020
ed8dd83
Merge branch 'add-e2e-smoketest' of github.com:idbeta/apisix-dashboar…
idbeta Dec 23, 2020
4e9ff24
fixed code style
idbeta Dec 23, 2020
50b1c78
chore: fixed title
idbeta Dec 23, 2020
31c4bdf
Merge branch 'master' into add-e2e-smoketest
juzhiyuan Dec 25, 2020
0e200f6
Merge branch 'master' into add-e2e-smoketest
juzhiyuan Dec 25, 2020
3bc25ed
Merge branch 'master' into add-e2e-smoketest
idbeta Dec 25, 2020
afbc645
Merge branch 'add-e2e-smoketest' of github.com:idbeta/apisix-dashboar…
idbeta Dec 25, 2020
25b5487
chore: title add `should`
idbeta Dec 25, 2020
1d7ca52
Merge branch 'master' into add-e2e-smoketest
LiteSun Dec 25, 2020
3d36e5e
Merge branch 'master' into add-e2e-smoketest
membphis Dec 27, 2020
983dfbb
Merge branch 'master' into add-e2e-smoketest
juzhiyuan Dec 28, 2020
942dace
Merge branch 'master' into add-e2e-smoketest
juzhiyuan Dec 28, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 109 additions & 0 deletions web/cypress/integration/upstream/create_and_delete_upstream.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
/*
* 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 and Delete Upstream', () => {
const name = `upstreamName${new Date().valueOf()}`;
const sleepTime = 100;
membphis marked this conversation as resolved.
Show resolved Hide resolved
const domSelectors = {
notification: '.ant-notification-notice-message'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use a global file to contain those selector mappers?

};

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

it('create roundrobin upstream', () => {
juzhiyuan marked this conversation as resolved.
Show resolved Hide resolved
membphis marked this conversation as resolved.
Show resolved Hide resolved
// go to upstream create page
cy.visit('/');
cy.contains('Upstream').click();
cy.wait(sleepTime*5);
juzhiyuan marked this conversation as resolved.
Show resolved Hide resolved
cy.contains('Create').click();

// input Name And Description
cy.get('#name').type(name);
cy.get('#desc').type('desc_by_autotest');

// input information
cy.get('#nodes_0_host').type('127.0.0.1');
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');
juzhiyuan marked this conversation as resolved.
Show resolved Hide resolved
juzhiyuan marked this conversation as resolved.
Show resolved Hide resolved
cy.contains('Create upstream successfully');
cy.wait(sleepTime*5);
cy.url().should('contains', 'upstream/list');
});

it('delete the upstream', () => {
cy.visit('/');
cy.contains('Upstream').click();
cy.wait(sleepTime*5)
cy.contains(name).siblings().contains('Delete').click();
cy.contains('button', 'Confirm').click();
cy.get(domSelectors.notification).should('contain', 'Delete successfully');
});

it('create chash upstream', () => {
juzhiyuan marked this conversation as resolved.
Show resolved Hide resolved
// go to upstream create page
cy.visit('/');
cy.contains('Upstream').click();
cy.wait(sleepTime*5);
cy.contains('Create').click();

// input `Name And Description`
cy.get('#name').type(name);
cy.get('#desc').type('desc_by_autotest');

// change upstream type to chash, todo: optimize the search method
juzhiyuan marked this conversation as resolved.
Show resolved Hide resolved
cy.get('.ant-select-selection-item').click();
cy.wait(sleepTime);
cy.get('.ant-select-item:nth-child(2)').click();
cy.get('#hash_on').click();
cy.wait(sleepTime);
cy.get('.ant-select-item-option-active:nth-child(1) > .ant-select-item-option-content').click();
cy.get('#key').click();
cy.wait(sleepTime);
cy.get('div:nth-child(8) .ant-select-item:nth-child(1) > .ant-select-item-option-content:nth-child(1)').click();

// input chash upstream's information
// add first upstream node
cy.get('#nodes_0_host').type('127.0.0.1');
cy.get('#nodes_0_port').clear().type('7000');
// add second upstream node
membphis marked this conversation as resolved.
Show resolved Hide resolved
cy.get('.ant-btn-dashed').click();
cy.get('#nodes_1_host').type('127.0.0.1');
cy.get('#nodes_1_port').clear().type('7001');
cy.get('#nodes_1_weight').clear().type('2');
// next to finish
cy.contains('Next').click();
cy.contains('Submit').click();
cy.get(domSelectors.notification).should('contain', 'Create upstream successfully');
cy.wait(sleepTime*5);
cy.url().should('contains', 'upstream/list');
});

it('delete the upstream', () => {
cy.visit('/');
cy.contains('Upstream').click();
cy.wait(sleepTime*5);
cy.contains(name).siblings().contains('Delete').click();
cy.contains('button', 'Confirm').click();
cy.get(domSelectors.notification).should('contain', 'Delete successfully');
});
})