-
Notifications
You must be signed in to change notification settings - Fork 534
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add rawDataEditor edit mode (#1601)
- Loading branch information
Showing
14 changed files
with
430 additions
and
44 deletions.
There are no files selected for viewing
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,86 @@ | ||
{ | ||
"Route": { | ||
"uris": [ | ||
"/*" | ||
], | ||
"name": "root", | ||
"methods": [ | ||
"GET", | ||
"HEAD", | ||
"POST", | ||
"PUT", | ||
"DELETE", | ||
"OPTIONS", | ||
"PATCH" | ||
], | ||
"upstream": { | ||
"nodes": [ | ||
{ | ||
"host": "12.12.12.12", | ||
"port": 80, | ||
"weight": 1 | ||
} | ||
], | ||
"timeout": { | ||
"connect": 6000, | ||
"read": 6000, | ||
"send": 6000 | ||
}, | ||
"type": "roundrobin", | ||
"pass_host": "pass" | ||
}, | ||
"status": 1 | ||
}, | ||
"Upstream": { | ||
"nodes": [ | ||
{ | ||
"host": "12.12.12.12", | ||
"port": 80, | ||
"weight": 1 | ||
} | ||
], | ||
"timeout": { | ||
"connect": 6, | ||
"read": 6, | ||
"send": 6 | ||
}, | ||
"type": "roundrobin", | ||
"pass_host": "pass", | ||
"name": "test" | ||
}, | ||
"Service": { | ||
"name": "test", | ||
"upstream": { | ||
"nodes": [ | ||
{ | ||
"host": "12.12.12.12", | ||
"port": 80, | ||
"weight": 1 | ||
} | ||
], | ||
"timeout": { | ||
"connect": 6, | ||
"read": 6, | ||
"send": 6 | ||
}, | ||
"type": "roundrobin", | ||
"pass_host": "pass" | ||
}, | ||
"plugins": { | ||
"jwt-auth": { | ||
"disable": false | ||
} | ||
} | ||
}, | ||
"Consumer": { | ||
"username": "test", | ||
"desc": "desc", | ||
"plugins": { | ||
"basic-auth": { | ||
"disable": false, | ||
"password": "test", | ||
"username": "test" | ||
} | ||
} | ||
} | ||
} |
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
96 changes: 96 additions & 0 deletions
96
web/cypress/integration/rawDataEditor/test-rawDataEditor.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,96 @@ | ||
/* | ||
* 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('Test RawDataEditor', () => { | ||
const timeout = 1000; | ||
|
||
beforeEach(() => { | ||
cy.login(); | ||
|
||
cy.fixture('rawDataEditor-dataset.json').as('dataset'); | ||
cy.fixture('selector.json').as('domSelector'); | ||
cy.fixture('data.json').as('data'); | ||
}); | ||
|
||
it('should create and update with rawDataEditor', function () { | ||
const menuList = ['Route', 'Service', 'Upstream', 'Consumer']; | ||
const publicData = this.data; | ||
const dateset = this.dataset; | ||
const domSelector = this.domSelector; | ||
menuList.forEach(function (item) { | ||
cy.visit('/'); | ||
cy.contains(item).click(); | ||
cy.contains('Create with Editor').click(); | ||
const data = dateset[item]; | ||
|
||
// create with editor | ||
cy.window().then(({ codemirror }) => { | ||
if (codemirror) { | ||
codemirror.setValue(JSON.stringify(data)); | ||
} | ||
cy.get(domSelector.drawer).should('exist'); | ||
cy.get(domSelector.drawer, { timeout }).within(() => { | ||
cy.contains('Submit').click({ | ||
force: true, | ||
}); | ||
cy.get(domSelector.drawer).should('not.exist'); | ||
}); | ||
}); | ||
|
||
cy.reload(); | ||
// update with editor | ||
cy.contains(item === 'Consumer' ? data.username : data.name) | ||
.siblings() | ||
.contains('View') | ||
.click(); | ||
|
||
cy.window().then(({ codemirror }) => { | ||
if (codemirror) { | ||
if (item === 'Consumer') { | ||
codemirror.setValue(JSON.stringify({ ...data, desc: 'newDesc' })); | ||
} else { | ||
codemirror.setValue(JSON.stringify({ ...data, name: 'newName' })); | ||
} | ||
} | ||
cy.get(domSelector.drawer).should('exist'); | ||
cy.get(domSelector.drawer, { timeout }).within(() => { | ||
cy.contains('Submit').click({ | ||
force: true, | ||
}); | ||
cy.get(domSelector.drawer).should('not.exist'); | ||
}); | ||
}); | ||
|
||
cy.reload(); | ||
cy.get(domSelector.tableBody).should('contain', item === 'Consumer' ? 'newDesc' : 'newName'); | ||
|
||
// delete resource | ||
cy.contains(item === 'Consumer' ? 'newDesc' : 'newName') | ||
.siblings() | ||
.contains('Delete') | ||
.click(); | ||
cy.contains('button', 'Confirm').click(); | ||
|
||
cy.get(domSelector.notification).should('contain', publicData[`delete${item}Success`]); | ||
cy.get(domSelector.notificationClose).should('be.visible').click({ | ||
force: true, | ||
multiple: true, | ||
}); | ||
}); | ||
}); | ||
}); |
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.