pict-section-form 1.3.13 → 1.3.15
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.
- package/docs/Injection_Conformance.md +137 -0
- package/docs/_sidebar.md +1 -0
- package/docs/input_providers/012-tab-group-selector.md +3 -1
- package/docs/input_providers/013-tab-section-selector.md +3 -1
- package/package.json +6 -5
- package/source/providers/Pict-Provider-DynamicFormSolverBehaviors.js +73 -5
- package/source/providers/Pict-Provider-DynamicSolver.js +20 -2
- package/source/providers/inputs/Pict-Provider-Input-TabGroupSelector.js +42 -3
- package/source/providers/inputs/Pict-Provider-Input-TabSectionSelector.js +42 -3
- package/source/views/Pict-View-Form-Metacontroller.js +685 -90
- package/test/Pict-Provider-DynamicFormSolverBehaviors-OrdinalScope_tests.js +105 -0
- package/test/Pict-Provider-Input-TabGroupSelector-TabHashValidation_tests.js +178 -0
- package/test/Pict-Provider-Input-TabSectionSelector-TabHashValidation_tests.js +193 -0
- package/test/Pict-View-Form-Metacontroller-DistinctManifest_tests.js +410 -0
- package/test/PictSectionForm-Injection-Conformance_tests.js +751 -0
- package/test/browser/Injection-Conformance-Differential-Scenario.js +346 -0
- package/test/browser/Injection-Conformance-EdgeCase-Scenario.js +168 -0
- package/test/browser/Injection-Conformance-Harness-Driver.js +538 -0
- package/test/browser/Injection-Conformance-Harness-Runner.js +487 -0
- package/test/browser/Injection-Conformance-Reconstitution-Scenario.js +191 -0
- package/test/browser/Injection-Conformance-Standalone-Scenario.js +114 -0
- package/test/fixtures/injection/Injection-Fixture-Cases.js +203 -0
- package/test/fixtures/injection/Injection-Fixture-Manifest.json +366 -0
- package/types/source/providers/Pict-Provider-DynamicFormSolverBehaviors.d.ts +110 -1
- package/types/source/providers/Pict-Provider-DynamicFormSolverBehaviors.d.ts.map +1 -1
- package/types/source/providers/Pict-Provider-DynamicSolver.d.ts.map +1 -1
- package/types/source/providers/Pict-Provider-DynamicTabularData.d.ts +17 -1
- package/types/source/providers/Pict-Provider-DynamicTabularData.d.ts.map +1 -1
- package/types/source/providers/Pict-Provider-InputExtension.d.ts +31 -0
- package/types/source/providers/Pict-Provider-InputExtension.d.ts.map +1 -1
- package/types/source/providers/inputs/Pict-Provider-Input-Chart-CSS.d.ts +16 -0
- package/types/source/providers/inputs/Pict-Provider-Input-Chart-CSS.d.ts.map +1 -0
- package/types/source/providers/inputs/Pict-Provider-Input-Chart.d.ts +47 -0
- package/types/source/providers/inputs/Pict-Provider-Input-Chart.d.ts.map +1 -1
- package/types/source/providers/inputs/Pict-Provider-Input-Diagram.d.ts +86 -0
- package/types/source/providers/inputs/Pict-Provider-Input-Diagram.d.ts.map +1 -1
- package/types/source/providers/inputs/Pict-Provider-Input-ObjectEditor.d.ts +128 -0
- package/types/source/providers/inputs/Pict-Provider-Input-ObjectEditor.d.ts.map +1 -0
- package/types/source/providers/inputs/Pict-Provider-Input-PreciseNumber.d.ts.map +1 -1
- package/types/source/providers/inputs/Pict-Provider-Input-TabGroupSelector.d.ts +10 -1
- package/types/source/providers/inputs/Pict-Provider-Input-TabGroupSelector.d.ts.map +1 -1
- package/types/source/providers/inputs/Pict-Provider-Input-TabSectionSelector.d.ts +10 -1
- package/types/source/providers/inputs/Pict-Provider-Input-TabSectionSelector.d.ts.map +1 -1
- package/types/source/providers/layouts/Pict-Layout-Tabular.d.ts +76 -4
- package/types/source/providers/layouts/Pict-Layout-Tabular.d.ts.map +1 -1
- package/types/source/views/Pict-View-DynamicForm.d.ts.map +1 -1
- package/types/source/views/Pict-View-Form-Metacontroller.d.ts +63 -2
- package/types/source/views/Pict-View-Form-Metacontroller.d.ts.map +1 -1
|
@@ -0,0 +1,538 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Injection conformance, browser tier: the in-page driver.
|
|
3
|
+
|
|
4
|
+
Boots a pict-section-form application in a real browser, injects manifests through createDistinctManifest
|
|
5
|
+
+ injectManifest (the path a host application takes), drives the DOM and publishes what it saw as base64
|
|
6
|
+
JSON on #PictFormInjectionHarness-Results, for Injection-Conformance-Harness-Runner.js to read back out
|
|
7
|
+
of `chrome --dump-dom`.
|
|
8
|
+
*/
|
|
9
|
+
/* global Pict */
|
|
10
|
+
|
|
11
|
+
const libPictSectionForm = require('../../source/Pict-Section-Form.js');
|
|
12
|
+
|
|
13
|
+
const RESULTS_ELEMENT_ID = 'PictFormInjectionHarness-Results';
|
|
14
|
+
const BOOT_TIMEOUT_MS = 20000;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @typedef {Object} HarnessCheck
|
|
18
|
+
* @property {string} Label
|
|
19
|
+
* @property {boolean} Passed
|
|
20
|
+
* @property {'fail'|'open'} Severity - 'open' marks a known, reported gap; it is printed but does not fail the run.
|
|
21
|
+
* @property {any} [Detail]
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @typedef {Object} HarnessBootOptions
|
|
26
|
+
* @property {Record<string, any>} HostManifest - Manifest the application boots with (DefaultFormManifest).
|
|
27
|
+
* @property {string} [MarshalDestination] - Address the form marshals to; defaults to AppData.
|
|
28
|
+
* @property {Record<string, any>} [InitialAppData] - The application data before the first render.
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @param {any} pValue
|
|
33
|
+
* @return {any}
|
|
34
|
+
*/
|
|
35
|
+
function cloneData(pValue)
|
|
36
|
+
{
|
|
37
|
+
if (pValue === undefined)
|
|
38
|
+
{
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
return JSON.parse(JSON.stringify(pValue));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Loose equality for solver output: numeric strings and numbers compare by value, arrays element-wise.
|
|
46
|
+
*
|
|
47
|
+
* @param {any} pActual
|
|
48
|
+
* @param {any} pExpected
|
|
49
|
+
* @return {boolean}
|
|
50
|
+
*/
|
|
51
|
+
function looselyEqual(pActual, pExpected)
|
|
52
|
+
{
|
|
53
|
+
if (Array.isArray(pExpected))
|
|
54
|
+
{
|
|
55
|
+
if (!Array.isArray(pActual) || (pActual.length !== pExpected.length))
|
|
56
|
+
{
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
for (let i = 0; i < pExpected.length; i++)
|
|
60
|
+
{
|
|
61
|
+
if (!looselyEqual(pActual[i], pExpected[i]))
|
|
62
|
+
{
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
if ((typeof pExpected === 'number') || ((typeof pExpected === 'string') && (pExpected.trim() !== '') && !isNaN(Number(pExpected))))
|
|
69
|
+
{
|
|
70
|
+
return (pActual !== null) && (pActual !== undefined) && (String(pActual).trim() !== '') && (Number(pActual) === Number(pExpected));
|
|
71
|
+
}
|
|
72
|
+
return pActual === pExpected;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Harness state and helpers shared by every scenario.
|
|
77
|
+
*/
|
|
78
|
+
class HarnessContext
|
|
79
|
+
{
|
|
80
|
+
/**
|
|
81
|
+
* @param {Record<string, any>} pConfig - window.PictFormInjectionHarnessConfig
|
|
82
|
+
* @param {Record<string, any>} [pHooks] - window.PictFormInjectionHarnessHooks
|
|
83
|
+
*/
|
|
84
|
+
constructor(pConfig, pHooks)
|
|
85
|
+
{
|
|
86
|
+
this.config = pConfig || {};
|
|
87
|
+
this.hooks = pHooks || {};
|
|
88
|
+
/** @type {Array<HarnessCheck>} */
|
|
89
|
+
this.checks = [];
|
|
90
|
+
/** @type {Array<string>} */
|
|
91
|
+
this.errors = [];
|
|
92
|
+
/** @type {Record<string, any>} */
|
|
93
|
+
this.snapshots = {};
|
|
94
|
+
/** @type {Record<string, any>} */
|
|
95
|
+
this.info = {};
|
|
96
|
+
/** @type {any} */
|
|
97
|
+
this.pict = null;
|
|
98
|
+
/** @type {string|null} */
|
|
99
|
+
this.tailSectionHash = null;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* @param {string} pLabel
|
|
104
|
+
* @param {any} pCondition
|
|
105
|
+
* @param {any} [pDetail]
|
|
106
|
+
* @param {'fail'|'open'} [pSeverity]
|
|
107
|
+
* @return {boolean}
|
|
108
|
+
*/
|
|
109
|
+
check(pLabel, pCondition, pDetail, pSeverity)
|
|
110
|
+
{
|
|
111
|
+
const tmpPassed = Boolean(pCondition);
|
|
112
|
+
this.checks.push({ Label: pLabel, Passed: tmpPassed, Severity: pSeverity || 'fail', Detail: tmpPassed ? undefined : cloneData(pDetail === undefined ? null : pDetail) });
|
|
113
|
+
return tmpPassed;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* @param {string} pLabel
|
|
118
|
+
* @param {any} pActual
|
|
119
|
+
* @param {any} pExpected
|
|
120
|
+
* @param {'fail'|'open'} [pSeverity]
|
|
121
|
+
* @return {boolean}
|
|
122
|
+
*/
|
|
123
|
+
checkEqual(pLabel, pActual, pExpected, pSeverity)
|
|
124
|
+
{
|
|
125
|
+
return this.check(pLabel, looselyEqual(pActual, pExpected), { Actual: pActual === undefined ? '(undefined)' : pActual, Expected: pExpected }, pSeverity);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* @param {number} pMilliseconds
|
|
130
|
+
* @return {Promise<void>}
|
|
131
|
+
*/
|
|
132
|
+
wait(pMilliseconds)
|
|
133
|
+
{
|
|
134
|
+
return new Promise((fResolve) => setTimeout(fResolve, pMilliseconds));
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
get metacontroller()
|
|
138
|
+
{
|
|
139
|
+
return this.pict.views.PictFormMetacontroller;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
get marshalDestinationObject()
|
|
143
|
+
{
|
|
144
|
+
return this.pict.providers.DataBroker.marshalDestinationObject;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Boots the form application and resolves after its first render and solve.
|
|
149
|
+
*
|
|
150
|
+
* @param {HarnessBootOptions} pOptions
|
|
151
|
+
* @return {Promise<void>}
|
|
152
|
+
*/
|
|
153
|
+
async boot(pOptions)
|
|
154
|
+
{
|
|
155
|
+
const tmpMarshalDestination = pOptions.MarshalDestination;
|
|
156
|
+
|
|
157
|
+
class HarnessApplication extends libPictSectionForm.PictFormApplication
|
|
158
|
+
{
|
|
159
|
+
constructor(pFable, pAppOptions, pServiceHash)
|
|
160
|
+
{
|
|
161
|
+
super(pFable, pAppOptions, pServiceHash);
|
|
162
|
+
if (tmpMarshalDestination)
|
|
163
|
+
{
|
|
164
|
+
this.pict.providers.DataBroker.marshalDestination = tmpMarshalDestination;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
HarnessApplication.default_configuration = Object.assign({}, libPictSectionForm.PictFormApplication.default_configuration,
|
|
169
|
+
{
|
|
170
|
+
Name: 'Injection Conformance Harness',
|
|
171
|
+
Hash: 'InjectionConformanceHarness',
|
|
172
|
+
pict_configuration:
|
|
173
|
+
{
|
|
174
|
+
Product: 'InjectionConformanceHarness',
|
|
175
|
+
DefaultFormManifest: cloneData(pOptions.HostManifest),
|
|
176
|
+
DefaultAppData: cloneData(pOptions.InitialAppData || {}),
|
|
177
|
+
},
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
Pict.safeLoadPictApplication(HarnessApplication, 0);
|
|
181
|
+
|
|
182
|
+
const tmpStart = Date.now();
|
|
183
|
+
while (!(window._Pict && window._Pict.views && window._Pict.views.PictFormMetacontroller && window._Pict.views.PictFormMetacontroller.FirstRenderCompleted))
|
|
184
|
+
{
|
|
185
|
+
if ((Date.now() - tmpStart) > BOOT_TIMEOUT_MS)
|
|
186
|
+
{
|
|
187
|
+
throw new Error('The form application did not finish its first render.');
|
|
188
|
+
}
|
|
189
|
+
await this.wait(20);
|
|
190
|
+
}
|
|
191
|
+
this.pict = window._Pict;
|
|
192
|
+
this.captureErrors();
|
|
193
|
+
await this.wait(20);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Records error-level log lines so the runner can show them next to the checks.
|
|
198
|
+
*/
|
|
199
|
+
captureErrors()
|
|
200
|
+
{
|
|
201
|
+
const tmpLog = this.pict.log;
|
|
202
|
+
const tmpOriginalError = tmpLog.error.bind(tmpLog);
|
|
203
|
+
tmpLog.error = (pMessage, pData) =>
|
|
204
|
+
{
|
|
205
|
+
this.errors.push(String(pMessage));
|
|
206
|
+
return tmpOriginalError(pMessage, pData);
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Salts a manifest, applies the optional PostSalt hook, injects it after the previous injection and
|
|
212
|
+
* renders and marshals the new sections, the sequence a host application runs.
|
|
213
|
+
*
|
|
214
|
+
* @param {Record<string, any>} pManifest
|
|
215
|
+
* @param {string} pSalt
|
|
216
|
+
* @return {Promise<{ Salted: Record<string, any>, Views: Array<any> }>}
|
|
217
|
+
*/
|
|
218
|
+
async inject(pManifest, pSalt)
|
|
219
|
+
{
|
|
220
|
+
let tmpSalted = this.metacontroller.createDistinctManifest(pManifest, pSalt);
|
|
221
|
+
if (typeof this.hooks.PostSalt === 'function')
|
|
222
|
+
{
|
|
223
|
+
tmpSalted = this.hooks.PostSalt(pManifest, tmpSalted, pSalt) || tmpSalted;
|
|
224
|
+
}
|
|
225
|
+
const tmpViews = this.metacontroller.injectManifest(tmpSalted, this.tailSectionHash || undefined);
|
|
226
|
+
this.metacontroller.updateMetatemplateInDOM();
|
|
227
|
+
if (tmpViews.length > 0)
|
|
228
|
+
{
|
|
229
|
+
this.tailSectionHash = tmpViews[tmpViews.length - 1].Hash;
|
|
230
|
+
}
|
|
231
|
+
await this.wait(0);
|
|
232
|
+
for (const tmpView of tmpViews)
|
|
233
|
+
{
|
|
234
|
+
tmpView.render();
|
|
235
|
+
}
|
|
236
|
+
for (const tmpView of tmpViews)
|
|
237
|
+
{
|
|
238
|
+
tmpView.marshalToView();
|
|
239
|
+
}
|
|
240
|
+
await this.wait(20);
|
|
241
|
+
return { Salted: tmpSalted, Views: tmpViews };
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Runs every solver in every view, then marshals the results to the DOM.
|
|
246
|
+
*
|
|
247
|
+
* @return {Promise<void>}
|
|
248
|
+
*/
|
|
249
|
+
async solve()
|
|
250
|
+
{
|
|
251
|
+
this.pict.providers.DynamicSolver.solveViews();
|
|
252
|
+
this.metacontroller.marshalToView();
|
|
253
|
+
await this.wait(20);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* Renders a section again from the data as it stands, the way opening a saved form does.
|
|
258
|
+
*
|
|
259
|
+
* @param {string} pSectionHash
|
|
260
|
+
* @return {boolean} false when the section is not rendered
|
|
261
|
+
*/
|
|
262
|
+
rerenderSection(pSectionHash)
|
|
263
|
+
{
|
|
264
|
+
const tmpView = this.getSectionView(pSectionHash);
|
|
265
|
+
if (!tmpView)
|
|
266
|
+
{
|
|
267
|
+
return false;
|
|
268
|
+
}
|
|
269
|
+
tmpView.render();
|
|
270
|
+
tmpView.marshalToView();
|
|
271
|
+
return true;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* @param {string} pAddress - Address relative to the marshal destination.
|
|
276
|
+
* @return {any}
|
|
277
|
+
*/
|
|
278
|
+
getValue(pAddress)
|
|
279
|
+
{
|
|
280
|
+
return this.pict.manifest.getValueAtAddress(this.marshalDestinationObject, pAddress);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* @param {string} pSectionHash
|
|
285
|
+
* @return {any} the section view, or undefined
|
|
286
|
+
*/
|
|
287
|
+
getSectionView(pSectionHash)
|
|
288
|
+
{
|
|
289
|
+
return this.pict.views[`PictSectionForm-${pSectionHash}`];
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* @return {Array<any>} every dynamic form section view
|
|
294
|
+
*/
|
|
295
|
+
getSectionViews()
|
|
296
|
+
{
|
|
297
|
+
return Object.values(this.pict.views).filter((pView) => pView && pView.isPictSectionForm);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* @param {string} pInputHash
|
|
302
|
+
* @return {{ View: any, Input: any } | null}
|
|
303
|
+
*/
|
|
304
|
+
findInput(pInputHash)
|
|
305
|
+
{
|
|
306
|
+
for (const tmpView of this.getSectionViews())
|
|
307
|
+
{
|
|
308
|
+
const tmpInput = tmpView.getInputFromHash(pInputHash);
|
|
309
|
+
if (tmpInput)
|
|
310
|
+
{
|
|
311
|
+
return { View: tmpView, Input: tmpInput };
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
return null;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* @param {string} pInputHash
|
|
319
|
+
* @return {HTMLInputElement|null}
|
|
320
|
+
*/
|
|
321
|
+
getInputElement(pInputHash)
|
|
322
|
+
{
|
|
323
|
+
const tmpFound = this.findInput(pInputHash);
|
|
324
|
+
if (!tmpFound || !tmpFound.Input.Macro || !tmpFound.Input.Macro.HTMLSelector)
|
|
325
|
+
{
|
|
326
|
+
return null;
|
|
327
|
+
}
|
|
328
|
+
return document.querySelector(tmpFound.Input.Macro.HTMLSelector);
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* Types a value into an input and fires its change event, as a person would.
|
|
333
|
+
*
|
|
334
|
+
* @param {string} pInputHash
|
|
335
|
+
* @param {any} pValue
|
|
336
|
+
* @return {boolean} false when the input element is not in the DOM
|
|
337
|
+
*/
|
|
338
|
+
enterValue(pInputHash, pValue)
|
|
339
|
+
{
|
|
340
|
+
const tmpElement = this.getInputElement(pInputHash);
|
|
341
|
+
if (!tmpElement)
|
|
342
|
+
{
|
|
343
|
+
return false;
|
|
344
|
+
}
|
|
345
|
+
tmpElement.value = String(pValue);
|
|
346
|
+
tmpElement.dispatchEvent(new Event('input', { bubbles: true }));
|
|
347
|
+
tmpElement.dispatchEvent(new Event('change', { bubbles: true }));
|
|
348
|
+
return true;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
/**
|
|
352
|
+
* @param {Element|null} pElement
|
|
353
|
+
* @return {boolean|null} null when the element does not exist
|
|
354
|
+
*/
|
|
355
|
+
isElementHidden(pElement)
|
|
356
|
+
{
|
|
357
|
+
if (!pElement)
|
|
358
|
+
{
|
|
359
|
+
return null;
|
|
360
|
+
}
|
|
361
|
+
const tmpHideClasses =
|
|
362
|
+
[
|
|
363
|
+
'pict-section-form-hidden-section',
|
|
364
|
+
'pict-section-form-hidden-group',
|
|
365
|
+
this.pict.providers['Pict-Input-TabSectionSelector'] ? this.pict.providers['Pict-Input-TabSectionSelector'].cssHideClass : null,
|
|
366
|
+
this.pict.providers['Pict-Input-TabGroupSelector'] ? this.pict.providers['Pict-Input-TabGroupSelector'].cssHideClass : null,
|
|
367
|
+
].filter(Boolean);
|
|
368
|
+
let tmpElement = pElement;
|
|
369
|
+
while (tmpElement && (tmpElement !== document.body))
|
|
370
|
+
{
|
|
371
|
+
if (tmpHideClasses.some((pClass) => tmpElement.classList.contains(pClass)))
|
|
372
|
+
{
|
|
373
|
+
return true;
|
|
374
|
+
}
|
|
375
|
+
if (window.getComputedStyle(tmpElement).display === 'none')
|
|
376
|
+
{
|
|
377
|
+
return true;
|
|
378
|
+
}
|
|
379
|
+
tmpElement = tmpElement.parentElement;
|
|
380
|
+
}
|
|
381
|
+
return false;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
/**
|
|
385
|
+
* @param {string} pSectionHash
|
|
386
|
+
* @return {boolean|null} null when the section is not rendered
|
|
387
|
+
*/
|
|
388
|
+
isSectionHidden(pSectionHash)
|
|
389
|
+
{
|
|
390
|
+
const tmpView = this.getSectionView(pSectionHash);
|
|
391
|
+
if (!tmpView)
|
|
392
|
+
{
|
|
393
|
+
return null;
|
|
394
|
+
}
|
|
395
|
+
return this.isElementHidden(document.getElementById(`SECTION-${tmpView.formID}`));
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
/**
|
|
399
|
+
* @param {string} pSectionHash
|
|
400
|
+
* @param {string} pGroupHash
|
|
401
|
+
* @return {boolean|null} null when the group is not rendered
|
|
402
|
+
*/
|
|
403
|
+
isGroupHidden(pSectionHash, pGroupHash)
|
|
404
|
+
{
|
|
405
|
+
const tmpView = this.getSectionView(pSectionHash);
|
|
406
|
+
if (!tmpView)
|
|
407
|
+
{
|
|
408
|
+
return null;
|
|
409
|
+
}
|
|
410
|
+
return this.isElementHidden(document.getElementById(`GROUP-${tmpView.formID}-${pGroupHash}`));
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
/**
|
|
414
|
+
* Clicks one tab of a TabSectionSelector / TabGroupSelector input.
|
|
415
|
+
*
|
|
416
|
+
* @param {string} pInputHash
|
|
417
|
+
* @param {string} pTabHash
|
|
418
|
+
* @return {boolean} false when the tab element is not in the DOM
|
|
419
|
+
*/
|
|
420
|
+
clickTab(pInputHash, pTabHash)
|
|
421
|
+
{
|
|
422
|
+
const tmpFound = this.findInput(pInputHash);
|
|
423
|
+
if (!tmpFound || !tmpFound.Input.Macro)
|
|
424
|
+
{
|
|
425
|
+
return false;
|
|
426
|
+
}
|
|
427
|
+
const tmpTab = document.getElementById(`TAB-${pTabHash}-${tmpFound.Input.Macro.RawHTMLID}`);
|
|
428
|
+
if (!tmpTab)
|
|
429
|
+
{
|
|
430
|
+
return false;
|
|
431
|
+
}
|
|
432
|
+
tmpTab.click();
|
|
433
|
+
return true;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
* @param {string} pInputHash - hash of a Chart input
|
|
438
|
+
* @return {{ Labels: Array<any>, Datasets: Array<{ Label: string, Data: Array<any> }> } | null}
|
|
439
|
+
*/
|
|
440
|
+
getChartData(pInputHash)
|
|
441
|
+
{
|
|
442
|
+
const tmpFound = this.findInput(pInputHash);
|
|
443
|
+
const tmpProvider = this.pict.providers['Pict-Input-Chart'];
|
|
444
|
+
if (!tmpFound || !tmpFound.Input.Macro || !tmpProvider)
|
|
445
|
+
{
|
|
446
|
+
return null;
|
|
447
|
+
}
|
|
448
|
+
const tmpChart = tmpProvider.currentChartObjects[`Object-For-${tmpFound.Input.Macro.RawHTMLID}`];
|
|
449
|
+
if (!tmpChart || !tmpChart.data)
|
|
450
|
+
{
|
|
451
|
+
return null;
|
|
452
|
+
}
|
|
453
|
+
return (
|
|
454
|
+
{
|
|
455
|
+
Labels: cloneData(tmpChart.data.labels || []),
|
|
456
|
+
Datasets: (tmpChart.data.datasets || []).map((pSet) => ({ Label: pSet.label, Data: cloneData(pSet.data || []) })),
|
|
457
|
+
});
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
/**
|
|
461
|
+
* @param {string} pSectionHash
|
|
462
|
+
* @param {string} pSelector
|
|
463
|
+
* @return {Element|null}
|
|
464
|
+
*/
|
|
465
|
+
querySection(pSectionHash, pSelector)
|
|
466
|
+
{
|
|
467
|
+
const tmpView = this.getSectionView(pSectionHash);
|
|
468
|
+
if (!tmpView)
|
|
469
|
+
{
|
|
470
|
+
return null;
|
|
471
|
+
}
|
|
472
|
+
const tmpSection = document.getElementById(`SECTION-${tmpView.formID}`);
|
|
473
|
+
return tmpSection ? tmpSection.querySelector(pSelector) : null;
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
/**
|
|
477
|
+
* Writes the results where the node runner can find them in the dumped DOM.
|
|
478
|
+
*/
|
|
479
|
+
publish()
|
|
480
|
+
{
|
|
481
|
+
const tmpResults =
|
|
482
|
+
{
|
|
483
|
+
Checks: this.checks,
|
|
484
|
+
Errors: this.errors.slice(0, 200),
|
|
485
|
+
ErrorCount: this.errors.length,
|
|
486
|
+
Snapshots: this.snapshots,
|
|
487
|
+
Info: this.info,
|
|
488
|
+
};
|
|
489
|
+
const tmpEncoded = window.btoa(unescape(encodeURIComponent(JSON.stringify(tmpResults))));
|
|
490
|
+
let tmpElement = document.getElementById(RESULTS_ELEMENT_ID);
|
|
491
|
+
if (!tmpElement)
|
|
492
|
+
{
|
|
493
|
+
tmpElement = document.createElement('div');
|
|
494
|
+
tmpElement.id = RESULTS_ELEMENT_ID;
|
|
495
|
+
document.body.appendChild(tmpElement);
|
|
496
|
+
}
|
|
497
|
+
tmpElement.setAttribute('data-results', tmpEncoded);
|
|
498
|
+
document.title = 'PictFormInjectionHarness:done';
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
const _Scenarios =
|
|
503
|
+
{
|
|
504
|
+
EdgeCase: require('./Injection-Conformance-EdgeCase-Scenario.js'),
|
|
505
|
+
Differential: require('./Injection-Conformance-Differential-Scenario.js'),
|
|
506
|
+
Standalone: require('./Injection-Conformance-Standalone-Scenario.js'),
|
|
507
|
+
Reconstitution: require('./Injection-Conformance-Reconstitution-Scenario.js'),
|
|
508
|
+
};
|
|
509
|
+
|
|
510
|
+
/**
|
|
511
|
+
* Runs the scenario named by window.PictFormInjectionHarnessConfig.Scenario and publishes the results.
|
|
512
|
+
*
|
|
513
|
+
* @return {Promise<void>}
|
|
514
|
+
*/
|
|
515
|
+
async function run()
|
|
516
|
+
{
|
|
517
|
+
const tmpContext = new HarnessContext(window.PictFormInjectionHarnessConfig, window.PictFormInjectionHarnessHooks);
|
|
518
|
+
window.addEventListener('error', (pEvent) =>
|
|
519
|
+
{
|
|
520
|
+
tmpContext.errors.push(`window.onerror: ${pEvent.message}`);
|
|
521
|
+
});
|
|
522
|
+
try
|
|
523
|
+
{
|
|
524
|
+
const tmpScenario = _Scenarios[tmpContext.config.Scenario];
|
|
525
|
+
if (!tmpScenario)
|
|
526
|
+
{
|
|
527
|
+
throw new Error(`Unknown scenario [${tmpContext.config.Scenario}].`);
|
|
528
|
+
}
|
|
529
|
+
await tmpScenario.run(tmpContext);
|
|
530
|
+
}
|
|
531
|
+
catch (pError)
|
|
532
|
+
{
|
|
533
|
+
tmpContext.check('scenario ran to completion', false, (pError && pError.stack) ? pError.stack : String(pError));
|
|
534
|
+
}
|
|
535
|
+
tmpContext.publish();
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
module.exports = { run: run, HarnessContext: HarnessContext, looselyEqual: looselyEqual, cloneData: cloneData };
|