-
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
feat: support data loader in frontend #2480
Merged
Merged
Changes from 6 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
9802c4f
feat: support new drawer form
bzp2010 963f92e
feat: move to en-US i18n
bzp2010 09b5350
feat: add new form and remove old
bzp2010 2e75e27
chore: add more i18n language
bzp2010 acd6ec2
feat: update drawer result implementation
bzp2010 841e95a
test: add import cases
bzp2010 924cdcc
fix: zhcn i18n style
bzp2010 2410844
feat: add memo
bzp2010 8eb30db
test: remove unused codes
bzp2010 d976364
test: add assert for ensure drawer closed
bzp2010 7f87496
feat: improve props of Import component
bzp2010 eab1198
feat: add an error log in console for debug
bzp2010 6aad851
feat: move console.error to empty function
bzp2010 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
198 changes: 198 additions & 0 deletions
198
web/cypress/integration/route/data-loader-import.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,198 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
context('Data Loader import', () => { | ||
const selector = { | ||
drawer: '.ant-drawer-content', | ||
selectDropdown: '.ant-select-dropdown', | ||
listTbody: '.ant-table-tbody', | ||
listRow: 'tr.ant-table-row-level-0', | ||
refresh: '.anticon-reload', | ||
notification: '.ant-notification-notice-message', | ||
notificationCloseIcon: '.ant-notification-notice-close', | ||
fileSelector: '[type=file]', | ||
notificationDesc: '.ant-notification-notice-description', | ||
task_name: '#task_name', | ||
merge_method: '#merge_method', | ||
}; | ||
const data = { | ||
route_name_0: 'route_name_0', | ||
route_name_1: 'route_name_1', | ||
upstream_node0_host_0: '1.1.1.1', | ||
upstream_node0_host_1: '2.2.2.2', | ||
importErrorMsg: 'required file type is .yaml, .yml or .json but got: .txt', | ||
uploadRouteFiles: [ | ||
'../../../api/test/testdata/import/default.json', | ||
'../../../api/test/testdata/import/default.yaml', | ||
'import-error.txt', | ||
], | ||
// Note: export file's name will be end of a timestamp | ||
jsonMask: 'cypress/downloads/*.json', | ||
yamlMask: 'cypress/downloads/*.yaml', | ||
port: '80', | ||
weight: 1, | ||
importRouteSuccess: 'Import Successfully', | ||
deleteRouteSuccess: 'Delete Route Successfully', | ||
deleteUpstreamSuccess: 'Delete Upstream Successfully', | ||
}; | ||
const cases = { | ||
API101: '../../../api/test/testdata/import/Postman-API101.yaml', | ||
}; | ||
|
||
beforeEach(() => { | ||
cy.login(); | ||
|
||
cy.fixture('selector.json').as('domSelector'); | ||
cy.fixture('data.json').as('data'); | ||
cy.fixture('export-route-dataset.json').as('exportFile'); | ||
}); | ||
|
||
it('should import API101 with merge mode', () => { | ||
cy.visit('/'); | ||
cy.contains('Route').click(); | ||
|
||
cy.get(selector.refresh).click(); | ||
cy.contains('Advanced').click(); | ||
cy.contains('Import').should('be.visible').click(); | ||
|
||
// select Data Loader type | ||
cy.contains('OpenAPI 3').should('be.visible').click(); | ||
cy.get(selector.selectDropdown).contains('OpenAPI 3').should('be.visible').click(); | ||
cy.get(selector.drawer).get(selector.task_name).type('api101_mm'); | ||
cy.get(selector.fileSelector).attachFile(cases.API101); | ||
cy.get(selector.drawer).contains('Submit').click(); | ||
cy.get(selector.drawer).contains('Import Successfully').should('be.visible'); | ||
cy.get(selector.drawer).contains('Total 3 route imported, 0 failed').click(); | ||
cy.get(selector.drawer).contains('Close').click(); | ||
|
||
// check result | ||
cy.get(selector.listTbody).get(selector.listRow).should('have.length', 3); | ||
cy.contains('api101_mm_customer').should('be.visible'); | ||
cy.contains('api101_mm_customer/{customer_id}').should('be.visible'); | ||
cy.contains('api101_mm_customers').should('be.visible'); | ||
|
||
// remove route | ||
for (let i = 0; i < 3; i += 1) { | ||
cy.get(selector.listTbody).get(selector.listRow).contains('More').click(); | ||
cy.contains('Delete').should('be.visible').click(); | ||
cy.contains('OK').should('be.visible').click(); | ||
cy.get(selector.notification).should('contain', data.deleteRouteSuccess); | ||
cy.get(selector.notificationCloseIcon).click(); | ||
} | ||
}); | ||
|
||
it('should import API101 with duplicate upstream', () => { | ||
cy.visit('/'); | ||
cy.contains('Route').click(); | ||
|
||
cy.get(selector.refresh).click(); | ||
cy.contains('Advanced').click(); | ||
cy.contains('Import').should('be.visible').click(); | ||
|
||
// select Data Loader type | ||
cy.contains('OpenAPI 3').should('be.visible').click(); | ||
cy.get(selector.selectDropdown).contains('OpenAPI 3').should('be.visible').click(); | ||
cy.get(selector.drawer).get(selector.task_name).type('api101_mm'); | ||
cy.get(selector.fileSelector).attachFile(cases.API101); | ||
cy.get(selector.drawer).contains('Submit').click(); | ||
cy.get(selector.drawer).contains('Import Failed').should('be.visible'); | ||
cy.get(selector.drawer).contains('Total 1 upstream imported, 1 failed').click(); | ||
cy.get(selector.drawer).contains('key: api101_mm is conflicted').should('be.visible'); | ||
cy.get(selector.drawer).contains('Close').click(); | ||
|
||
// remove route | ||
for (let i = 0; i < 3; i += 1) { | ||
cy.get(selector.listTbody).get(selector.listRow).contains('More').click(); | ||
cy.contains('Delete').should('be.visible').click(); | ||
cy.contains('OK').should('be.visible').click(); | ||
cy.get(selector.notification).should('contain', data.deleteRouteSuccess); | ||
cy.get(selector.notificationCloseIcon).click(); | ||
} | ||
}); | ||
|
||
it('should import API101 with non-merge mode', () => { | ||
cy.visit('/'); | ||
cy.contains('Route').click(); | ||
|
||
cy.get(selector.refresh).click(); | ||
cy.contains('Advanced').click(); | ||
cy.contains('Import').should('be.visible').click(); | ||
|
||
// select Data Loader type | ||
cy.contains('OpenAPI 3').should('be.visible').click(); | ||
cy.get(selector.selectDropdown).contains('OpenAPI 3').should('be.visible').click(); | ||
cy.get(selector.drawer).get(selector.task_name).type('api101_nmm'); | ||
cy.get(selector.drawer).get(selector.merge_method).click(); | ||
cy.get(selector.fileSelector).attachFile(cases.API101); | ||
cy.get(selector.drawer).contains('Submit').click(); | ||
cy.get(selector.drawer).contains('Import Successfully').should('be.visible'); | ||
cy.get(selector.drawer).contains('Total 5 route imported, 0 failed').click(); | ||
cy.get(selector.drawer).contains('Close').click(); | ||
|
||
// check result | ||
cy.get(selector.listTbody).get(selector.listRow).should('have.length', 5); | ||
|
||
// remove route | ||
/**/ | ||
}); | ||
|
||
it('should import API101 with duplicate route', () => { | ||
cy.visit('/'); | ||
cy.contains('Route').click(); | ||
|
||
cy.get(selector.refresh).click(); | ||
cy.contains('Advanced').click(); | ||
cy.contains('Import').should('be.visible').click(); | ||
|
||
// select Data Loader type | ||
cy.contains('OpenAPI 3').should('be.visible').click(); | ||
cy.get(selector.selectDropdown).contains('OpenAPI 3').should('be.visible').click(); | ||
cy.get(selector.drawer).get(selector.task_name).type('api101_nmm'); | ||
cy.get(selector.drawer).get(selector.merge_method).click(); | ||
cy.get(selector.fileSelector).attachFile(cases.API101); | ||
cy.get(selector.drawer).contains('Submit').click(); | ||
cy.get(selector.drawer).contains('Import Failed').should('be.visible'); | ||
cy.get(selector.drawer).contains('Total 5 route imported, 1 failed').click(); | ||
cy.get(selector.drawer).contains('is duplicated with route api101_nmm_').should('be.visible'); | ||
cy.get(selector.drawer).contains('Close').click(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is best to add assertions to confirm that the drawer has disappeared There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added |
||
}); | ||
|
||
it('should remove all routes and upstreams', function () { | ||
cy.visit('/'); | ||
cy.contains('Route').click(); | ||
cy.get(selector.refresh).click(); | ||
// remove route | ||
for (let i = 0; i < 5; i += 1) { | ||
cy.get(selector.listTbody).get(selector.listRow).contains('More').click(); | ||
cy.contains('Delete').should('be.visible').click(); | ||
cy.contains('OK').should('be.visible').click(); | ||
cy.get(selector.notification).should('contain', data.deleteRouteSuccess); | ||
cy.get(selector.notificationCloseIcon).click(); | ||
} | ||
|
||
cy.visit('/'); | ||
cy.contains('Upstream').click(); | ||
cy.get(selector.refresh).click(); | ||
// remove route | ||
for (let i = 0; i < 2; i += 1) { | ||
cy.get(selector.listTbody).get(selector.listRow).contains('Delete').click(); | ||
cy.contains('Confirm').should('be.visible').click(); | ||
cy.get(selector.notification).should('contain', data.deleteUpstreamSuccess); | ||
cy.get(selector.notificationCloseIcon).click(); | ||
} | ||
}); | ||
}); |
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
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
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
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
Oops, something went wrong.
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.
This section seems to be able to be deleted
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.
removed