-
-
Notifications
You must be signed in to change notification settings - Fork 178
Expand file tree
/
Copy pathAction.tsx
More file actions
205 lines (195 loc) · 7.03 KB
/
Action.tsx
File metadata and controls
205 lines (195 loc) · 7.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
import React, { useContext } from 'react';
import styles from '../Action/Action.module.scss';
import AutoCompleteMockData from '../../AutoComplete/AutoCompleteMockData';
import ToolTip from '../../ToolTip/ToolTip';
import { MockDataContext } from '../../../context/reducers/updatedMockDataReducer';
import { GlobalContext } from '../../../context/reducers/globalReducer';
import { AiOutlineClose } from 'react-icons/ai';
import { ReactTestComponentAssertion } from '../../../utils/updatedReactTypes';
import { useRTFsContexts } from '../../../context/RTFsContextsProvider';
const questionIcon = require('../../../assets/images/help-circle.png');
// This is tracking the actions that you have in a specific test, following the flow of data will
// help you better understand exactly how this is working
type EventTypes =
| React.ChangeEvent<HTMLSelectElement>
| React.ChangeEvent<HTMLInputElement>;
type FieldTypes =
| 'eventType'
| 'eventValue'
| 'queryVariant'
| 'querySelector'
| 'queryValue';
// Action box in middle panel (testCase.jsx)
const Action = React.memo(({ blockObjectsState }) => {
const thisBlockObjectsState = blockObjectsState;
const [{ mockData }] = useContext(MockDataContext);
const [{ theme }] = useContext(GlobalContext);
const { handleAddBlock, handleChange, handleDeleteBlock, rTFDispatch } =
//useContext(RTFsContexts);
useRTFsContexts();
/*const handleChangeActionFields = (e: EventTypes, field: FieldTypes) => {
let updatedAction = { ...statement };
updatedAction[field] = e.target.value;
rTFDispatch(updateAction(updatedAction));
};*/
//conditional rendering for events with values
const needsEventValue = (eventType: string) => {
const eventsWithValues = [
'keyDown',
'keyPress',
'keyUp',
'change',
'input',
'invalid',
'submit',
];
return eventsWithValues.includes(eventType);
};
//needsEventsValue should be iterated on to create a <select>option
return (
<div id={styles[`action${theme}`]}>
<AiOutlineClose
id={styles.close}
onClick={() => {
handleDeleteBlock(
thisBlockObjectsState.parentsFilepath,
thisBlockObjectsState.key
);
}}
/>
<span className={styles.header}>Action</span>
<div id={styles.eventTypeFlexBox}>
<div id={styles.eventType}>
<label htmlFor="eventType">Event Type</label>
<input
type="text"
id="eventType"
value={blockObjectsState.eventType}
onChange={(e) =>
handleChange(
thisBlockObjectsState.filepath,
'eventType',
e.target.value
)
}
placeholder="eg. click, change, keyPress"
/>
</div>
<div id={styles.eventTypeVal}>
{needsEventValue(blockObjectsState.eventType) &&
mockData.length > 0 ? (
<div className={styles.eventValueMock}>
<label htmlFor="eventValue">Value</label>
<AutoCompleteMockData
//This needs to be figured out. Didn't have time to look into making AutoCOmpleteMck Data work
dispatchToTestCase={rTFDispatch}
statementType="action"
// id={styles2.autoCompleteMockData}
/>
</div>
) : needsEventValue(blockObjectsState.eventType) ? (
<span className={styles.eventValue}>
<label htmlFor="eventValue">Value</label>
<input
type="text"
id="eventValue"
onChange={(e) =>
handleChange(
thisBlockObjectsState.filepath,
'eventValue',
e.target.value
)
}
/>
</span>
) : null}
</div>
</div>
<div id={styles.queryFlexBox}>
<div id={styles.querySelector}>
<label htmlFor="queryVariant" className={styles.queryLabel}>
Query Selector
</label>
<div id={styles.dropdownFlex}>
<select
id="queryVariant"
value={blockObjectsState.queryVariant}
onChange={(e) =>
handleChange(
thisBlockObjectsState.filepath,
'queryVariant',
e.target.value
)
}
>
<option value="" />
<option value="getBy">getBy</option>
<option value="getAllBy">getAllBy</option>
<option value="queryBy">queryBy</option>
<option value="queryAllBy">queryAllBy</option>
<option value="findBy">findBy</option>
<option value="findAllBy">findAllBy</option>
</select>
<span id={styles.hastooltip} role="tooltip">
<img src={questionIcon} alt="help" />
<span id={styles.tooltip}>
<ToolTip toolTipType={blockObjectsState.queryVariant} />
</span>
</span>
<select
id="querySelector"
value={blockObjectsState.querySelector}
onChange={(e) =>
handleChange(
thisBlockObjectsState.filepath,
'querySelector',
e.target.value
)
}
>
<option value="" />
<option value="LabelText">LabelText</option>
<option value="PlaceholderText">PlaceholderText</option>
<option value="Text">Text</option>
<option value="AltText">AltText</option>
<option value="Title">Title</option>
<option value="DisplayValue">DisplayValue</option>
<option value="Role">Role</option>
<option value="TestId">TestId</option>
{/* TextMatch Precision & Normalization will be added */}
</select>
<span id={styles.hastooltip} role="tooltip">
<img src={questionIcon} alt="help" />
<span id={styles.tooltip}>
<ToolTip toolTipType={blockObjectsState.querySelector} />
</span>
</span>
<div id={styles.query}>
<span>
{/* <label htmlFor='queryValue' className={styles.queryLabel}>
Query
</label> */}
</span>
<span>
<input
type="text"
id="queryValue"
placeholder="text, queryOptions, waitForOptions"
value={blockObjectsState.queryValue}
onChange={(e) =>
handleChange(
thisBlockObjectsState.filepath,
'queryValue',
e.target.value
)
}
/>
</span>
</div>
</div>
</div>
</div>
</div>
);
});
export default Action;