systemview 1.0.1 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (263) hide show
  1. package/api/Connections.js +36 -0
  2. package/api/connections.txt +1 -0
  3. package/api/index.js +78 -0
  4. package/babel.config.js +12 -0
  5. package/cli/launchApp.js +0 -0
  6. package/cli/runTest.js +0 -0
  7. package/cli/utils/cli.js +48 -0
  8. package/cli/utils/init.js +17 -0
  9. package/cli/utils/log.js +11 -0
  10. package/package.json +6 -3
  11. package/plugin/SystemViewModule.js +97 -0
  12. package/plugin/getAllTest.js +21 -0
  13. package/plugin/index.js +40 -0
  14. package/src/App.css +38 -0
  15. package/src/App.js +30 -0
  16. package/src/ServiceContext.js +9 -0
  17. package/src/assets/arrow.png +0 -0
  18. package/src/assets/check.svg +1 -0
  19. package/src/assets/clear.png +0 -0
  20. package/src/assets/edit.png +0 -0
  21. package/src/assets/error.svg +1 -0
  22. package/src/assets/eval-icon.svg +10 -0
  23. package/src/assets/expand-arrow.svg +41 -0
  24. package/src/assets/expand-button.svg +41 -0
  25. package/src/assets/fonts/FontsFree-Net-SFMono-Regular.ttf +0 -0
  26. package/src/assets/fonts/Malkor-Regular.ttf +0 -0
  27. package/src/assets/iconfinder-icon (1).svg +14 -0
  28. package/src/assets/iconfinder-icon.svg +14 -0
  29. package/src/assets/icons-save-60.png +0 -0
  30. package/src/assets/loading.gif +0 -0
  31. package/src/assets/missing-doc.png +0 -0
  32. package/src/assets/saved-doc.png +0 -0
  33. package/src/assets/sysly.png +0 -0
  34. package/src/assets/test-icon.svg +10 -0
  35. package/src/assets/test-missing.png +0 -0
  36. package/src/assets/test-saved.png +0 -0
  37. package/src/assets/x.svg +1 -0
  38. package/src/atoms/Button/Button.js +20 -0
  39. package/src/atoms/Button/Button.test.js +27 -0
  40. package/src/atoms/Button/__snapshots__/Button.test.js.snap +9 -0
  41. package/src/atoms/Button/styles.scss +35 -0
  42. package/src/atoms/Count/index.js +10 -0
  43. package/src/atoms/Count/styles.scss +25 -0
  44. package/src/atoms/DataTable/DataTable.js +27 -0
  45. package/src/atoms/DataTable/DataTable.test.js +55 -0
  46. package/src/atoms/DataTable/__snapshots__/DataTable.test.js.snap +36 -0
  47. package/src/atoms/DataTable/styles.scss +28 -0
  48. package/src/atoms/DescriptionBox/DescriptionBox.js +24 -0
  49. package/src/atoms/DescriptionBox/DescriptionBox.test.js +36 -0
  50. package/src/atoms/DescriptionBox/__snapshots__/DescriptionBox.test.js.snap +14 -0
  51. package/src/atoms/DescriptionBox/styles.scss +24 -0
  52. package/src/atoms/DescriptionText/DescriptionText.js +12 -0
  53. package/src/atoms/DescriptionText/DescriptionText.test.js +22 -0
  54. package/src/atoms/DescriptionText/styles.scss +10 -0
  55. package/src/atoms/DocsIcon/DocsIcon.js +20 -0
  56. package/src/atoms/DocsIcon/DocsIcon.test.js +23 -0
  57. package/src/atoms/DocsIcon/styles.scss +7 -0
  58. package/src/atoms/ExpandableIcon/ExpandableIcon.js +30 -0
  59. package/src/atoms/ExpandableIcon/ExpandableIcon.test.js +18 -0
  60. package/src/atoms/ExpandableIcon/styles.scss +5 -0
  61. package/src/atoms/JsonTextBox/JsonTextBox.js +61 -0
  62. package/src/atoms/JsonTextBox/JsonTextBox.test.js +0 -0
  63. package/src/atoms/JsonTextBox/styles.scss +41 -0
  64. package/src/atoms/Link/Link.js +17 -0
  65. package/src/atoms/Link/Link.test.js +33 -0
  66. package/src/atoms/Link/styles.scss +8 -0
  67. package/src/atoms/List/List.js +8 -0
  68. package/src/atoms/List/List.test.js +26 -0
  69. package/src/atoms/List/styles.scss +9 -0
  70. package/src/atoms/Markdown/Markdown.js +48 -0
  71. package/src/atoms/Markdown/styles.scss +414 -0
  72. package/src/atoms/RunTestIcon/index.js +41 -0
  73. package/src/atoms/RunTestIcon/styles.scss +16 -0
  74. package/src/atoms/SaveIcon/SaveIcon.js +6 -0
  75. package/src/atoms/SaveIcon/styles.scss +3 -0
  76. package/src/atoms/Selector/Selector.js +28 -0
  77. package/src/atoms/Selector/Selector.test.js +0 -0
  78. package/src/atoms/Selector/styles.scss +1 -0
  79. package/src/atoms/StatusIndicator/StatusIndicator.js +16 -0
  80. package/src/atoms/StatusIndicator/styles.scss +33 -0
  81. package/src/atoms/TestsIcon/TestsIcon.js +17 -0
  82. package/src/atoms/TestsIcon/TestsIcon.test.js +18 -0
  83. package/src/atoms/TestsIcon/styles.scss +0 -0
  84. package/src/atoms/Text/Text.js +8 -0
  85. package/src/atoms/Text/Text.test.js +21 -0
  86. package/src/atoms/Text/styles.scss +0 -0
  87. package/src/atoms/Textbox/Textbox.js +33 -0
  88. package/src/atoms/Textbox/Textbox.test.js +23 -0
  89. package/src/atoms/Textbox/styles.scss +14 -0
  90. package/src/atoms/Title/Title.js +12 -0
  91. package/src/atoms/Title/Title.test.js +0 -0
  92. package/src/atoms/Title/styles.scss +6 -0
  93. package/src/atoms/Toggle/Toggle.js +13 -0
  94. package/src/atoms/Toggle/Toggle.test.js +0 -0
  95. package/src/atoms/Toggle/styles.scss +62 -0
  96. package/src/atoms/TypeSelector/TypeSelector.js +28 -0
  97. package/src/atoms/TypeSelector/TypeSelector.test.js +0 -0
  98. package/src/atoms/TypeSelector/styles.scss +9 -0
  99. package/src/index.css +20 -0
  100. package/src/index.js +24 -0
  101. package/src/logo.svg +7 -0
  102. package/src/molecules/Args/Args.js +302 -0
  103. package/src/molecules/Args/Args.test.js +0 -0
  104. package/src/molecules/Args/styles.scss +166 -0
  105. package/src/molecules/AutoCompleteBox/AutoCompleteBox.js +101 -0
  106. package/src/molecules/AutoCompleteBox/AutoCompleteBox.test.js +0 -0
  107. package/src/molecules/AutoCompleteBox/styles.scss +35 -0
  108. package/src/molecules/DataTableForm/DataTableForm.js +167 -0
  109. package/src/molecules/DataTableForm/DataTableForm.test.js +0 -0
  110. package/src/molecules/DataTableForm/styles.scss +51 -0
  111. package/src/molecules/EditBox/EditBox.js +49 -0
  112. package/src/molecules/EditBox/EditBox.test.js +0 -0
  113. package/src/molecules/EditBox/styles.scss +38 -0
  114. package/src/molecules/ExpandableList/ExpandableList.js +26 -0
  115. package/src/molecules/ExpandableList/ExpandableList.test.js +33 -0
  116. package/src/molecules/ExpandableList/styles.scss +18 -0
  117. package/src/molecules/ExpandableSection/ExpandableSection.js +36 -0
  118. package/src/molecules/ExpandableSection/ExpandableSection.test.js +0 -0
  119. package/src/molecules/ExpandableSection/styles.scss +22 -0
  120. package/src/molecules/ServerModulesList/ServerModulesList.js +75 -0
  121. package/src/molecules/ServerModulesList/styles.scss +28 -0
  122. package/src/molecules/TargetSelector/TargetSelector.js +34 -0
  123. package/src/molecules/TargetSelector/TargetSelector.test.js +0 -0
  124. package/src/molecules/TargetSelector/styles.scss +0 -0
  125. package/src/molecules/TestCaption/TestCaption.js +26 -0
  126. package/src/molecules/TestCaption/TestCaption.test.js +0 -0
  127. package/src/molecules/TestCaption/styles.scss +40 -0
  128. package/src/molecules/TestSummary/index.js +212 -0
  129. package/src/molecules/TestSummary/styles.scss +83 -0
  130. package/src/molecules/TextWith2Links/TextWith2Links.js +10 -0
  131. package/src/molecules/TextWith2Links/styles.scss +0 -0
  132. package/src/molecules/ValidationInput/ValidationInput.js +64 -0
  133. package/src/molecules/ValidationInput/ValidationInput.test.js +0 -0
  134. package/src/molecules/ValidationInput/ValidationMessages.js +178 -0
  135. package/src/molecules/ValidationInput/ValidationOptions.js +113 -0
  136. package/src/molecules/ValidationInput/styles.scss +74 -0
  137. package/src/molecules/ValidationInput/validator.js +244 -0
  138. package/src/organisms/Documentation/Documentation.js +128 -0
  139. package/src/organisms/Documentation/Documentation.test.js +0 -0
  140. package/src/organisms/Documentation/styles.scss +22 -0
  141. package/src/organisms/MultiTestSection/MultiTestSection.js +85 -0
  142. package/src/organisms/MultiTestSection/MultiTestSection.test.js +0 -0
  143. package/src/organisms/MultiTestSection/styles.scss +22 -0
  144. package/src/organisms/SavedTests/SavedTests.js +209 -0
  145. package/src/organisms/SavedTests/SavedTests.test.js +0 -0
  146. package/src/organisms/SavedTests/styles.scss +76 -0
  147. package/src/organisms/SavedTests/transformTests.js +51 -0
  148. package/src/organisms/ScratchPad/ScratchPad.js +128 -0
  149. package/src/organisms/ScratchPad/ScratchPad.test.js +0 -0
  150. package/src/organisms/ScratchPad/styles.scss +100 -0
  151. package/src/organisms/SystemNavigator/SystemNavigator.js +148 -0
  152. package/src/organisms/SystemNavigator/SystemNavigator.test.js +24 -0
  153. package/src/organisms/SystemNavigator/styles.scss +38 -0
  154. package/src/organisms/TestContainer/TestContainer.js +72 -0
  155. package/src/organisms/TestContainer/TestContainer.test.js +0 -0
  156. package/src/organisms/TestContainer/styles.scss +20 -0
  157. package/src/organisms/TestPanel/AfterTest/AfterTest.js +16 -0
  158. package/src/organisms/TestPanel/AfterTest/AfterTest.test.js +0 -0
  159. package/src/organisms/TestPanel/AfterTest/styles.scss +0 -0
  160. package/src/organisms/TestPanel/BeforeTest/BeforeTest.js +16 -0
  161. package/src/organisms/TestPanel/BeforeTest/BeforeTest.test.js +0 -0
  162. package/src/organisms/TestPanel/BeforeTest/styles.scss +0 -0
  163. package/src/organisms/TestPanel/Evaluations.js +369 -0
  164. package/src/organisms/TestPanel/EventsTest/EventsTest.js +19 -0
  165. package/src/organisms/TestPanel/EventsTest/styles.scss +0 -0
  166. package/src/organisms/TestPanel/MainTest/MainTest.js +20 -0
  167. package/src/organisms/TestPanel/MainTest/MainTest.test.js +0 -0
  168. package/src/organisms/TestPanel/MainTest/styles.scss +143 -0
  169. package/src/organisms/TestPanel/TestPanel.js +170 -0
  170. package/src/organisms/TestPanel/TestPanel.test.js +0 -0
  171. package/src/organisms/TestPanel/components/Argument.class.js +94 -0
  172. package/src/organisms/TestPanel/components/FullTestController.js +78 -0
  173. package/src/organisms/TestPanel/components/Test.class.js +162 -0
  174. package/src/organisms/TestPanel/components/TestController.class.js +135 -0
  175. package/src/organisms/TestPanel/components/test-helpers.js +109 -0
  176. package/src/organisms/TestPanel/styles.scss +45 -0
  177. package/src/pages/SystemView/SystemView.js +68 -0
  178. package/src/pages/SystemView/styles.scss +81 -0
  179. package/src/reportWebVitals.js +13 -0
  180. package/src/sass/bootstrap/_alert.scss +51 -0
  181. package/src/sass/bootstrap/_badge.scss +47 -0
  182. package/src/sass/bootstrap/_breadcrumb.scss +38 -0
  183. package/src/sass/bootstrap/_button-group.scss +166 -0
  184. package/src/sass/bootstrap/_buttons.scss +143 -0
  185. package/src/sass/bootstrap/_card.scss +270 -0
  186. package/src/sass/bootstrap/_carousel.scss +191 -0
  187. package/src/sass/bootstrap/_close.scss +34 -0
  188. package/src/sass/bootstrap/_code.scss +56 -0
  189. package/src/sass/bootstrap/_custom-forms.scss +297 -0
  190. package/src/sass/bootstrap/_dropdown.scss +131 -0
  191. package/src/sass/bootstrap/_forms.scss +333 -0
  192. package/src/sass/bootstrap/_functions.scss +86 -0
  193. package/src/sass/bootstrap/_grid.scss +52 -0
  194. package/src/sass/bootstrap/_images.scss +42 -0
  195. package/src/sass/bootstrap/_input-group.scss +159 -0
  196. package/src/sass/bootstrap/_jumbotron.scss +16 -0
  197. package/src/sass/bootstrap/_list-group.scss +115 -0
  198. package/src/sass/bootstrap/_media.scss +8 -0
  199. package/src/sass/bootstrap/_mixins.scss +42 -0
  200. package/src/sass/bootstrap/_modal.scss +168 -0
  201. package/src/sass/bootstrap/_nav.scss +118 -0
  202. package/src/sass/bootstrap/_navbar.scss +311 -0
  203. package/src/sass/bootstrap/_pagination.scss +77 -0
  204. package/src/sass/bootstrap/_popover.scss +183 -0
  205. package/src/sass/bootstrap/_print.scss +124 -0
  206. package/src/sass/bootstrap/_progress.scss +33 -0
  207. package/src/sass/bootstrap/_reboot.scss +482 -0
  208. package/src/sass/bootstrap/_root.scss +19 -0
  209. package/src/sass/bootstrap/_tables.scss +180 -0
  210. package/src/sass/bootstrap/_tooltip.scss +115 -0
  211. package/src/sass/bootstrap/_transitions.scss +36 -0
  212. package/src/sass/bootstrap/_type.scss +125 -0
  213. package/src/sass/bootstrap/_utilities.scss +14 -0
  214. package/src/sass/bootstrap/_variables.scss +894 -0
  215. package/src/sass/bootstrap/bootstrap-grid.scss +32 -0
  216. package/src/sass/bootstrap/bootstrap-reboot.scss +12 -0
  217. package/src/sass/bootstrap/bootstrap.scss +42 -0
  218. package/src/sass/bootstrap/mixins/_alert.scss +13 -0
  219. package/src/sass/bootstrap/mixins/_background-variant.scss +21 -0
  220. package/src/sass/bootstrap/mixins/_badge.scss +12 -0
  221. package/src/sass/bootstrap/mixins/_border-radius.scss +35 -0
  222. package/src/sass/bootstrap/mixins/_box-shadow.scss +5 -0
  223. package/src/sass/bootstrap/mixins/_breakpoints.scss +123 -0
  224. package/src/sass/bootstrap/mixins/_buttons.scss +109 -0
  225. package/src/sass/bootstrap/mixins/_caret.scss +65 -0
  226. package/src/sass/bootstrap/mixins/_clearfix.scss +7 -0
  227. package/src/sass/bootstrap/mixins/_float.scss +11 -0
  228. package/src/sass/bootstrap/mixins/_forms.scss +137 -0
  229. package/src/sass/bootstrap/mixins/_gradients.scss +45 -0
  230. package/src/sass/bootstrap/mixins/_grid-framework.scss +67 -0
  231. package/src/sass/bootstrap/mixins/_grid.scss +52 -0
  232. package/src/sass/bootstrap/mixins/_hover.scss +39 -0
  233. package/src/sass/bootstrap/mixins/_image.scss +36 -0
  234. package/src/sass/bootstrap/mixins/_list-group.scss +21 -0
  235. package/src/sass/bootstrap/mixins/_lists.scss +7 -0
  236. package/src/sass/bootstrap/mixins/_nav-divider.scss +10 -0
  237. package/src/sass/bootstrap/mixins/_navbar-align.scss +10 -0
  238. package/src/sass/bootstrap/mixins/_pagination.scss +22 -0
  239. package/src/sass/bootstrap/mixins/_reset-text.scss +17 -0
  240. package/src/sass/bootstrap/mixins/_resize.scss +6 -0
  241. package/src/sass/bootstrap/mixins/_screen-reader.scss +35 -0
  242. package/src/sass/bootstrap/mixins/_size.scss +6 -0
  243. package/src/sass/bootstrap/mixins/_table-row.scss +30 -0
  244. package/src/sass/bootstrap/mixins/_text-emphasis.scss +14 -0
  245. package/src/sass/bootstrap/mixins/_text-hide.scss +9 -0
  246. package/src/sass/bootstrap/mixins/_text-truncate.scss +8 -0
  247. package/src/sass/bootstrap/mixins/_transition.scss +9 -0
  248. package/src/sass/bootstrap/mixins/_visibility.scss +7 -0
  249. package/src/sass/bootstrap/utilities/_align.scss +8 -0
  250. package/src/sass/bootstrap/utilities/_background.scss +19 -0
  251. package/src/sass/bootstrap/utilities/_borders.scss +59 -0
  252. package/src/sass/bootstrap/utilities/_clearfix.scss +3 -0
  253. package/src/sass/bootstrap/utilities/_display.scss +38 -0
  254. package/src/sass/bootstrap/utilities/_embed.scss +52 -0
  255. package/src/sass/bootstrap/utilities/_flex.scss +46 -0
  256. package/src/sass/bootstrap/utilities/_float.scss +9 -0
  257. package/src/sass/bootstrap/utilities/_position.scss +36 -0
  258. package/src/sass/bootstrap/utilities/_screenreaders.scss +11 -0
  259. package/src/sass/bootstrap/utilities/_sizing.scss +12 -0
  260. package/src/sass/bootstrap/utilities/_spacing.scss +51 -0
  261. package/src/sass/bootstrap/utilities/_text.scss +52 -0
  262. package/src/sass/bootstrap/utilities/_visibility.scss +11 -0
  263. package/src/setupTests.js +5 -0
@@ -0,0 +1,369 @@
1
+ import React, { useState, useEffect } from "react";
2
+ import ExpandableSection from "../../molecules/ExpandableSection/ExpandableSection";
3
+ import ValidationInput from "../../molecules/ValidationInput/ValidationInput";
4
+ import ValidationOptions, {
5
+ inputToTypes,
6
+ } from "../../molecules/ValidationInput/ValidationOptions";
7
+ import TypeSelector from "../../atoms/TypeSelector/TypeSelector";
8
+ import { getErrors, defaultValue } from "../../molecules/ValidationInput/validator";
9
+ import Count from "../../atoms/Count";
10
+ import { endsWithArrayIndex } from "./components/test-helpers";
11
+
12
+ const validationCount = (evaluations) =>
13
+ evaluations.reduce((sum, e) => (e.save ? e.validations.length + 1 : 0) + sum, 0);
14
+ export default function Evaluations({ test, updateTests }) {
15
+ const { evaluations, errors } = test;
16
+ const [open, setOpen] = useState(false);
17
+ const [saveAll, setSaveAll] = useState(!test.savedEvaluations.length);
18
+ const [totalValidations, setTotalValidations] = useState(
19
+ validationCount(test.evaluations)
20
+ );
21
+ const toggleExpansion = () => {
22
+ setOpen((state) => !state);
23
+ };
24
+
25
+ const updateEvaluation = (evaluation) => {
26
+ evaluation.errors = getErrors(evaluation);
27
+ test.addEvaluation(evaluation);
28
+ test.errors = test.getErrors();
29
+ updateTests();
30
+ };
31
+
32
+ const addValidation = (x) => {
33
+ const { expected_type } = evaluations[x];
34
+ const input_type = ValidationOptions[expected_type].inputs[0];
35
+ evaluations[x].validations.push({
36
+ name: ValidationOptions[expected_type].values[0],
37
+ value: defaultValue(inputToTypes[input_type]),
38
+ });
39
+ updateEvaluation(evaluations[x]);
40
+ setTotalValidations(validationCount(evaluations));
41
+ };
42
+
43
+ const deleteValidation = (x, y) => {
44
+ evaluations[x].validations.splice(y, 1);
45
+ updateEvaluation(evaluations[x]);
46
+ setTotalValidations(validationCount(evaluations));
47
+ };
48
+
49
+ const updateValidations = (x, y, p, v) => {
50
+ evaluations[x].validations[y][p] = v;
51
+ updateEvaluation(evaluations[x]);
52
+ };
53
+
54
+ const updateExpectedType = (x, e) => {
55
+ evaluations[x].expected_type = e.target.value;
56
+ evaluations[x].validations = [];
57
+ updateEvaluation(evaluations[x]);
58
+ };
59
+
60
+ const updateSaveStatus = (x, save) => {
61
+ evaluations[x].save = save;
62
+ updateEvaluation(evaluations[x]);
63
+ setTotalValidations(validationCount(evaluations));
64
+ };
65
+
66
+ const toggleAllSaveStatuses = () => {
67
+ setSaveAll(!saveAll);
68
+ test.evaluations = test.evaluations.map((e) => ({ ...e, save: !saveAll }));
69
+ test.errors = test.getErrors();
70
+ updateTests();
71
+ setTotalValidations(validationCount(evaluations));
72
+ };
73
+
74
+ useEffect(() => {
75
+ if (test.test_end !== null) {
76
+ updateTests(test.evaluations);
77
+ } else {
78
+ updateTests([]);
79
+ }
80
+ if (test.test_end !== null) setTotalValidations(validationCount(test.evaluations));
81
+ }, [test.evaluations, test.test_end]);
82
+
83
+ return (
84
+ <div className={`evaluations evaluations--visible-${evaluations.length > 0}`}>
85
+ <ExpandableSection
86
+ open={open}
87
+ toggleExpansion={toggleExpansion}
88
+ title={
89
+ <>
90
+ <div className={`evaluations__title evaluations--error-${errors.length > 0}`}>
91
+ <span className="evaluations__namespace">
92
+ {errors.length > 0 ? "Test Failed: " : "Test Passed: "}
93
+ </span>
94
+ <span
95
+ className={`evaluations__type evaluations--error-${errors.length > 0}`}
96
+ >
97
+ <Count count={errors.length} type={errors.length && "error"} /> errors
98
+ </span>
99
+ <Count count={totalValidations} />{" "}
100
+ <span className="evaluations__total">Total</span>
101
+ </div>
102
+ <input
103
+ className="evaluations__checkbox"
104
+ type="checkbox"
105
+ checked={saveAll}
106
+ onChange={toggleAllSaveStatuses}
107
+ />
108
+ </>
109
+ }
110
+ >
111
+ {evaluations.map(
112
+ (
113
+ { namespace, type, expected_type, save, errors, validations, indexed, value },
114
+ i
115
+ ) => {
116
+ return (
117
+ <EvaluationRow
118
+ key={i}
119
+ namespace={namespace}
120
+ type={type}
121
+ expected_type={expected_type}
122
+ errors={errors}
123
+ validations={validations}
124
+ index={i}
125
+ addValidation={addValidation}
126
+ deleteValidation={deleteValidation}
127
+ updateValidations={updateValidations}
128
+ updateExpectedType={updateExpectedType}
129
+ updateSaveStatus={updateSaveStatus}
130
+ updateTests={updateTests}
131
+ save={save}
132
+ test={test}
133
+ indexed={indexed}
134
+ value={value}
135
+ />
136
+ );
137
+ }
138
+ )}
139
+ </ExpandableSection>
140
+ </div>
141
+ );
142
+ }
143
+
144
+ const EvaluationRow = ({
145
+ namespace,
146
+ type,
147
+ expected_type,
148
+ errors,
149
+ validations,
150
+ index,
151
+ addValidation,
152
+ deleteValidation,
153
+ updateValidations,
154
+ updateExpectedType,
155
+ updateSaveStatus,
156
+ updateTests,
157
+ save,
158
+ test,
159
+ indexed,
160
+ value,
161
+ }) => {
162
+ const calcWidth = (text = "") => Math.ceil(text.length / 0.12);
163
+ const [type_width, setWidth] = useState(calcWidth(0));
164
+ const style = { "--type-width": type_width + "px" };
165
+ const [open, setOpen] = useState(errors.length && validations.length);
166
+
167
+ const typeError = !!errors.find(({ name }) => name === "typeError");
168
+ const toggleExpansion = () => {
169
+ setOpen((state) => !state);
170
+ };
171
+ const onSelect = (i, e) => {
172
+ updateExpectedType(i, e);
173
+ setWidth(calcWidth(e.target.value));
174
+ };
175
+ const toggleSave = () => updateSaveStatus(index, !save);
176
+ useEffect(
177
+ () => setWidth(calcWidth(expected_type)),
178
+
179
+ [expected_type, type_width]
180
+ );
181
+
182
+ useEffect(() => {
183
+ if (errors.length && validations.length) setOpen(true);
184
+ }, [errors]);
185
+ return (
186
+ <ExpandableSection
187
+ open={open}
188
+ toggleExpansion={toggleExpansion}
189
+ title={
190
+ <>
191
+ <div className={`evaluations__title`} style={style}>
192
+ {endsWithArrayIndex(namespace) ? (
193
+ <ArrayNamespace
194
+ updateTests={updateTests}
195
+ namespace={namespace}
196
+ test={test}
197
+ indexed={indexed}
198
+ value={value}
199
+ />
200
+ ) : (
201
+ <span
202
+ className={`evaluations__namespace evaluations--error-${
203
+ errors.length > 0
204
+ }`}
205
+ >
206
+ {namespace}:{" "}
207
+ </span>
208
+ )}
209
+ <TypeSelector
210
+ default_type={expected_type}
211
+ onSelect={onSelect.bind(this, index)}
212
+ />
213
+ <span
214
+ className={`evaluations__type-error-msg
215
+ evaluations__type-error-msg--${typeError}
216
+ evaluations--error-${typeError}`}
217
+ >
218
+ (received {type})
219
+ </span>
220
+ {!!validations.length && <Count count={validations.length} />}
221
+ </div>
222
+ <input
223
+ className="evaluations__checkbox"
224
+ type="checkbox"
225
+ checked={save}
226
+ onChange={toggleSave}
227
+ />
228
+ </>
229
+ }
230
+ >
231
+ <div className="evaluations__row">
232
+ <span
233
+ className={`evaluations__input evaluations__input--visible-${
234
+ expected_type !== "object" &&
235
+ expected_type !== "null" &&
236
+ expected_type !== "undefined"
237
+ }`}
238
+ >
239
+ <div className="evaluations__add-btn-container">
240
+ <span
241
+ className="evaluations__add-validation-btn btn"
242
+ onClick={addValidation.bind(this, index)}
243
+ >
244
+ +
245
+ </span>
246
+ </div>
247
+ <div className="evaluations__validation-container">
248
+ {validations.map(({ name, value }, i) => {
249
+ const isError = !!errors.find(({ name: errName }) => errName === name);
250
+ return (
251
+ <div className="evaluations__validation" key={i}>
252
+ <ValidationInput
253
+ className={`evaluations--error-${isError} evaluations__validation__input`}
254
+ type={expected_type}
255
+ name={name}
256
+ value={value}
257
+ onSelect={updateValidations.bind(this, index, i, "name")}
258
+ onInputChanged={updateValidations.bind(this, index, i, "value")}
259
+ />
260
+ <span
261
+ className="evaluations__validation__delete-btn btn"
262
+ onClick={deleteValidation.bind(this, index, i)}
263
+ >
264
+ x
265
+ </span>
266
+ </div>
267
+ );
268
+ })}
269
+ </div>
270
+ </span>
271
+ </div>
272
+ </ExpandableSection>
273
+ );
274
+ };
275
+
276
+ function ArrayNamespace({ namespace, errorCount, updateTests, test, indexed, value }) {
277
+ const [name = "", index = ""] = namespace.split(/(\[\d+\])$/);
278
+ const [open, setOpen] = useState(false);
279
+ const [isIndexed, setIsIndexed] = useState(!!indexed);
280
+ const [testIndex, setIndex] = useState(parseInt(index.substr(1, index.length - 1)));
281
+
282
+ const inputChange = (e) => setIndex(parseInt(e.target.value));
283
+ const add = () => {
284
+ // push ensures that the evaluation namespace is add and not overwritten
285
+ test.savedEvaluations.push({
286
+ namespace: `${name}[${testIndex + 1}]`,
287
+ save: true,
288
+ indexed: true,
289
+ });
290
+
291
+ if (!indexed)
292
+ //add the current index because the test will only use the one
293
+ //saved index, but we need the current index to stay as well
294
+ test.addSavedIndices(namespace, `${name}[${testIndex}]`);
295
+
296
+ test.validate();
297
+ updateTests();
298
+ setOpen(false);
299
+ };
300
+ const show = () => setOpen(true);
301
+
302
+ const hide = () => {
303
+ test.removeSavedIndices(namespace);
304
+ if (isIndexed) {
305
+ test.addSavedIndices(namespace, `${name}[${testIndex}]`);
306
+ } else {
307
+ const e = test.evaluations.find((e) => e.namespace === namespace);
308
+ if (e) {
309
+ e.indexed = false;
310
+ e.expected_type = undefined;
311
+ test.addEvaluation(e);
312
+ }
313
+ }
314
+ test.validate();
315
+ updateTests();
316
+ setOpen(false);
317
+ };
318
+ const handleCheck = (e) => setIsIndexed(e.target.checked);
319
+
320
+ useEffect(() => setIsIndexed(!!indexed), [indexed]);
321
+ useEffect(() => {
322
+ const [name = "", index = ""] = namespace.split(/(\[\d+\])$/);
323
+ setIndex(parseInt(index.substr(1, index.length - 1)));
324
+ }, [namespace]);
325
+
326
+ return (
327
+ <span className={`evaluations__namespace evaluations--error-${errorCount > 0}`}>
328
+ <span>{name}</span>
329
+ {!open ? (
330
+ <span
331
+ onClick={show}
332
+ className={`evaluations__index-button btn evaluations__index-button--indexed-${isIndexed}`}
333
+ >
334
+ {index}
335
+ </span>
336
+ ) : (
337
+ <span className={`evaluations__index-button`}>
338
+ <span className="evaluations__brackets">{"["}</span>
339
+ {isIndexed ? (
340
+ <input
341
+ className="evaluations__index-input"
342
+ type={"number"}
343
+ onChange={inputChange}
344
+ min={0}
345
+ //max={value.length}
346
+ value={testIndex}
347
+ />
348
+ ) : (
349
+ <span className="evaluations__random">random</span>
350
+ )}
351
+ <input
352
+ className="evaluations__index-checkbox"
353
+ checked={isIndexed}
354
+ onChange={handleCheck}
355
+ type={"checkbox"}
356
+ />
357
+ <span onClick={add} className="evaluations__add-index-btn btn">
358
+ +
359
+ </span>
360
+ <span className="evaluations__brackets">{"]"}</span>
361
+ <span onClick={hide} className="evaluations__clear-error btn">
362
+ ×
363
+ </span>
364
+ </span>
365
+ )}
366
+ :{" "}
367
+ </span>
368
+ );
369
+ }
@@ -0,0 +1,19 @@
1
+ import React from "react";
2
+ import MultiTestSection from "../../MultiTestSection/MultiTestSection";
3
+ import "./styles.scss";
4
+
5
+ const EventsTest = ({ TestSection, TestController, namespace, FullTest, connection }) => {
6
+ return (
7
+ <MultiTestSection
8
+ dynamic={false}
9
+ TestSection={TestSection}
10
+ TestController={TestController}
11
+ namespace={namespace}
12
+ arg={{ name: "event_name", input_type: "string", FullTest }}
13
+ caption="Events"
14
+ staticArguments={true}
15
+ />
16
+ );
17
+ };
18
+
19
+ export default EventsTest;
File without changes
@@ -0,0 +1,20 @@
1
+ import React from "react";
2
+ import TestContainer from "../../TestContainer/TestContainer";
3
+
4
+ import "./styles.scss";
5
+
6
+ const MainTest = ({ TestController, TestSection }) => {
7
+ return (
8
+ <section className="current-data-section">
9
+ <TestContainer
10
+ title="Main:"
11
+ open={true}
12
+ test={TestSection[0]}
13
+ testIndex={0}
14
+ TestController={TestController}
15
+ />
16
+ </section>
17
+ );
18
+ };
19
+
20
+ export default MainTest;
@@ -0,0 +1,143 @@
1
+ .evaluations {
2
+ background: #25d0a8;
3
+ background: #76b1f7;
4
+ background: #ced8f4;
5
+
6
+ border-radius: 0px 0px 4px 4px;
7
+ overflow-wrap: anywhere;
8
+ padding: 12px 18px;
9
+ font-family: monospace;
10
+ &--visible-false {
11
+ display: none;
12
+ }
13
+ &__row {
14
+ margin: 4px;
15
+ padding: 8px 5px;
16
+ }
17
+
18
+ &__title {
19
+ --type-width: auto;
20
+ margin-left: 10px;
21
+ width: 100%;
22
+ & select {
23
+ width: var(--type-width);
24
+ }
25
+ }
26
+
27
+ &__input {
28
+ & > input {
29
+ width: 100%;
30
+ padding: 6px 9px;
31
+ margin: 8px 0;
32
+ box-sizing: border-box;
33
+ border: none;
34
+ border: 1px solid #383836;
35
+ background: #a5ffda;
36
+ }
37
+ &--visible-false {
38
+ display: none;
39
+ }
40
+ }
41
+ &__add-validation-btn {
42
+ background: #5a77ca;
43
+ padding: 0px 5px 1px 5px;
44
+ border-radius: 16px;
45
+ font-weight: bold;
46
+ color: #ffffff;
47
+ }
48
+ &__validation-container {
49
+ display: inline-grid;
50
+ margin-left: 4px;
51
+ }
52
+ &__add-btn-container {
53
+ display: inline-grid;
54
+ }
55
+ &__validation {
56
+ border-bottom: 1px solid #9797d1;
57
+ &__delete-btn {
58
+ display: inline;
59
+ font-family: system-ui;
60
+ margin-left: 6px;
61
+ font-size: 15px;
62
+ color: #6565a1;
63
+ &:hover {
64
+ color: #c30f0f;
65
+ }
66
+ }
67
+ &__input {
68
+ display: inline-flex;
69
+ }
70
+ }
71
+ &__type-error-msg {
72
+ display: none;
73
+ &--true {
74
+ display: initial;
75
+ }
76
+ }
77
+ &--error-true,
78
+ &--error-true > * {
79
+ color: #cd4343;
80
+ //color: #993939;
81
+ font-weight: bold;
82
+ //font-style: italic;
83
+ }
84
+ &__total {
85
+ color: grey;
86
+ }
87
+ &__checkbox {
88
+ cursor: pointer;
89
+ }
90
+ &__index-button {
91
+ display: flex;
92
+ flex-direction: row;
93
+ align-items: center;
94
+ &.btn:hover {
95
+ font-weight: bold;
96
+ color: #2326fe;
97
+ color: #ff5722;
98
+ color: #c717e5;
99
+ color: #1131df;
100
+ }
101
+ &--indexed-true {
102
+ font-weight: bold;
103
+ }
104
+ }
105
+ &__namespace {
106
+ display: inline-flex;
107
+ flex-wrap: wrap;
108
+ }
109
+
110
+ &__index-input {
111
+ width: 45px;
112
+ height: 15px;
113
+ }
114
+
115
+ &__brackets {
116
+ align-self: baseline;
117
+ font-size: 14px;
118
+ color: black;
119
+ font-weight: bold;
120
+ }
121
+
122
+ &__index-checkbox {
123
+ cursor: pointer;
124
+ }
125
+ &__random {
126
+ align-self: baseline;
127
+ font-weight: bold;
128
+ color: #2b9b2c;
129
+ font-style: italic;
130
+ }
131
+ &__clear-error {
132
+ color: gray;
133
+ font-size: 16px;
134
+ &:hover {
135
+ color: black;
136
+ }
137
+ }
138
+ &__add-index-btn {
139
+ color: #2776ff;
140
+ font-weight: bold;
141
+ font-size: 16px;
142
+ }
143
+ }