Skip to content

Commit

Permalink
Bugfix/stop button not working always (#121)
Browse files Browse the repository at this point in the history
* Added reset option to reset the test execution if Stop execution fails

* Fixed alignment in condition builder

* Aligned the condition builder to compy with allOf and oneOf syntax of openapi

* Bumped up the version and postponed the audits
  • Loading branch information
vijayg10 authored Sep 23, 2021
1 parent 9d2ad7c commit 72ea467
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 45 deletions.
24 changes: 12 additions & 12 deletions audit-resolve.json
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
},
"565|react-scripts>webpack>terser-webpack-plugin>cacache>ssri": {
"decision": "postpone",
"madeAt": 1631622865889
"madeAt": 1632415808487
},
"1665|socket.io-client>engine.io-client>xmlhttprequest-ssl": {
"decision": "fix",
Expand Down Expand Up @@ -23570,7 +23570,7 @@
},
"1693|react-scripts>postcss-safe-parser>postcss": {
"decision": "postpone",
"madeAt": 1631622866821
"madeAt": 1632415808983
},
"1693|react-scripts>css-loader>icss-utils>postcss": {
"decision": "postpone",
Expand Down Expand Up @@ -23886,7 +23886,7 @@
},
"1693|react-scripts>resolve-url-loader>postcss": {
"decision": "postpone",
"madeAt": 1631622868182
"madeAt": 1632415811063
},
"1746|socket.io-client>engine.io-client>xmlhttprequest-ssl": {
"decision": "fix",
Expand Down Expand Up @@ -24060,19 +24060,19 @@
},
"1747|react-scripts>react-dev-utils>browserslist": {
"decision": "postpone",
"madeAt": 1631622868756
"madeAt": 1632415811570
},
"1748|react-scripts>webpack-dev-server>ws": {
"decision": "postpone",
"madeAt": 1631622867496
"madeAt": 1632415809479
},
"1751|react-scripts>webpack>watchpack>watchpack-chokidar2>chokidar>glob-parent": {
"decision": "postpone",
"madeAt": 1631622869397
"madeAt": 1632415812110
},
"1751|react-scripts>webpack-dev-server>chokidar>glob-parent": {
"decision": "postpone",
"madeAt": 1631622869397
"madeAt": 1632415812110
},
"1754|react-scripts>@svgr/webpack>@svgr/plugin-svgo>svgo>css-select>css-what": {
"decision": "ignore",
Expand Down Expand Up @@ -24104,11 +24104,11 @@
},
"1770|react-scripts>terser-webpack-plugin>cacache>tar": {
"decision": "postpone",
"madeAt": 1631622670424
"madeAt": 1632415810097
},
"1771|react-scripts>terser-webpack-plugin>cacache>tar": {
"decision": "postpone",
"madeAt": 1631622670424
"madeAt": 1632415810097
},
"1776|react-scripts>webpack-dev-server>sockjs-client>eventsource>original>url-parse": {
"decision": "fix",
Expand Down Expand Up @@ -25280,15 +25280,15 @@
},
"1779|react-scripts>terser-webpack-plugin>cacache>tar": {
"decision": "postpone",
"madeAt": 1631622670424
"madeAt": 1632415810097
},
"1780|react-scripts>terser-webpack-plugin>cacache>tar": {
"decision": "postpone",
"madeAt": 1631622670424
"madeAt": 1632415810097
},
"1781|react-scripts>terser-webpack-plugin>cacache>tar": {
"decision": "postpone",
"madeAt": 1631622670424
"madeAt": 1632415810097
}
},
"rules": {},
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ml-testing-toolkit-ui",
"version": "13.5.2",
"version": "13.5.3",
"description": "Mojaloop Testing Toolkit Web User Interface",
"main": "index.js",
"repository": {
Expand Down
22 changes: 19 additions & 3 deletions src/views/outbound/OutboundRequest.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ class OutboundRequest extends React.Component {
tempReorderedTestCases: [],
serverLogsVisible: true,
testCaseEditorLogs: [],
environmentManagerVisible: false
environmentManagerVisible: false,
resetExecutionOptionEnabled: false
};
}

Expand Down Expand Up @@ -211,6 +212,9 @@ class OutboundRequest extends React.Component {
}

handleIncomingProgress = (progress) => {
if (!this.state.sendingOutboundRequestID) {
return null
}
if (progress.status === 'FINISHED') {
message.success({ content: 'Test case finished', key: 'outboundSendProgress', duration: 2 });
this.setState({ sendingOutboundRequestID: null, testReport: progress.totalResult })
Expand Down Expand Up @@ -295,6 +299,7 @@ class OutboundRequest extends React.Component {
// await axios.post(apiBaseUrl + "/api/outbound/template/" + outboundRequestID, template ? template : this.state.template, { headers: { 'Content-Type': 'application/json' } })
await axios.post(apiBaseUrl + "/api/outbound/template/" + traceId, convertedTemplate, { headers: { 'Content-Type': 'application/json' } })

this.state.resetExecutionOptionEnabled = false
this.state.sendingOutboundRequestID = traceId
this.state.lastOutgoingRequestID = traceId
this.state.testCaseEditorLogs = []
Expand Down Expand Up @@ -322,9 +327,20 @@ class OutboundRequest extends React.Component {
await axios.delete(apiBaseUrl + "/api/outbound/template/" + outboundRequestID)
}

handleResetExecution = async () => {
message.error({ content: 'Execution has been reset', key: 'outboundSendProgress', duration: 2 });
message.error({ content: 'Execution has been reset', key: 'outboundStopProgress', duration: 2 });
this.setState({ sendingOutboundRequestID: null, resetExecutionOptionEnabled: false })
}

handleSendStopClick = () => {
if (this.state.sendingOutboundRequestID) {
this.handleStopExecution(this.state.sendingOutboundRequestID)
if (this.state.resetExecutionOptionEnabled) {
this.handleResetExecution(this.state.sendingOutboundRequestID)
} else {
this.handleStopExecution(this.state.sendingOutboundRequestID)
this.setState({ resetExecutionOptionEnabled: true })
}
} else {
this.handleSendTemplate()
}
Expand Down Expand Up @@ -987,7 +1003,7 @@ class OutboundRequest extends React.Component {
danger
onClick={this.handleSendStopClick}
>
{this.state.sendingOutboundRequestID ? 'Stop' : 'Run'}
{this.state.sendingOutboundRequestID ? (this.state.resetExecutionOptionEnabled ? 'Reset' : 'Stop') : 'Run'}
</Button>
<Button
className="float-right mr-2"
Expand Down
28 changes: 20 additions & 8 deletions src/views/rules/BuilderTools.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import axios from 'axios';
import { Select, TreeSelect, Input, Tooltip, Tag } from 'antd';
import 'antd/dist/antd.css';
import jsf from 'json-schema-faker';
import _ from 'lodash';
// import './index.css';
import Ajv from 'ajv';
const ajv = new Ajv({allErrors: true});
Expand All @@ -38,6 +39,16 @@ jsf.option({
maxItems: 2
})

const _getSchema = (contentObj) => {
if (contentObj.hasOwnProperty('allOf')) {
return _.reduce(contentObj.allOf, _.merge)
} else if (contentObj.hasOwnProperty('oneOf')) {
return _.reduce(contentObj.oneOf, _.merge)
} else {
return contentObj
}
}

export class FactSelect extends React.Component {
constructor () {
super()
Expand Down Expand Up @@ -90,10 +101,11 @@ export class FactSelect extends React.Component {
}

getNodeFacts = (nodeData, parentId=0, valuePrefix='') => {
const nodeSchema = _getSchema(nodeData)
let factTreeData = [];
for (let property in nodeData.properties) {
for (let property in nodeSchema.properties) {
let isLeaf = true;
const fact = nodeData.properties[property];
const fact = _getSchema(nodeSchema.properties[property]);
if (fact.type === 'object') {
isLeaf = false;
}
Expand Down Expand Up @@ -145,7 +157,7 @@ export class FactDataGenerator {
getBodyFactData = (resourceDefinition) => {
let bodySchema = {}
try {
bodySchema = resourceDefinition.requestBody.content['application/json'].schema
bodySchema = _getSchema(resourceDefinition.requestBody.content['application/json'].schema)
} catch(err) {
}
return bodySchema
Expand Down Expand Up @@ -174,7 +186,7 @@ export class FactDataGenerator {
try {
totalParameters.concat(resourceDefinition.parameters).forEach((item) => {
if (item.in === 'header') {
headerSchema.properties[item.name] = item.schema
headerSchema.properties[item.name] = _getSchema(item.schema)
}
})
} catch(err) {
Expand Down Expand Up @@ -207,7 +219,7 @@ export class FactDataGenerator {
try {
parameters.forEach((item) => {
if (item.in === 'path') {
pathParametersSchema.properties[item.name] = item.schema
pathParametersSchema.properties[item.name] = _getSchema(item.schema)
}
})
} catch(err) {
Expand All @@ -224,7 +236,7 @@ export class FactDataGenerator {
try {
parameters.forEach((item) => {
if (item.in === 'query') {
queryParametersSchema.properties[item.name] = item.schema
queryParametersSchema.properties[item.name] = _getSchema(item.schema)
}
})
} catch(err) {
Expand All @@ -246,7 +258,7 @@ export class FactDataGenerator {
return {
type: 'object',
properties: {
body: resourceDefinition.responses[errorCode].content['application/json'].schema
body: _getSchema(resourceDefinition.responses[errorCode].content['application/json'].schema)
}
}
} catch(err) {
Expand All @@ -261,7 +273,7 @@ export class FactDataGenerator {
getSelectedResponseBodySchema = (responses, statusCode) => {
let bodySchema = {}
try {
bodySchema = responses[statusCode].content['application/json'].schema
bodySchema = _getSchema(responses[statusCode].content['application/json'].schema)
} catch(err) {
}
return bodySchema
Expand Down
38 changes: 18 additions & 20 deletions src/views/rules/ConditionBuilder.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class ValueSelector extends React.Component {
<Select
onChange={this.handleValueChange}
value={this.props.value}
style={{ width: 220 }}
>
{ this.props.selectedFact.enum.map(item => {
return (
Expand Down Expand Up @@ -362,10 +363,8 @@ class Condition extends React.Component {
render() {
return (
<Card>
<table width="100%">
<tbody>
<tr>
<td>
<Row>
<Col span={8}>
<label>
Fact Type
</label>
Expand All @@ -374,50 +373,49 @@ class Condition extends React.Component {
<Select
value={JSON.stringify(this.state.selectedFactType)}
onChange={this.handleFactTypeSelect}
style={{minWidth: '150px'}}
style={{width: '100%'}}
>
{this.getFactTypeItems()}
</Select>
</td>
<td>
</Col>
<Col span={8} className='pl-2'>
<label>
Fact
</label>
<br />
<FactSelect factData={this.state.factData} value={this.state.selectedFactPath} onSelect={this.handleFactSelect} />
</td>
<td>
</Col>
<Col span={8} className='pl-2'>
<label>
Operator
</label>
<br />
<Select style={{ width: 180 }} value={this.state.selectedOperator} onChange={this.handleOperatorSelect}>
<Select style={{ width: '100%' }} value={this.state.selectedOperator} onChange={this.handleOperatorSelect}>
{this.getOperatorItems()}
</Select>
</td>
</tr>
<tr>
<td colSpan='2'>
</Col>
</Row>
<Row className='mt-2'>
<Col span={8}>
<label>
Value
</label>
<br />
<ValueSelector value={this.props.condition.value} selectedFact={this.state.selectedFact} selectedOperator={this.state.selectedOperator} onChange={this.handleValueChange} />

</td>
<td align='right'>
</Col>
<Col span={16}>
<br />
<Button
className='float-right'
type="primary"
danger
onClick={this.handleDelete}
>
Delete
</Button>
</td>
</tr>
</tbody>
</table>
</Col>
</Row>
</Card>

)
Expand Down

0 comments on commit 72ea467

Please sign in to comment.