Skip to content

Commit

Permalink
feat: refactor Plugin Orchestration (#1813)
Browse files Browse the repository at this point in the history
  • Loading branch information
juzhiyuan authored May 11, 2021
1 parent 059b30b commit 423c9e8
Show file tree
Hide file tree
Showing 40 changed files with 1,901 additions and 1,043 deletions.
5 changes: 3 additions & 2 deletions .actions/ASF-Release.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,12 @@ ASFLicenseHeaderLua.txt

# Skip files containing MIT License
web/scripts/verifyCommit.js
web/src/components/HeaderDropdown/index.less
web/src/components/HeaderDropdown/index.tsx
web/src/components/HeaderDropdown
web/src/components/NoticeIcon
web/src/components/PageLoading/index.tsx
web/src/components/RightContent
web/src/components/PluginFlow/components/ConfigPanel
web/src/components/PluginFlow/components/Toolbar
web/src/e2e/__mocks__/antd-pro-merge-less.js
web/src/e2e/baseLayout.e2e.js
web/src/pages/404.tsx
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/frontend-plugin-e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ jobs:
with:
go-version: '1.13'

- name: Download dag-to-lua
working-directory: ./
run: make dag-lib

- name: Start manager-api
working-directory: ./api
run: |
Expand Down
1 change: 1 addition & 0 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ The following components are provided under the MIT License. See project link fo
The text of each license is also included at licenses/LICENSE-[project].txt.

files from ant-design-pro: https://github.com/ant-design/ant-design-pro MIT
files from antvis-x6: https://github.com/antvis/X6 MIT
files from json.lua: https://github.com/rxi/json.lua MIT

========================================================================
Expand Down
21 changes: 21 additions & 0 deletions licenses/LICENSE-antvis-x6.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 Alipay.inc

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
/*
* 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 route with plugin orchestration', () => {
const selector = {
empty: '.ant-empty-normal',
name: '#name',
description: '#desc',
nodes_0_host: '#nodes_0_host',
nodes_0_port: '#nodes_0_port',
nodes_0_weight: '#nodes_0_weight',
groupButton: '.ant-radio-group',
canvas: '.x6-graph-svg',
startNode:
'#stencil > div > div.x6-widget-stencil-content > div:nth-child(1) > div > div > svg > g > g.x6-graph-svg-stage > g:nth-child(1) > g > circle',
notification: '.ant-notification-notice-message',
notificationClose: '.anticon-close',
nodeInput: '.x6-widget-stencil input[type="search"]',
hiddenGroup: '.x6-widget-stencil-group.unmatched',
canvasNode: '#container > svg > g > g.x6-graph-svg-stage > g:nth-child(2) > rect',
canvasContainer: '#container',
drawer: '.ant-drawer-content',
deleteAlert: '.ant-modal-body',
codemirrorScroll: '.CodeMirror-scroll',
};

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

it('should create route with plugin orchestration', function () {
cy.visit('/');
cy.contains('Route').click();
cy.get(selector.empty).should('be.visible');
cy.contains('Create').click();
cy.contains('Next').click().click();
cy.get(selector.name).type('routeName');
cy.get(selector.description).type('desc');
cy.contains('Next').click();

cy.get(selector.nodes_0_host).type('127.0.0.1');
cy.get(selector.nodes_0_port).clear().type('80');
cy.get(selector.nodes_0_weight).clear().type('1');
cy.contains('Next').click();

cy.get(selector.groupButton).contains('Orchestration').click();
cy.get(selector.canvas).should('be.visible');

// Plugin Orchestration
cy.get(selector.startNode).move({ x: 400, y: 0, force: true, position: 'center' });
cy.contains('Next').click();
cy.get(selector.notification).should('contain', 'Root node not found');
cy.get(selector.notificationClose).click().should('not.be.visible');

cy.get(selector.nodeInput).type('key-auth');
cy.get(selector.hiddenGroup).should('not.be.visible');
cy.contains('key-auth').move({ x: 300, y: 0, force: true, position: 'center' });
cy.contains('Next').click();
cy.get(selector.notification).should('contain', 'Root node not found');
cy.get(selector.notificationClose).click().should('not.be.visible');

// Linking nodes
cy.get(selector.canvasNode)
.click()
.then(() => {
const node2 = cy
.get('#container > svg > g > g.x6-graph-svg-stage > g:nth-child(2) > g > circle')
.eq(0);
const node1 = cy
.get('#container > svg > g > g.x6-graph-svg-stage > g:nth-child(1) > g > circle')
.eq(0);
node1
.trigger('mousedown')
.trigger('mousemove', { x: 0, y: 150, force: true })
.trigger('mouseup', { force: true });
});

cy.contains('Next').click();
cy.get(selector.notification).should('contain', 'Found node without configuration');
cy.get(selector.notificationClose).click().should('not.be.visible');

// Configuration plugins and submit
cy.get(selector.canvasContainer)
.click()
.within(() => {
cy.contains('key-auth').dblclick();
});
cy.contains('Submit').click();
cy.get(selector.drawer).should('not.exist');
cy.contains('Next').click();
cy.contains('Submit').click();

cy.contains('Submit Successfully');
cy.contains('Goto List').click();
cy.url().should('contains', 'routes/list');
});

it('should view and delete the route', function () {
cy.visit('/routes/list');
cy.contains('routeName').siblings().contains('More').click();
cy.contains('View').click();
cy.get(selector.codemirrorScroll).within(() => {
cy.contains('script').should('exist');
});
cy.contains('Cancel').click();

// Delete the route
cy.contains('routeName').siblings().contains('More').click();
cy.contains('Delete').click();
cy.get(selector.deleteAlert)
.should('be.visible')
.within(() => {
cy.contains('OK').click();
});
cy.get(selector.notification).should('contain', 'Delete Route Successfully');
});
});
1 change: 1 addition & 0 deletions web/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
/* eslint-disable no-undef */
import defaultSettings from '../../config/defaultSettings';
import 'cypress-file-upload';
import '@4tw/cypress-drag-drop';

Cypress.Commands.add('login', () => {
const { SERVE_ENV = 'dev' } = Cypress.env();
Expand Down
4 changes: 3 additions & 1 deletion web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@
"@ant-design/icons": "^4.0.0",
"@ant-design/pro-layout": "^6.0.0",
"@ant-design/pro-table": "2.30.1",
"@mrblenny/react-flow-chart": "^0.0.14",
"@antv/x6": "^1.18.5",
"@antv/x6-react-components": "^1.1.7",
"@rjsf/antd": "2.2.0",
"@rjsf/core": "2.2.0",
"@types/js-yaml": "^4.0.0",
Expand Down Expand Up @@ -88,6 +89,7 @@
"yaml": "^1.10.0"
},
"devDependencies": {
"@4tw/cypress-drag-drop": "^1.6.0",
"@ant-design/pro-cli": "^2.0.2",
"@cypress/code-coverage": "^3.9.2",
"@types/base-64": "^0.1.3",
Expand Down
Loading

0 comments on commit 423c9e8

Please sign in to comment.