-
Notifications
You must be signed in to change notification settings - Fork 545
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add frontend e2e test (create_and_delete_upstream) (#1066)
* test: add e2e for web-create_and_delete_upstream * move to upstream folder * chore: fix code style * chore: fix code style * chore: fix code style * test: use camelCase, modify upstream name, method to access upstream list page, modify indentation * remove useless code * fixed: CI failed * chore: modify comment * add comment * fixed code style * chore: fixed title * chore: title add `should` Co-authored-by: 琚致远 <[email protected]> Co-authored-by: YuanSheng Wang <[email protected]> Co-authored-by: litesun <[email protected]>
- Loading branch information
1 parent
e594fc0
commit b194c61
Showing
1 changed file
with
110 additions
and
0 deletions.
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'); | ||
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 | ||
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 | ||
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'); | ||
}); | ||
}) |