Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/build
/src/serviceWorker.js
36 changes: 36 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"parser": "babel-eslint",
"parserOptions": {
"ecmaVersion": 9,
"sourceType": "module"
},
"rules": {
"indent": [
"error",
2
],
"linebreak-style": [
"error",
"unix"
],
"quotes": [
"error",
"single"
],
"semi": [
"error",
"always"
],
"object-curly-spacing": [
"error",
"always"
],
"comma-spacing": [
"error",
{
"before": false,
"after": true
}
]
}
}
4,879 changes: 3,171 additions & 1,708 deletions package-lock.json

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{
"name": "tasty-ui",
"version": "0.2.8",
"version": "0.3.0",
"publishConfig": {
"access": "public"
},
"dependencies": {
"ajv": "^6.10.2",
"axios": "^0.19.0",
"body-parser": "^1.19.0",
"classnames": "^2.2.6",
Expand All @@ -15,6 +16,7 @@
"lodash": "^4.17.13",
"moment": "^2.24.0",
"nconf": "^0.10.0",
"node-sass": "^4.12.0",
"react": "^16.8.6",
"react-bootstrap": "^1.0.0-beta.9",
"react-bootstrap-table-next": "^3.1.5",
Expand Down Expand Up @@ -50,6 +52,7 @@
]
},
"devDependencies": {
"husky": "^2.7.0"
"husky": "^2.7.0",
"eslint":"^5.16.0"
}
}
42 changes: 42 additions & 0 deletions server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,46 @@ app.get('/api/log', (req, res) => {
});
});

app.get('/api/config', (req, res) => {
const { type } = req.query;
if (type) {
//getting the current configuration from tasty
const currentConfig = TastyRunner.getCurrentConfig(type);
res.json(currentConfig);
} else {
res.status(500).send('select the parameter in type! load or func example: ?type=load');
}
});
app.post('/api/config', (req, res) => {
const { type } = req.query;
if (type) {
// get
try {
TastyRunner.setCurrentConfig(type, req.body).then(result=>{
res.json({ result:true });
}).catch(error=>{
res.status(500).send('error while processing configuration');
});
}
catch(err){
res.status(500).send('error while parsing JSON');
}
} else {
res.status(500).send('error while getting the type! select ?type=load or ?type=func');
}
});
app.get('/api/config/schema', (req, res)=>{
const { type } = req.query;
if(type)
{
try {
const schema = TastyRunner.getSchema(type);
res.json(schema);
}
catch(err)
{
res.status(500).send(err);
}
}
});
module.exports = server;
2 changes: 1 addition & 1 deletion server/process/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Processor{
this.workDirectory = workingDir;
}
getTestFiles(type){
return recursive(path.resolve(path.join(this.workDirectory,type)))//@todo catch section!!!!!
return recursive(path.resolve(path.join(this.workDirectory, type)));//@todo catch section!!!!!
}
}
module.exports = Processor;
26 changes: 13 additions & 13 deletions server/routes/tests/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module.exports = function router(Router) {
customRouter.get('/', (req, res) => {
//console.log('request: ',req);
const mapFunc = (elt) => {
return {path: elt, name: path.basename(elt)};
return { path: elt, name: path.basename(elt) };
};
Router.getTestFiles('func').then(resultFunc => {
Router.getTestFiles('load').then(resultLoad => {
Expand All @@ -19,31 +19,31 @@ module.exports = function router(Router) {
customRouter.get('/types/', (req, res) => {
//console.log('request: ',req);
res.json({
types: ["functional", "load"]
})
types: ['functional', 'load']
});
});
customRouter.post('/run/', (req, res) => {
//@TODO this is a stub!!!
//@todo set different reports for functional and load tests
const {type} = req.body;
const { type } = req.body;
console.log('type:--->', type);
//@todo custom logic based on type of test
let strF = '';
switch (type) {
case 'functional':
strF='func';
break;
case 'load':
strF='load';
break;
default:
break;
case 'functional':
strF='func';
break;
case 'load':
strF='load';
break;
default:
break;
}
// simulation of test duration
setTimeout(() => {
//console.log('executed tests!');
//res.json({done:true});
console.log('file to send: ',path.resolve(path.join(process.cwd(), 'logs', strF+'_log.html')));
console.log('file to send: ', path.resolve(path.join(process.cwd(), 'logs', strF+'_log.html')));
res.sendFile(path.resolve(path.join(process.cwd(), 'logs', strF+'_log.html')));
}, 1000);
});
Expand Down
3 changes: 3 additions & 0 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Container, Nav, Navbar } from 'react-bootstrap';

import Testing from './pages/Testing';
import Reports from './pages/Reports';
import ConfigurationPage from './pages/Configuration';

const PROJECT_NAME = 'Lego';

Expand All @@ -15,12 +16,14 @@ function App() {
<Nav className="mr-auto">
<NavLink to="/tests" className="nav-link">Tests</NavLink>
<NavLink to="/reports" className="nav-link">Reports</NavLink>
<NavLink to="/config" className="nav-link">Configuration</NavLink>
</Nav>
</Navbar>
<Container className="App my-3" fluid>
<Switch>
<Route path="/tests" component={Testing} />
<Route path="/reports" component={Reports} />
<Route path="/config" component={ConfigurationPage} />
<Redirect to="/tests" />
</Switch>
</Container>
Expand Down
26 changes: 26 additions & 0 deletions src/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,29 @@ export const getLog = async () => {
return null;
}
};
export const getConfiguration = async (type) => {
try {
const res = await axios.get(`/api/config?type=${type}`);
return res.data;
} catch (err) {
return null;
}
};
export const setConfiguration = async (type, data) => {
try {
const sendData = JSON.parse(data);
const res = await axios.post(`/api/config?type=${type}`, sendData);
return res.data;
} catch (err) {
return { error:true, err };
}
};
export const getSchema = async (type) =>{
try{
const data = await axios.get(`/api/config/schema?type=${type}`);
return data.data;
}
catch(err){
return err;
}
};
24 changes: 12 additions & 12 deletions src/components/Report/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import React from 'react';
import * as api from '../../api';
import { Badge, Card, Spinner } from 'react-bootstrap';
import _ from 'lodash';
import Highcharts from "highcharts/highstock";
import HighchartsReact from 'highcharts-react-official'
import Highcharts from 'highcharts/highstock';
import HighchartsReact from 'highcharts-react-official';

class Report extends React.Component {
state = {
Expand All @@ -28,15 +28,15 @@ class Report extends React.Component {
const percent = test.stats.passes / test.stats.tests * 100;

switch (true) {
case percent === 100:
return 'passes';
case percent >= 90 && percent < 100:
return 'warning';
default:
return 'fails';
case percent === 100:
return 'passes';
case percent >= 90 && percent < 100:
return 'warning';
default:
return 'fails';
}
});
const failsPercent = _.get(stats,'fails', 0) / tests * 100;
const failsPercent = _.get(stats, 'fails', 0) / tests * 100;
const options = {
chart: {
plotBackgroundColor: null,
Expand All @@ -63,13 +63,13 @@ class Report extends React.Component {
series: [{
name: 'Tests',
colorByPoint: true,
innerSize: "27%",
innerSize: '27%',
data: [{
name: 'Passed',
y: stats.passes || 0,
color: "#2ec277",
color: '#2ec277',
}, {
name: "Failed",
name: 'Failed',
y: stats.fails || 0,
color: '#ff7774'
}, {
Expand Down
27 changes: 27 additions & 0 deletions src/pages/Configuration.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import React from 'react';
import { Nav } from 'react-bootstrap';
import { NavLink, Redirect, Route, Switch } from 'react-router-dom';
import Index from '../subpages/Config';

class ConfigurationPage extends React.Component {
render() {
return (
<>
<Nav variant="tabs">
<Nav.Item>
<Nav.Link as={NavLink} to={`${this.props.match.url}/func`}>Func</Nav.Link>
</Nav.Item>
<Nav.Item>
<Nav.Link as={NavLink} to={`${this.props.match.url}/load`}>Load</Nav.Link>
</Nav.Item>
</Nav>
<Switch>
<Route path={`${this.props.match.path}/:type`} component={Index}/>
<Redirect to={`${this.props.match.path}/func`}/>
</Switch>
</>
);
}
}

export default ConfigurationPage;
Loading