Skip to content

Commit ef4a575

Browse files
committed
Rename evaluate to assert node
1 parent ad4c2a8 commit ef4a575

File tree

12 files changed

+63
-360
lines changed

12 files changed

+63
-360
lines changed

packages/flowtest-electron/src/utils/flowparser/EvaluateNode.js renamed to packages/flowtest-electron/src/utils/flowparser/AssertNode.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
const { Node } = require('./Node');
22

3-
class EvaluateNode extends Node {
3+
class AssertNode extends Node {
44
constructor() {
5-
super('evaluateNode');
5+
super('assertNode');
66
}
77

88
serialize(id, data, metadata) {
99
return {
1010
id,
11-
type: 'evaluateNode',
11+
type: 'assertNode',
1212
data,
1313
...metadata,
1414
};
@@ -30,5 +30,5 @@ class EvaluateNode extends Node {
3030
}
3131

3232
module.exports = {
33-
EvaluateNode,
33+
AssertNode,
3434
};

packages/flowtest-electron/src/utils/flowparser/parser.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const { cloneDeep } = require('lodash');
22
const { AuthNode } = require('./AuthNode');
33
const { ComplexNode } = require('./ComplexNode');
44
const { DelayNode } = require('./DelayNode');
5-
const { EvaluateNode } = require('./EvaluateNode');
5+
const { AssertNode } = require('./AssertNode');
66
const { OutputNode } = require('./OutputNode');
77
const { RequestNode } = require('./RequestNode');
88
const { StartNode } = require('./StartNode');
@@ -96,16 +96,16 @@ const deserialize = (flowData) => {
9696
};
9797
}
9898

99-
if (node.type === 'evaluateNode') {
100-
const eNode = new EvaluateNode();
99+
if (node.type === 'assertNode') {
100+
const eNode = new AssertNode();
101101
const result = eNode.deserialize(node);
102102
textData.graph.data.nodes[result.id] = {
103-
type: 'evaluateNode',
103+
type: 'assertNode',
104104
...result.data,
105105
};
106106

107107
textData.graph.metadata.nodes[result.id] = {
108-
type: 'evaluateNode',
108+
type: 'assertNode',
109109
...result.metadata,
110110
};
111111
}
@@ -196,10 +196,10 @@ const serialize = (textData) => {
196196
flowData.nodes.push(result);
197197
}
198198

199-
if (value.type === 'evaluateNode') {
199+
if (value.type === 'assertNode') {
200200
const data = value;
201201
const metadata = textDataCopy.graph.metadata.nodes[id];
202-
const dNode = new EvaluateNode();
202+
const dNode = new AssertNode();
203203
const result = dNode.serialize(id, data, metadata);
204204
flowData.nodes.push(result);
205205
}

packages/flowtest-electron/tests/utils/flowtest-parser.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,14 +124,14 @@ describe('FlowTest parser', () => {
124124
},
125125
{
126126
id: '9',
127-
type: 'evaluateNode',
127+
type: 'assertNode',
128128
position: {
129129
x: 1958.6425053074213,
130130
y: 59.84168648963893,
131131
},
132132
data: {
133-
description: 'Evaluate conditional expressions.',
134-
type: 'evaluateNode',
133+
description: 'Assert on conditional expressions.',
134+
type: 'assertNode',
135135
variables: {
136136
var1: {
137137
type: 'String',

src/components/molecules/flow/AddNodes.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ const outputNode = {
3737
type: 'outputNode',
3838
};
3939

40-
const evaluateNode = {
41-
description: 'Evaluate conditional expressions.',
42-
type: 'evaluateNode',
40+
const assertNode = {
41+
description: 'Assert on conditional expressions.',
42+
type: 'assertNode',
4343
};
4444

4545
const delayNode = {
@@ -201,24 +201,24 @@ const AddNodes = ({ collectionId }) => {
201201
</>
202202
)}
203203
</Disclosure>
204-
{/* Evaluate */}
204+
{/* Assert */}
205205
<Disclosure as='div'>
206206
{({ open }) => (
207207
<>
208208
<Disclosure.Button className='flex justify-between w-full px-4 py-2 text-lg font-medium text-left border-t border-b bg-gray-50 hover:bg-gray-100 focus:outline-none focus-visible:ring'>
209-
<span>Evaluate</span>
209+
<span>Assert</span>
210210
<ChevronUpIcon className={`${open ? 'rotate-180 transform' : ''} h-5 w-5 `} />
211211
</Disclosure.Button>
212212
<Disclosure.Panel className='px-4 pt-4 pb-2 text-sm border-l border-r'>
213213
<div
214-
key='evaluate'
215-
onDragStart={(event) => onDragStart(event, evaluateNode)}
214+
key='assert'
215+
onDragStart={(event) => onDragStart(event, assertNode)}
216216
draggable
217217
cursor='move'
218218
className='py-2 border-b'
219219
>
220-
<div className='text-base font-semibold primary-text'>Evaluate</div>
221-
<div className='text-xs secondary-text'>{evaluateNode.description}</div>
220+
<div className='text-base font-semibold primary-text'>Assert</div>
221+
<div className='text-xs secondary-text'>{assertNode.description}</div>
222222
</div>
223223
</Disclosure.Panel>
224224
</>

src/components/molecules/flow/graph/Graph.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import { cloneDeep } from 'lodash';
44
import { readFlowTestSync } from 'service/collection';
55
import useCanvasStore from 'stores/CanvasStore';
66
import authNode from './compute/authnode';
7-
import complexNode from './compute/complexNode';
8-
import evaluateNode from './compute/evaluateNode';
7+
import complexNode from './compute/complexnode';
8+
import assertNode from './compute/assertnode';
99
import requestNode from './compute/requestNode';
1010

1111
class Graph {
@@ -27,7 +27,7 @@ class Graph {
2727
#computeConnectingEdge(node, result) {
2828
let connectingEdge = undefined;
2929

30-
if (node.type === 'evaluateNode') {
30+
if (node.type === 'assertNode') {
3131
if (result.output === true) {
3232
connectingEdge = this.edges.find((edge) => edge.sourceHandle == 'true' && edge.source === node.id);
3333
} else {
@@ -73,8 +73,8 @@ class Graph {
7373
};
7474
}
7575

76-
if (node.type === 'evaluateNode') {
77-
const eNode = new evaluateNode(node.data.operator, node.data.variables, prevNodeOutputData, this.logs);
76+
if (node.type === 'assertNode') {
77+
const eNode = new assertNode(node.data.operator, node.data.variables, prevNodeOutputData, this.logs);
7878
if (eNode.evaluate()) {
7979
this.logs.push('Result: true');
8080
result = {
@@ -162,7 +162,7 @@ class Graph {
162162
if (connectingEdge != undefined) {
163163
const nextNode = this.nodes.find(
164164
(node) =>
165-
['requestNode', 'outputNode', 'evaluateNode', 'delayNode', 'authNode', 'complexNode'].includes(node.type) &&
165+
['requestNode', 'outputNode', 'assertNode', 'delayNode', 'authNode', 'complexNode'].includes(node.type) &&
166166
node.id === connectingEdge.target,
167167
);
168168
this.graphRunNodeOutput[node.id] = result.data ? result.data : {};

src/components/molecules/flow/graph/compute/evaluatenode.js renamed to src/components/molecules/flow/graph/compute/assertnode.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
import Operators from '../../constants/operators';
2-
import { computeNodeVariables } from '../compute/utils';
2+
import { computeNodeVariables } from './utils';
33
import Node from './node';
44

5-
class evaluateNode extends Node {
5+
class assertNode extends Node {
66
constructor(operator, variables, prevNodeOutputData, logs) {
7-
super('evaluateNode');
7+
super('assertNode');
88
this.operator = operator;
99
this.variables = variables;
1010
this.prevNodeOutputData = prevNodeOutputData;
1111
this.logs = logs;
1212
}
1313

1414
evaluate() {
15-
console.log('Evaluating an evaluate node');
15+
console.log('Evaluating an assert node');
1616
const evalVariables = computeNodeVariables(this.variables, this.prevNodeOutputData);
1717
const var1 = evalVariables.var1;
1818
const var2 = evalVariables.var2;
@@ -22,7 +22,7 @@ class evaluateNode extends Node {
2222
throw 'Operator undefined';
2323
}
2424
this.logs.push(
25-
`Evaluate var1: ${JSON.stringify(var1)} of type: ${typeof var1}, var2: ${JSON.stringify(var2)} of type: ${typeof var2} with operator: ${operator}`,
25+
`Assert var1: ${JSON.stringify(var1)} of type: ${typeof var1}, var2: ${JSON.stringify(var2)} of type: ${typeof var2} with operator: ${operator}`,
2626
);
2727
if (operator == Operators.isEqualTo) {
2828
return var1 === var2;
@@ -36,4 +36,4 @@ class evaluateNode extends Node {
3636
}
3737
}
3838

39-
export default evaluateNode;
39+
export default assertNode;

src/components/molecules/flow/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import CustomEdge from './edges/ButtonEdge';
1414
import AddNodes from './AddNodes';
1515
import RequestNode from './nodes/RequestNode';
1616
import OutputNode from './nodes/OutputNode';
17-
import EvaluateNode from './nodes/EvaluateNode';
17+
import AssertNode from './nodes/AssertNode';
1818
import DelayNode from './nodes/DelayNode';
1919
import AuthNode from './nodes/AuthNode';
2020
import FlowNode from 'components/atoms/flow/FlowNode';
@@ -88,7 +88,7 @@ const Flow = ({ collectionId }) => {
8888
startNode: StartNode,
8989
requestNode: RequestNode,
9090
outputNode: OutputNode,
91-
evaluateNode: EvaluateNode,
91+
assertNode: AssertNode,
9292
delayNode: DelayNode,
9393
authNode: AuthNode,
9494
complexNode: ComplexNode,

src/components/molecules/flow/nodes/EvaluateNode.js renamed to src/components/molecules/flow/nodes/AssertNode.js

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ import { CHOOSE_OPERATOR_DEFAULT_VALUE_OBJ } from 'constants/Common';
88
import useCanvasStore from 'stores/CanvasStore';
99

1010
const operatorMenu = (id, data) => {
11-
const setEvaluateNodeOperator = useCanvasStore((state) => state.setEvaluateNodeOperator);
11+
const setAssertNodeOperator = useCanvasStore((state) => state.setAssertNodeOperator);
1212

1313
const handleOperatorSelection = (event) => {
1414
const selectedValue = event.target?.value;
1515
// ToDO: verify the behavior when use selects the default item
1616
if (selectedValue !== CHOOSE_OPERATOR_DEFAULT_VALUE_OBJ.value) {
17-
setEvaluateNodeOperator(id, selectedValue);
17+
setAssertNodeOperator(id, selectedValue);
1818
}
1919
};
2020

@@ -24,7 +24,7 @@ const operatorMenu = (id, data) => {
2424
onChange={handleOperatorSelection}
2525
name='operator-type'
2626
value={data.operator ? data.operator : CHOOSE_OPERATOR_DEFAULT_VALUE_OBJ.value}
27-
className='h-12 w-full rounded-md border border-neutral-500 px-1 py-2 text-neutral-500 outline-0 focus:ring-0'
27+
className='w-full h-12 px-1 py-2 border rounded-md border-neutral-500 text-neutral-500 outline-0 focus:ring-0'
2828
>
2929
<option value={CHOOSE_OPERATOR_DEFAULT_VALUE_OBJ.value}>
3030
{CHOOSE_OPERATOR_DEFAULT_VALUE_OBJ.displayValue}
@@ -40,32 +40,32 @@ const operatorMenu = (id, data) => {
4040

4141
// ToDo: refactor component parameters, make it more readable. vname and data are not suited
4242
const variableElem = (id, data, varName) => {
43-
const setEvaluateNodeVariable = useCanvasStore((state) => state.setEvaluateNodeVariable);
43+
const setAssertNodeVariable = useCanvasStore((state) => state.setAssertNodeVariable);
4444

4545
const handleInputTypeSelection = (event) => {
4646
const selectedValue = event.target?.value;
4747
switch (selectedValue) {
4848
case 'String':
49-
setEvaluateNodeVariable(id, varName, selectedValue, '');
49+
setAssertNodeVariable(id, varName, selectedValue, '');
5050
break;
5151
case 'Select':
52-
setEvaluateNodeVariable(id, varName, selectedValue, '');
52+
setAssertNodeVariable(id, varName, selectedValue, '');
5353
break;
5454
case 'Number':
55-
setEvaluateNodeVariable(id, varName, selectedValue, 0);
55+
setAssertNodeVariable(id, varName, selectedValue, 0);
5656
break;
5757
case 'Boolean':
58-
setEvaluateNodeVariable(id, varName, selectedValue, false);
58+
setAssertNodeVariable(id, varName, selectedValue, false);
5959
break;
6060
}
6161
};
6262

6363
const handleBooleanValueSelection = (event) => {
64-
setEvaluateNodeVariable(id, varName, 'Boolean', event.target?.value);
64+
setAssertNodeVariable(id, varName, 'Boolean', event.target?.value);
6565
};
6666

6767
return (
68-
<div className='mb-4 flex items-center justify-center rounded-md border border-neutral-500 text-sm text-neutral-500 outline-0 focus:ring-0'>
68+
<div className='flex items-center justify-center mb-4 text-sm border rounded-md border-neutral-500 text-neutral-500 outline-0 focus:ring-0'>
6969
{data.variables && data.variables[varName] ? (
7070
data.variables[varName].type === 'Boolean' ? (
7171
<select
@@ -91,17 +91,17 @@ const variableElem = (id, data, varName) => {
9191
case 'String':
9292
// data.variables[varName].value = updatedValue.toString();
9393
// setVariableValue(updatedValue.toString());
94-
setEvaluateNodeVariable(id, varName, 'String', updatedValue.toString());
94+
setAssertNodeVariable(id, varName, 'String', updatedValue.toString());
9595
break;
9696
case 'Select':
9797
// data.variables[varName].value = updatedValue.toString();
9898
// setVariableValue(updatedValue.toString());
99-
setEvaluateNodeVariable(id, varName, 'Select', updatedValue.toString());
99+
setAssertNodeVariable(id, varName, 'Select', updatedValue.toString());
100100
break;
101101
case 'Number':
102102
// data.variables[varName].value = parseInt(updatedValue);
103103
// setVariableValue(parseInt(updatedValue));
104-
setEvaluateNodeVariable(id, varName, 'Number', parseInt(updatedValue));
104+
setAssertNodeVariable(id, varName, 'Number', parseInt(updatedValue));
105105
break;
106106
}
107107
}}
@@ -118,15 +118,15 @@ const variableElem = (id, data, varName) => {
118118
onChange={(event) => {
119119
// default type is string, as soon as we select another type, it goes to above flow
120120
const updatedValue = event.target.value;
121-
setEvaluateNodeVariable(id, varName, 'String', updatedValue.toString());
121+
setAssertNodeVariable(id, varName, 'String', updatedValue.toString());
122122
}}
123123
/>
124124
)}
125125

126126
<select
127127
onChange={handleInputTypeSelection}
128128
name='var-input-type'
129-
className='nodrag h-8 w-full rounded-br-md rounded-tr-md border-l border-l-neutral-500 p-0 px-1'
129+
className='w-full h-8 p-0 px-1 border-l nodrag rounded-br-md rounded-tr-md border-l-neutral-500'
130130
value={data.variables && data.variables[varName] ? data.variables[varName].type : 'String'}
131131
>
132132
<option value='Select'>Select</option>
@@ -138,10 +138,10 @@ const variableElem = (id, data, varName) => {
138138
);
139139
};
140140

141-
const EvaluateNode = ({ id, data }) => {
141+
const AssertNode = ({ id, data }) => {
142142
return (
143143
<FlowNode
144-
title='Evaluate'
144+
title='Assert'
145145
handleLeft={true}
146146
handleLeftData={{ type: 'target' }}
147147
handleRight={true}
@@ -163,8 +163,8 @@ const EvaluateNode = ({ id, data }) => {
163163
);
164164
};
165165

166-
EvaluateNode.propTypes = {
166+
AssertNode.propTypes = {
167167
data: PropTypes.object.isRequired,
168168
};
169169

170-
export default EvaluateNode;
170+
export default AssertNode;

src/components/molecules/flow/nodes/OutputNode.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ import { PropTypes } from 'prop-types';
33
import FlowNode from 'components/atoms/flow/FlowNode';
44

55
const OutputNode = ({ id, data }) => {
6+
console.log('output node id: ', id);
7+
console.log('output node data: ', data);
8+
69
return (
710
<FlowNode
811
title='Output'

src/constants/Flow.js

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)