systemview 1.1.2 → 1.2.2

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 (254) hide show
  1. package/api/connections.txt +1 -1
  2. package/package.json +3 -3
  3. package/server.js +19 -0
  4. package/babel.config.js +0 -12
  5. package/src/App.css +0 -38
  6. package/src/App.js +0 -30
  7. package/src/ServiceContext.js +0 -9
  8. package/src/assets/arrow.png +0 -0
  9. package/src/assets/check.svg +0 -1
  10. package/src/assets/clear.png +0 -0
  11. package/src/assets/edit.png +0 -0
  12. package/src/assets/error.svg +0 -1
  13. package/src/assets/eval-icon.svg +0 -10
  14. package/src/assets/expand-arrow.svg +0 -41
  15. package/src/assets/expand-button.svg +0 -41
  16. package/src/assets/fonts/FontsFree-Net-SFMono-Regular.ttf +0 -0
  17. package/src/assets/fonts/Malkor-Regular.ttf +0 -0
  18. package/src/assets/iconfinder-icon (1).svg +0 -14
  19. package/src/assets/iconfinder-icon.svg +0 -14
  20. package/src/assets/icons-save-60.png +0 -0
  21. package/src/assets/loading.gif +0 -0
  22. package/src/assets/missing-doc.png +0 -0
  23. package/src/assets/saved-doc.png +0 -0
  24. package/src/assets/sysly.png +0 -0
  25. package/src/assets/test-icon.svg +0 -10
  26. package/src/assets/test-missing.png +0 -0
  27. package/src/assets/test-saved.png +0 -0
  28. package/src/assets/x.svg +0 -1
  29. package/src/atoms/Button/Button.js +0 -20
  30. package/src/atoms/Button/Button.test.js +0 -27
  31. package/src/atoms/Button/__snapshots__/Button.test.js.snap +0 -9
  32. package/src/atoms/Button/styles.scss +0 -35
  33. package/src/atoms/Count/index.js +0 -10
  34. package/src/atoms/Count/styles.scss +0 -25
  35. package/src/atoms/DataTable/DataTable.js +0 -27
  36. package/src/atoms/DataTable/DataTable.test.js +0 -55
  37. package/src/atoms/DataTable/__snapshots__/DataTable.test.js.snap +0 -36
  38. package/src/atoms/DataTable/styles.scss +0 -28
  39. package/src/atoms/DescriptionBox/DescriptionBox.js +0 -24
  40. package/src/atoms/DescriptionBox/DescriptionBox.test.js +0 -36
  41. package/src/atoms/DescriptionBox/__snapshots__/DescriptionBox.test.js.snap +0 -14
  42. package/src/atoms/DescriptionBox/styles.scss +0 -24
  43. package/src/atoms/DescriptionText/DescriptionText.js +0 -12
  44. package/src/atoms/DescriptionText/DescriptionText.test.js +0 -22
  45. package/src/atoms/DescriptionText/styles.scss +0 -10
  46. package/src/atoms/DocsIcon/DocsIcon.js +0 -20
  47. package/src/atoms/DocsIcon/DocsIcon.test.js +0 -23
  48. package/src/atoms/DocsIcon/styles.scss +0 -7
  49. package/src/atoms/ExpandableIcon/ExpandableIcon.js +0 -30
  50. package/src/atoms/ExpandableIcon/ExpandableIcon.test.js +0 -18
  51. package/src/atoms/ExpandableIcon/styles.scss +0 -5
  52. package/src/atoms/JsonTextBox/JsonTextBox.js +0 -61
  53. package/src/atoms/JsonTextBox/JsonTextBox.test.js +0 -0
  54. package/src/atoms/JsonTextBox/styles.scss +0 -41
  55. package/src/atoms/Link/Link.js +0 -17
  56. package/src/atoms/Link/Link.test.js +0 -33
  57. package/src/atoms/Link/styles.scss +0 -8
  58. package/src/atoms/List/List.js +0 -8
  59. package/src/atoms/List/List.test.js +0 -26
  60. package/src/atoms/List/styles.scss +0 -9
  61. package/src/atoms/Markdown/Markdown.js +0 -48
  62. package/src/atoms/Markdown/styles.scss +0 -414
  63. package/src/atoms/RunTestIcon/index.js +0 -41
  64. package/src/atoms/RunTestIcon/styles.scss +0 -16
  65. package/src/atoms/SaveIcon/SaveIcon.js +0 -6
  66. package/src/atoms/SaveIcon/styles.scss +0 -3
  67. package/src/atoms/Selector/Selector.js +0 -28
  68. package/src/atoms/Selector/Selector.test.js +0 -0
  69. package/src/atoms/Selector/styles.scss +0 -1
  70. package/src/atoms/StatusIndicator/StatusIndicator.js +0 -16
  71. package/src/atoms/StatusIndicator/styles.scss +0 -33
  72. package/src/atoms/TestsIcon/TestsIcon.js +0 -17
  73. package/src/atoms/TestsIcon/TestsIcon.test.js +0 -18
  74. package/src/atoms/TestsIcon/styles.scss +0 -0
  75. package/src/atoms/Text/Text.js +0 -8
  76. package/src/atoms/Text/Text.test.js +0 -21
  77. package/src/atoms/Text/styles.scss +0 -0
  78. package/src/atoms/Textbox/Textbox.js +0 -33
  79. package/src/atoms/Textbox/Textbox.test.js +0 -23
  80. package/src/atoms/Textbox/styles.scss +0 -14
  81. package/src/atoms/Title/Title.js +0 -12
  82. package/src/atoms/Title/Title.test.js +0 -0
  83. package/src/atoms/Title/styles.scss +0 -6
  84. package/src/atoms/Toggle/Toggle.js +0 -13
  85. package/src/atoms/Toggle/Toggle.test.js +0 -0
  86. package/src/atoms/Toggle/styles.scss +0 -62
  87. package/src/atoms/TypeSelector/TypeSelector.js +0 -28
  88. package/src/atoms/TypeSelector/TypeSelector.test.js +0 -0
  89. package/src/atoms/TypeSelector/styles.scss +0 -9
  90. package/src/index.css +0 -20
  91. package/src/index.js +0 -24
  92. package/src/logo.svg +0 -7
  93. package/src/molecules/Args/Args.js +0 -302
  94. package/src/molecules/Args/Args.test.js +0 -0
  95. package/src/molecules/Args/styles.scss +0 -166
  96. package/src/molecules/AutoCompleteBox/AutoCompleteBox.js +0 -101
  97. package/src/molecules/AutoCompleteBox/AutoCompleteBox.test.js +0 -0
  98. package/src/molecules/AutoCompleteBox/styles.scss +0 -35
  99. package/src/molecules/DataTableForm/DataTableForm.js +0 -167
  100. package/src/molecules/DataTableForm/DataTableForm.test.js +0 -0
  101. package/src/molecules/DataTableForm/styles.scss +0 -51
  102. package/src/molecules/EditBox/EditBox.js +0 -49
  103. package/src/molecules/EditBox/EditBox.test.js +0 -0
  104. package/src/molecules/EditBox/styles.scss +0 -38
  105. package/src/molecules/ExpandableList/ExpandableList.js +0 -26
  106. package/src/molecules/ExpandableList/ExpandableList.test.js +0 -33
  107. package/src/molecules/ExpandableList/styles.scss +0 -18
  108. package/src/molecules/ExpandableSection/ExpandableSection.js +0 -36
  109. package/src/molecules/ExpandableSection/ExpandableSection.test.js +0 -0
  110. package/src/molecules/ExpandableSection/styles.scss +0 -22
  111. package/src/molecules/ServerModulesList/ServerModulesList.js +0 -75
  112. package/src/molecules/ServerModulesList/styles.scss +0 -28
  113. package/src/molecules/TargetSelector/TargetSelector.js +0 -34
  114. package/src/molecules/TargetSelector/TargetSelector.test.js +0 -0
  115. package/src/molecules/TargetSelector/styles.scss +0 -0
  116. package/src/molecules/TestCaption/TestCaption.js +0 -26
  117. package/src/molecules/TestCaption/TestCaption.test.js +0 -0
  118. package/src/molecules/TestCaption/styles.scss +0 -40
  119. package/src/molecules/TestSummary/index.js +0 -212
  120. package/src/molecules/TestSummary/styles.scss +0 -83
  121. package/src/molecules/TextWith2Links/TextWith2Links.js +0 -10
  122. package/src/molecules/TextWith2Links/styles.scss +0 -0
  123. package/src/molecules/ValidationInput/ValidationInput.js +0 -64
  124. package/src/molecules/ValidationInput/ValidationInput.test.js +0 -0
  125. package/src/molecules/ValidationInput/ValidationMessages.js +0 -178
  126. package/src/molecules/ValidationInput/ValidationOptions.js +0 -113
  127. package/src/molecules/ValidationInput/styles.scss +0 -74
  128. package/src/molecules/ValidationInput/validator.js +0 -244
  129. package/src/organisms/Documentation/Documentation.js +0 -128
  130. package/src/organisms/Documentation/Documentation.test.js +0 -0
  131. package/src/organisms/Documentation/styles.scss +0 -22
  132. package/src/organisms/MultiTestSection/MultiTestSection.js +0 -85
  133. package/src/organisms/MultiTestSection/MultiTestSection.test.js +0 -0
  134. package/src/organisms/MultiTestSection/styles.scss +0 -22
  135. package/src/organisms/SavedTests/SavedTests.js +0 -209
  136. package/src/organisms/SavedTests/SavedTests.test.js +0 -0
  137. package/src/organisms/SavedTests/styles.scss +0 -76
  138. package/src/organisms/SavedTests/transformTests.js +0 -51
  139. package/src/organisms/ScratchPad/ScratchPad.js +0 -128
  140. package/src/organisms/ScratchPad/ScratchPad.test.js +0 -0
  141. package/src/organisms/ScratchPad/styles.scss +0 -100
  142. package/src/organisms/SystemNavigator/SystemNavigator.js +0 -148
  143. package/src/organisms/SystemNavigator/SystemNavigator.test.js +0 -24
  144. package/src/organisms/SystemNavigator/styles.scss +0 -38
  145. package/src/organisms/TestContainer/TestContainer.js +0 -72
  146. package/src/organisms/TestContainer/TestContainer.test.js +0 -0
  147. package/src/organisms/TestContainer/styles.scss +0 -20
  148. package/src/organisms/TestPanel/AfterTest/AfterTest.js +0 -16
  149. package/src/organisms/TestPanel/AfterTest/AfterTest.test.js +0 -0
  150. package/src/organisms/TestPanel/AfterTest/styles.scss +0 -0
  151. package/src/organisms/TestPanel/BeforeTest/BeforeTest.js +0 -16
  152. package/src/organisms/TestPanel/BeforeTest/BeforeTest.test.js +0 -0
  153. package/src/organisms/TestPanel/BeforeTest/styles.scss +0 -0
  154. package/src/organisms/TestPanel/Evaluations.js +0 -369
  155. package/src/organisms/TestPanel/EventsTest/EventsTest.js +0 -19
  156. package/src/organisms/TestPanel/EventsTest/styles.scss +0 -0
  157. package/src/organisms/TestPanel/MainTest/MainTest.js +0 -20
  158. package/src/organisms/TestPanel/MainTest/MainTest.test.js +0 -0
  159. package/src/organisms/TestPanel/MainTest/styles.scss +0 -143
  160. package/src/organisms/TestPanel/TestPanel.js +0 -170
  161. package/src/organisms/TestPanel/TestPanel.test.js +0 -0
  162. package/src/organisms/TestPanel/components/Argument.class.js +0 -94
  163. package/src/organisms/TestPanel/components/FullTestController.js +0 -78
  164. package/src/organisms/TestPanel/components/Test.class.js +0 -162
  165. package/src/organisms/TestPanel/components/TestController.class.js +0 -135
  166. package/src/organisms/TestPanel/components/test-helpers.js +0 -109
  167. package/src/organisms/TestPanel/styles.scss +0 -45
  168. package/src/pages/SystemView/SystemView.js +0 -68
  169. package/src/pages/SystemView/styles.scss +0 -81
  170. package/src/reportWebVitals.js +0 -13
  171. package/src/sass/bootstrap/_alert.scss +0 -51
  172. package/src/sass/bootstrap/_badge.scss +0 -47
  173. package/src/sass/bootstrap/_breadcrumb.scss +0 -38
  174. package/src/sass/bootstrap/_button-group.scss +0 -166
  175. package/src/sass/bootstrap/_buttons.scss +0 -143
  176. package/src/sass/bootstrap/_card.scss +0 -270
  177. package/src/sass/bootstrap/_carousel.scss +0 -191
  178. package/src/sass/bootstrap/_close.scss +0 -34
  179. package/src/sass/bootstrap/_code.scss +0 -56
  180. package/src/sass/bootstrap/_custom-forms.scss +0 -297
  181. package/src/sass/bootstrap/_dropdown.scss +0 -131
  182. package/src/sass/bootstrap/_forms.scss +0 -333
  183. package/src/sass/bootstrap/_functions.scss +0 -86
  184. package/src/sass/bootstrap/_grid.scss +0 -52
  185. package/src/sass/bootstrap/_images.scss +0 -42
  186. package/src/sass/bootstrap/_input-group.scss +0 -159
  187. package/src/sass/bootstrap/_jumbotron.scss +0 -16
  188. package/src/sass/bootstrap/_list-group.scss +0 -115
  189. package/src/sass/bootstrap/_media.scss +0 -8
  190. package/src/sass/bootstrap/_mixins.scss +0 -42
  191. package/src/sass/bootstrap/_modal.scss +0 -168
  192. package/src/sass/bootstrap/_nav.scss +0 -118
  193. package/src/sass/bootstrap/_navbar.scss +0 -311
  194. package/src/sass/bootstrap/_pagination.scss +0 -77
  195. package/src/sass/bootstrap/_popover.scss +0 -183
  196. package/src/sass/bootstrap/_print.scss +0 -124
  197. package/src/sass/bootstrap/_progress.scss +0 -33
  198. package/src/sass/bootstrap/_reboot.scss +0 -482
  199. package/src/sass/bootstrap/_root.scss +0 -19
  200. package/src/sass/bootstrap/_tables.scss +0 -180
  201. package/src/sass/bootstrap/_tooltip.scss +0 -115
  202. package/src/sass/bootstrap/_transitions.scss +0 -36
  203. package/src/sass/bootstrap/_type.scss +0 -125
  204. package/src/sass/bootstrap/_utilities.scss +0 -14
  205. package/src/sass/bootstrap/_variables.scss +0 -894
  206. package/src/sass/bootstrap/bootstrap-grid.scss +0 -32
  207. package/src/sass/bootstrap/bootstrap-reboot.scss +0 -12
  208. package/src/sass/bootstrap/bootstrap.scss +0 -42
  209. package/src/sass/bootstrap/mixins/_alert.scss +0 -13
  210. package/src/sass/bootstrap/mixins/_background-variant.scss +0 -21
  211. package/src/sass/bootstrap/mixins/_badge.scss +0 -12
  212. package/src/sass/bootstrap/mixins/_border-radius.scss +0 -35
  213. package/src/sass/bootstrap/mixins/_box-shadow.scss +0 -5
  214. package/src/sass/bootstrap/mixins/_breakpoints.scss +0 -123
  215. package/src/sass/bootstrap/mixins/_buttons.scss +0 -109
  216. package/src/sass/bootstrap/mixins/_caret.scss +0 -65
  217. package/src/sass/bootstrap/mixins/_clearfix.scss +0 -7
  218. package/src/sass/bootstrap/mixins/_float.scss +0 -11
  219. package/src/sass/bootstrap/mixins/_forms.scss +0 -137
  220. package/src/sass/bootstrap/mixins/_gradients.scss +0 -45
  221. package/src/sass/bootstrap/mixins/_grid-framework.scss +0 -67
  222. package/src/sass/bootstrap/mixins/_grid.scss +0 -52
  223. package/src/sass/bootstrap/mixins/_hover.scss +0 -39
  224. package/src/sass/bootstrap/mixins/_image.scss +0 -36
  225. package/src/sass/bootstrap/mixins/_list-group.scss +0 -21
  226. package/src/sass/bootstrap/mixins/_lists.scss +0 -7
  227. package/src/sass/bootstrap/mixins/_nav-divider.scss +0 -10
  228. package/src/sass/bootstrap/mixins/_navbar-align.scss +0 -10
  229. package/src/sass/bootstrap/mixins/_pagination.scss +0 -22
  230. package/src/sass/bootstrap/mixins/_reset-text.scss +0 -17
  231. package/src/sass/bootstrap/mixins/_resize.scss +0 -6
  232. package/src/sass/bootstrap/mixins/_screen-reader.scss +0 -35
  233. package/src/sass/bootstrap/mixins/_size.scss +0 -6
  234. package/src/sass/bootstrap/mixins/_table-row.scss +0 -30
  235. package/src/sass/bootstrap/mixins/_text-emphasis.scss +0 -14
  236. package/src/sass/bootstrap/mixins/_text-hide.scss +0 -9
  237. package/src/sass/bootstrap/mixins/_text-truncate.scss +0 -8
  238. package/src/sass/bootstrap/mixins/_transition.scss +0 -9
  239. package/src/sass/bootstrap/mixins/_visibility.scss +0 -7
  240. package/src/sass/bootstrap/utilities/_align.scss +0 -8
  241. package/src/sass/bootstrap/utilities/_background.scss +0 -19
  242. package/src/sass/bootstrap/utilities/_borders.scss +0 -59
  243. package/src/sass/bootstrap/utilities/_clearfix.scss +0 -3
  244. package/src/sass/bootstrap/utilities/_display.scss +0 -38
  245. package/src/sass/bootstrap/utilities/_embed.scss +0 -52
  246. package/src/sass/bootstrap/utilities/_flex.scss +0 -46
  247. package/src/sass/bootstrap/utilities/_float.scss +0 -9
  248. package/src/sass/bootstrap/utilities/_position.scss +0 -36
  249. package/src/sass/bootstrap/utilities/_screenreaders.scss +0 -11
  250. package/src/sass/bootstrap/utilities/_sizing.scss +0 -12
  251. package/src/sass/bootstrap/utilities/_spacing.scss +0 -51
  252. package/src/sass/bootstrap/utilities/_text.scss +0 -52
  253. package/src/sass/bootstrap/utilities/_visibility.scss +0 -11
  254. package/src/setupTests.js +0 -5
@@ -1,170 +0,0 @@
1
- import React, { useState, useContext, useEffect } from "react";
2
- import BeforeTest from "./BeforeTest/BeforeTest";
3
- import AfterTest from "./AfterTest/AfterTest";
4
- import MainTest from "./MainTest/MainTest";
5
- import EventsTest from "./EventsTest/EventsTest";
6
- import ServiceContext from "../../ServiceContext";
7
- import Test from "./components/Test.class";
8
- import TestController from "./components/TestController.class";
9
- import "./styles.scss";
10
- import RunTestIcon from "../../atoms/RunTestIcon";
11
- import SaveIcon from "../../atoms/SaveIcon/SaveIcon";
12
- import SavedTests from "../SavedTests/SavedTests";
13
- import { Client } from "systemlynx";
14
- import FullTestController from "./components/FullTestController";
15
- import Title from "../../atoms/Title/Title";
16
- import { CurrentTest } from "../../atoms/StatusIndicator/StatusIndicator";
17
-
18
- const FullTest = ({ serviceId, moduleName, methodName }) => {
19
- const namespace = { serviceId, moduleName, methodName };
20
- const { connectedServices } = useContext(ServiceContext);
21
- const serviceData = connectedServices.find(
22
- (service) => service.serviceId === serviceId
23
- );
24
- const { Plugin } = serviceData
25
- ? Client.createService(serviceData.system.connectionData)
26
- : {};
27
- const [Before, setTestBefore] = useState([]);
28
- const [After, setTestAfter] = useState([]);
29
- const [Main, setTestMain] = useState([new Test({ namespace, shouldValidate: true })]);
30
- const eventNamespace = { serviceId, moduleName, methodName: "on" };
31
- const [Events, setEventTest] = useState([]);
32
- const FullTest = [Before, Main, Events, After];
33
- const [savedTests, setSavedTests] = useState([]);
34
- const [saveResponse, setMessage] = useState({ message: "", error: false });
35
- window.Tests = FullTest;
36
- const testCtrl = (TestSection, setState, section, FullTest) =>
37
- new TestController({
38
- TestSection,
39
- setState,
40
- section,
41
- FullTest,
42
- connectedServices,
43
- });
44
- const MainCtrl = testCtrl(Main, setTestMain, 1, FullTest);
45
- const BeforeCtrl = testCtrl(Before, setTestBefore, 0, FullTest);
46
- const EventCtrl = testCtrl(Events, setEventTest, 2, FullTest);
47
- const AfterCtrl = testCtrl(After, setTestAfter, 3, FullTest);
48
-
49
- const { runFullTest, saveTests } = new FullTestController({
50
- FullTest,
51
- connectedServices,
52
- });
53
-
54
- const runTest = async () => {
55
- const tests = await runFullTest();
56
- setFullTest(tests);
57
- };
58
- const setFullTest = ([Before, Main, Events, After]) => {
59
- setTestMain([...Main]);
60
- setTestBefore([...Before]);
61
- setEventTest([...Events]);
62
- setTestAfter([...After]);
63
- };
64
- const clearMessage = () => setMessage({ error: false, message: "" });
65
- const save = async () => {
66
- const { error, message } = await saveTests();
67
-
68
- if (!error) {
69
- resetTests();
70
- //fetchTests();
71
- }
72
-
73
- setMessage({ error, message });
74
- setTimeout(clearMessage, 4000);
75
- };
76
-
77
- const fetchTests = async () => {
78
- try {
79
- if (Plugin) {
80
- const results = await Plugin.getTests(namespace);
81
- setSavedTests(results);
82
- }
83
- } catch (error) {
84
- return [];
85
- }
86
- };
87
- const resetTests = () => {
88
- setTestBefore([]);
89
- setTestAfter([]);
90
- setEventTest([]);
91
- //get connection for the main test and set state
92
- const test = new Test({ namespace, shouldValidate: true }).getConnection(
93
- connectedServices
94
- );
95
- setTestMain([test]);
96
- };
97
-
98
- useEffect(() => {
99
- resetTests();
100
- fetchTests();
101
- // eslint-disable-next-line react-hooks/exhaustive-deps
102
- }, [serviceId, moduleName, methodName, connectedServices]);
103
-
104
- return (
105
- <section className="test-panel">
106
- <div className="container">
107
- <div className="row">
108
- <Title text="Scratch Pad" />
109
- {typeof Main[0].index === "number" && (
110
- <CurrentTest name={`Saved Test ${1 + Main[0].index}`} onClick={resetTests} />
111
- )}
112
- </div>
113
- <div>
114
- <span className="row test__buttons">
115
- <span
116
- className={`test-panel__error-message test-panel__error-message--hide-${!saveResponse.message} test-panel__error-message--error-${
117
- saveResponse.error
118
- } `}
119
- >
120
- <span>{saveResponse.message}</span>
121
- <span onClick={clearMessage} className="test-panel__clear-error btn">
122
- ×
123
- </span>
124
- </span>
125
-
126
- <span>
127
- <span className="btn" onClick={runTest}>
128
- <RunTestIcon />
129
- </span>
130
- <span className="btn" onClick={save}>
131
- <SaveIcon />
132
- </span>
133
- </span>
134
- </span>
135
-
136
- <div className="row test-panel__section">
137
- <BeforeTest TestController={BeforeCtrl} TestSection={Before} />
138
- </div>
139
- <div className="row test-panel__section">
140
- <MainTest TestController={MainCtrl} TestSection={Main} />
141
- </div>
142
-
143
- <div className="row test-panel__section">
144
- <AfterTest TestController={AfterCtrl} TestSection={After} />
145
- </div>
146
- <div className="row test-panel__section">
147
- <EventsTest
148
- TestController={EventCtrl}
149
- TestSection={Events}
150
- namespace={eventNamespace}
151
- FullTest={FullTest}
152
- />
153
- </div>
154
- <div className="row test-panel__section">
155
- <SavedTests
156
- savedTests={savedTests}
157
- connectedServices={connectedServices}
158
- setFullTest={setFullTest}
159
- Plugin={Plugin}
160
- fetchTests={fetchTests}
161
- />
162
- </div>
163
- </div>
164
- </div>
165
- <div className="scroll-buffer"></div>
166
- </section>
167
- );
168
- };
169
-
170
- export default FullTest;
File without changes
@@ -1,94 +0,0 @@
1
- import {
2
- isTargetValueFn,
3
- isTargetNamespace,
4
- targetValueFnRegex,
5
- obj,
6
- isEqualArrays,
7
- isFunction,
8
- strFn,
9
- } from "./test-helpers";
10
-
11
- export function TargetValue(target_namespace, source_map = [], source_index = 0) {
12
- this.target_namespace = target_namespace;
13
- this.source_map = source_map;
14
- this.source_index = source_index;
15
- }
16
- export default function Argument(
17
- name,
18
- FullTest,
19
- input_type = "undefined",
20
- input,
21
- targetValues = []
22
- ) {
23
- this.name = name;
24
- this.input = input;
25
- this.input_type = input_type;
26
- this.data_type = "";
27
- this.targetValues = targetValues;
28
-
29
- this.value = () => {
30
- return this.targetValues.reduce((arg, { source_map, target_namespace: nsp }) => {
31
- const [value, placeholder, key] = obj(arg).parse(source_map);
32
-
33
- if (isTargetValueFn(nsp)) {
34
- placeholder[key] = value
35
- .trim()
36
- .replace(nsp, getTargetValue(nsp.substring(3, nsp.length - 1)));
37
- } else if (isTargetNamespace(nsp)) {
38
- placeholder[key] = getTargetValue(nsp);
39
- } else {
40
- placeholder[key] = strFn(nsp);
41
- }
42
-
43
- return arg;
44
- //creating a deep copy in order to lose refs to original
45
- }, obj(this).clone()).input;
46
- };
47
-
48
- this.parseTargetValues = (input, source_map) => {
49
- //extract one or more target replacer text from string (i.e. "tv(beforeTest.Action1.error)")
50
- Array.from(input.matchAll(targetValueFnRegex)).forEach((match) => {
51
- this.addTargetValue(match[0], source_map, match.index);
52
- });
53
- if (isTargetNamespace(input) || isFunction(input))
54
- this.addTargetValue(input, source_map, 0);
55
-
56
- return this;
57
- };
58
-
59
- this.checkTargetNamespaces = () => {
60
- // check target namespaces against current input for deletion
61
- //keep if the target value string still exist on this.input...
62
- this.targetValues = this.targetValues.filter(
63
- ({ target_namespace, source_map, source_index }) => {
64
- const value = obj(this).valueAt(source_map);
65
- return (
66
- typeof value === "string" &&
67
- value.indexOf(target_namespace, source_index) === source_index
68
- );
69
- }
70
- );
71
- return this;
72
- };
73
-
74
- this.addTargetValue = (target_namespace, source_map = [], source_index) => {
75
- //check to see if target value already exists first
76
- this.targetValues.findIndex(
77
- (tv) =>
78
- tv.target_namespace === target_namespace &&
79
- isEqualArrays(tv.source_map, source_map) &&
80
- tv.source_index === source_index
81
- ) === -1 &&
82
- this.targetValues.push(new TargetValue(target_namespace, source_map, source_index));
83
- return this;
84
- };
85
-
86
- const getTargetValue = (input) => {
87
- const [test, action] = input.split(".");
88
- const nsp = input
89
- .replace(test, { beforeTest: 0, mainTest: 1, Events: 2, afterTest: 3 }[test])
90
- .replace(action, parseInt(action.replace("Action", "")) - 1)
91
- .replace("error", "results");
92
- return obj(FullTest).valueAtNsp(nsp);
93
- };
94
- }
@@ -1,78 +0,0 @@
1
- import Test from "./Test.class";
2
-
3
- const sections = ["Before", "Main", "Events", "After"];
4
-
5
- export default function FullTestController({ FullTest, connectedServices }) {
6
- this.runFullTest = async ([Before, Main, Events, After] = FullTest) => {
7
- Events.forEach((test) => test.runTest());
8
-
9
- await new Promise((resolve) => {
10
- function recursiveRunTest(tests, i = 0) {
11
- if (i === tests.length) resolve();
12
- else tests[i].runTest().then(() => recursiveRunTest(tests, i + 1));
13
- }
14
- recursiveRunTest([...Before, ...Main, ...After]);
15
- });
16
-
17
- return [Before, Main, Events, After];
18
- };
19
-
20
- function validateTest({ title, evaluations, shouldValidate }, section, index) {
21
- if (!title)
22
- return {
23
- message: `${sections[section]}: Action ${index + 1} description is required`,
24
- error: true,
25
- };
26
- if (shouldValidate && !evaluations.filter((e) => e.save).length)
27
- return {
28
- message: `${sections[section]}: Action ${index + 1} validations required`,
29
- error: true,
30
- };
31
-
32
- return { error: false };
33
- }
34
- this.saveTests = async (Tests = FullTest) => {
35
- const { title, getConnection, namespace, index } = Tests[1][0];
36
-
37
- for (let i = 0; i < Tests.length; i++) {
38
- for (let x = 0; x < Tests.length; x++) {
39
- const res = Tests[i][x] ? validateTest(Tests[i][x], i, x) : {};
40
- if (res.error) return res;
41
- }
42
- }
43
-
44
- const { connection } = getConnection(connectedServices);
45
-
46
- const { Plugin } = connection[namespace.serviceId];
47
-
48
- if (Plugin) {
49
- const [Before, Main, Events, After] = Tests.map((testSection) =>
50
- testSection.map((test) => {
51
- const { args, evaluations, namespace, title } = test;
52
- //resetting scope of test
53
- Object.assign(test, new Test(test));
54
- return {
55
- args,
56
- namespace,
57
- title,
58
- savedEvaluations: evaluations
59
- .filter((e) => e.save)
60
- .map(({ namespace, expected_type, validations, save, indexed }) => ({
61
- namespace,
62
- expected_type,
63
- validations,
64
- save,
65
- indexed,
66
- })),
67
- };
68
- })
69
- );
70
-
71
- const testIndex = await Plugin.saveTest(
72
- { Before, Main, Events, After, title, namespace },
73
- index
74
- );
75
- return { message: "Test Saved!", error: false, testIndex };
76
- } else return { message: "Plugin Plugin not connected!", error: true };
77
- };
78
- }
@@ -1,162 +0,0 @@
1
- import { validateResults } from "../../../molecules/ValidationInput/validator";
2
- import { Client } from "systemlynx";
3
- import moment from "moment";
4
- import { getArrayNamespaces, getLastArrayNamespace, obj } from "./test-helpers";
5
-
6
- export default function Test({
7
- namespace,
8
- args,
9
- title,
10
- shouldValidate = false,
11
- savedEvaluations = [],
12
- index,
13
- editMode = true,
14
- }) {
15
- const logger = new TestLogger(this);
16
- this.index = index;
17
- this.connection = {};
18
- this.title = title;
19
- this.args = args || [];
20
- this.editMode = editMode;
21
- this.shouldValidate = shouldValidate || !!savedEvaluations.length;
22
- this.namespace = namespace || {
23
- serviceId: "",
24
- moduleName: "",
25
- methodName: "",
26
- };
27
- this.clearResults = () => {
28
- this.results = null;
29
- this.response_type = "";
30
- this.test_start = null;
31
- this.test_end = null;
32
- this.evaluations = [];
33
- this.savedEvaluations = obj(savedEvaluations).clone();
34
- this.errors = [];
35
- return this;
36
- };
37
-
38
- this.clearResults();
39
-
40
- this.getErrors = () => {
41
- this.errors = this.evaluations
42
- .filter(({ save }) => save)
43
- .reduce(
44
- (sum, { errors, namespace }) =>
45
- sum.concat(errors.map((e) => ({ ...e, namespace }))),
46
- []
47
- );
48
- return this.errors;
49
- };
50
-
51
- this.validate = validateResults.bind(this);
52
-
53
- this.runTest = async () => {
54
- const { serviceId, moduleName, methodName } = this.namespace;
55
- const args = this.args.map((arg) => arg.value());
56
-
57
- this.test_start = moment().toJSON();
58
- const Module = this.connection[serviceId][moduleName];
59
- if (methodName === "on") {
60
- const eventTest = (e) => {
61
- this.results = e;
62
- this.test_end = moment().toJSON();
63
- this.response_type = "event";
64
- this.shouldValidate && this.validate();
65
- logger.end();
66
- Module.$clearEvent(args[0], "eventTest");
67
- };
68
- logger.start(args);
69
- Module.on(args[0], eventTest);
70
- } else {
71
- try {
72
- logger.start(args);
73
- this.results = await Module[methodName](...args);
74
- this.test_end = moment().toJSON();
75
- this.response_type = "results";
76
- this.shouldValidate && this.validate();
77
- logger.end();
78
- } catch (error) {
79
- this.test_end = moment().toJSON();
80
- this.results = error;
81
- this.response_type = "error";
82
- this.shouldValidate && this.validate();
83
- logger.end();
84
- }
85
- }
86
- return this;
87
- };
88
-
89
- this.getConnection = (connectedServices) => {
90
- const { serviceId } = this.namespace;
91
-
92
- if (connectedServices.length > 0) {
93
- const service = connectedServices.find(
94
- (service) => service.serviceId === serviceId
95
- );
96
- if (!service) {
97
- console.warn("connection data not found");
98
- return this;
99
- }
100
- const { connectionData } = service.system;
101
-
102
- this.connection[serviceId] = Client.createService(connectionData);
103
- }
104
-
105
- return this;
106
- };
107
-
108
- this.addEvaluation = (evaluation) => {
109
- const savedEval = this.savedEvaluations.find(
110
- ({ namespace }) => namespace === evaluation.namespace
111
- );
112
- if (savedEval) Object.assign(savedEval, evaluation);
113
- else this.savedEvaluations.push(evaluation);
114
- };
115
- this.removeEvaluation = (namespace) => {
116
- const index = this.savedEvaluations.findIndex((e) => e.namespace === namespace);
117
- if (index > -1) return this.savedEvaluations.splice(index, 1)[0];
118
- else return {};
119
- };
120
-
121
- this.addSavedIndices = (arrayNamespace, newArrayNamespace) => {
122
- //break namespace into multiple array namespaces
123
- const nspList = getArrayNamespaces(arrayNamespace);
124
- this.evaluations.forEach((e) => {
125
- if (nspList.includes(getLastArrayNamespace(e.namespace))) {
126
- e.namespace = e.namespace.replace(arrayNamespace, newArrayNamespace);
127
- e.indexed = true;
128
- e.expected_type = undefined;
129
- this.addEvaluation(e);
130
- }
131
- });
132
- };
133
- this.removeSavedIndices = (namespace) => {
134
- this.savedEvaluations = this.savedEvaluations.filter(
135
- (e) => !e.namespace.includes(namespace) //|| !e.indexed
136
- );
137
- };
138
- }
139
-
140
- function TestLogger(test) {
141
- this.start = (args) => {
142
- const { serviceId, moduleName, methodName } = test.namespace;
143
-
144
- console.log(
145
- `[${moment(this.test_start).format(
146
- "L LTS"
147
- )}]> [invoking]:${serviceId}.${moduleName}.${methodName}()`
148
- );
149
- console.log.apply({}, ["args:"].concat(args));
150
- };
151
- this.end = () => {
152
- const { serviceId, moduleName, methodName } = test.namespace;
153
- const { results, response_type } = test;
154
- console.log(
155
- `[${moment(this.test_end).format(
156
- "L LTS"
157
- )}]> [${response_type}]:${serviceId}.${moduleName}.${methodName}()`,
158
- `${response_type}:`,
159
- results
160
- );
161
- };
162
- }
@@ -1,135 +0,0 @@
1
- import { getType } from "../../../molecules/ValidationInput/validator";
2
- import Test from "./Test.class";
3
- import Argument, { TargetValue } from "./Argument.class";
4
- export default function TestController({
5
- TestSection,
6
- setState,
7
- section,
8
- FullTest,
9
- connectedServices,
10
- }) {
11
- this.runTest = async (testIndex) => {
12
- const test = TestSection[testIndex];
13
- //run only one test
14
- await test.runTest();
15
- setState([...TestSection]);
16
- };
17
-
18
- this.runAllTest = async () => {};
19
-
20
- this.updateNamespace = (index, namespace) => {
21
- TestSection[index].namespace = namespace;
22
- TestSection[index].getConnection(connectedServices);
23
- setState([...TestSection]);
24
- };
25
- this.addTest = (namespace, args, title) => {
26
- TestSection.push(new Test({ namespace, args, title, editMode: true }));
27
- setState([...TestSection]);
28
- if (namespace) this.updateNamespace(TestSection.length - 1, namespace);
29
- };
30
- this.deleteTest = (index) => {
31
- TestSection.splice(index, 1);
32
- setState([...TestSection]);
33
- };
34
- this.addArg = (index) => {
35
- const name = "arg" + (TestSection[0].args.length + 1);
36
- TestSection[index].args.push(new Argument(name, FullTest));
37
- setState([...TestSection]);
38
- };
39
- this.deleteArg = (index, arg_index) => {
40
- TestSection[index].args.splice(arg_index, 1);
41
- setState([...TestSection]);
42
- };
43
- this.editArg = (index, arg_index, arg) => {
44
- arg.data_type = getType(arg.input);
45
- TestSection[index].args[arg_index] = arg;
46
- setState([...TestSection]);
47
- };
48
- this.resetResults = (index) => {
49
- TestSection[index].clearResults();
50
- setState([...TestSection]);
51
- };
52
-
53
- this.addTargetValue = (
54
- testIndex,
55
- arg_index,
56
- target_namespace,
57
- source_map,
58
- source_index
59
- ) => {
60
- //check to see if target value already exists first
61
- const arg = TestSection[testIndex].args[arg_index];
62
- arg.addTargetValue(target_namespace, source_map, source_index);
63
- setState([...TestSection]);
64
- };
65
- this.setTargetValue = (
66
- testIndex,
67
- arg_index,
68
- target_index,
69
- target_namespace,
70
- source_map,
71
- source_index
72
- ) => {
73
- const arg = TestSection[testIndex].args[arg_index];
74
-
75
- arg.targetValues[target_index] = new TargetValue(
76
- target_namespace.trim(),
77
- source_map,
78
- source_index
79
- );
80
- setState([...TestSection]);
81
- };
82
-
83
- this.parseTargetValues = (testIndex, arg_index, input, source_map) => {
84
- const arg = TestSection[testIndex].args[arg_index];
85
- arg.parseTargetValues(input, source_map).checkTargetNamespaces();
86
- setState([...TestSection]);
87
- };
88
- this.checkTargetValues = (testIndex, arg_index) => {
89
- const arg = TestSection[testIndex].args[arg_index];
90
- arg.checkTargetNamespaces();
91
- setState([...TestSection]);
92
- };
93
- this.updateTitle = (testIndex, title) => {
94
- TestSection[testIndex].title = title;
95
- setState([...TestSection]);
96
- };
97
- this.updateEvaluations = (testIndex, evaluations) => {
98
- TestSection[testIndex].evaluations = evaluations;
99
- setState([...TestSection]);
100
- };
101
- this.updateTests = () => {
102
- setState([...TestSection]);
103
- };
104
- this.updateValidationStatus = (testIndex) => {
105
- if (section !== 1) {
106
- TestSection[testIndex].shouldValidate = !TestSection[testIndex].shouldValidate;
107
- if (TestSection[testIndex].shouldValidate) TestSection[testIndex].validate();
108
- else TestSection[testIndex].evaluations = [];
109
- setState([...TestSection]);
110
- }
111
- };
112
- this.getTargetSuggestions = (testIndex) => {
113
- //get target value suggestion (namespaces) for previous test including sub test
114
- const suggestions = [];
115
- const test_names = ["beforeTest", "mainTest", "afterTest"];
116
- //exclude all test sections following current section
117
- const targetTests = FullTest.slice(0, section + 1);
118
-
119
- targetTests.forEach((test_section, sIndex) => {
120
- //also exclude current test and the tests that follow from the suggestions
121
- const count = sIndex === section ? testIndex : test_section.length;
122
- for (let i = 0; i < count; i++) {
123
- suggestions.push(
124
- `${test_names[sIndex]}.${"Action" + (i + 1) + "."}${
125
- test_section[i].response_type || "results"
126
- }`
127
- );
128
- }
129
- });
130
-
131
- return suggestions;
132
- };
133
-
134
- return this;
135
- }