-
Notifications
You must be signed in to change notification settings - Fork 545
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
+110
−0
Merged
Changes from 27 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 aa2be78
move to upstream folder
idbeta 69dc364
chore: fix code style
idbeta 14584a4
chore: fix code style
idbeta 6d680f9
chore: fix code style
idbeta 2ea5c6d
Merge branch 'master' into add-e2e-smoketest
idbeta a99940a
test: use camelCase, modify upstream name, method to access upstream…
idbeta 6d7a742
remove useless code
idbeta 85be9c8
Merge branch 'master' into add-e2e-smoketest
idbeta a518452
fixed: CI failed
idbeta e6fa8be
chore: modify comment
idbeta 372a11c
Merge branch 'master' into add-e2e-smoketest
juzhiyuan 5b7e9f1
Merge branch 'master' into add-e2e-smoketest
juzhiyuan 10df523
Merge branch 'master' into add-e2e-smoketest
membphis 02fdebd
add comment
idbeta 6318965
Merge branch 'master' into add-e2e-smoketest
idbeta ed8dd83
Merge branch 'add-e2e-smoketest' of github.com:idbeta/apisix-dashboar…
idbeta 4e9ff24
fixed code style
idbeta 50b1c78
chore: fixed title
idbeta 31c4bdf
Merge branch 'master' into add-e2e-smoketest
juzhiyuan 0e200f6
Merge branch 'master' into add-e2e-smoketest
juzhiyuan 3bc25ed
Merge branch 'master' into add-e2e-smoketest
idbeta afbc645
Merge branch 'add-e2e-smoketest' of github.com:idbeta/apisix-dashboar…
idbeta 25b5487
chore: title add `should`
idbeta 1d7ca52
Merge branch 'master' into add-e2e-smoketest
LiteSun 3d36e5e
Merge branch 'master' into add-e2e-smoketest
membphis 983dfbb
Merge branch 'master' into add-e2e-smoketest
juzhiyuan 942dace
Merge branch 'master' into add-e2e-smoketest
juzhiyuan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
110 changes: 110 additions & 0 deletions
110
web/cypress/integration/upstream/create_and_delete_upstream.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
/* | ||
* 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; // the unit is milliseconds | ||
const domSelectors = { | ||
notification: '.ant-notification-notice-message' | ||
}; | ||
|
||
beforeEach(() => { | ||
// init login | ||
cy.login(); | ||
}) | ||
|
||
it('should create upstream with default type (roundrobin)', () => { | ||
// 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'); | ||
|
||
// 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('should 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('should create chash upstream', () => { | ||
// 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('[title=roundrobin]').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(); | ||
|
||
// 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('should 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'); | ||
}); | ||
}) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?