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,105 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Solver ordinal gates are per copy.
|
|
3
|
+
|
|
4
|
+
`setsolverordinalenabled` / `enablesolverordinal` / `disablesolverordinal` gate solvers by ordinal number,
|
|
5
|
+
and ordinals are small integers that every manifest uses from 1. So a gate an injected copy sets has to
|
|
6
|
+
stay inside that copy, or it silences whatever a sibling copy happens to have at the same ordinal.
|
|
7
|
+
|
|
8
|
+
A gate the form itself sets stays global: a form that gates its own ordinals has always been able to, and
|
|
9
|
+
the sections it declares carry no salt to scope by.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
const Chai = require('chai');
|
|
13
|
+
const Expect = Chai.expect;
|
|
14
|
+
|
|
15
|
+
const libPict = require('pict');
|
|
16
|
+
const libDynamicFormSolverBehaviors = require('../source/providers/Pict-Provider-DynamicFormSolverBehaviors.js');
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @return {any} the behaviors provider, wired to a pict instance and nothing else
|
|
20
|
+
*/
|
|
21
|
+
function buildBehaviors()
|
|
22
|
+
{
|
|
23
|
+
const tmpPict = new libPict({ Product: 'OrdinalScopeTests', LogStreams: [ { streamtype: 'console', level: 'fatal' } ] });
|
|
24
|
+
tmpPict.addProvider('DynamicFormSolverBehaviors', {}, libDynamicFormSolverBehaviors);
|
|
25
|
+
return tmpPict.providers.DynamicFormSolverBehaviors;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @param {string} pSectionHash - The section hash as the view holds it.
|
|
30
|
+
* @param {string} [pOriginalHash] - What the section was called before it was salted, when it is a copy.
|
|
31
|
+
*
|
|
32
|
+
* @return {any} a view stub carrying just the section definition the scope is read from
|
|
33
|
+
*/
|
|
34
|
+
function buildView(pSectionHash, pOriginalHash)
|
|
35
|
+
{
|
|
36
|
+
const tmpSection = { Hash: pSectionHash };
|
|
37
|
+
if (pOriginalHash)
|
|
38
|
+
{
|
|
39
|
+
tmpSection.OriginalHash = pOriginalHash;
|
|
40
|
+
}
|
|
41
|
+
return { sectionDefinition: tmpSection };
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
suite('Dynamic form solver behaviors ordinal scope', () =>
|
|
45
|
+
{
|
|
46
|
+
suite('getViewSolverScope', () =>
|
|
47
|
+
{
|
|
48
|
+
test('a section the form declares itself has no scope', () =>
|
|
49
|
+
{
|
|
50
|
+
const tmpBehaviors = buildBehaviors();
|
|
51
|
+
Expect(tmpBehaviors.getViewSolverScope(buildView('Measure'))).to.equal('');
|
|
52
|
+
Expect(tmpBehaviors.getViewSolverScope(undefined)).to.equal('');
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
test('an injected section is scoped by the salt it carries', () =>
|
|
56
|
+
{
|
|
57
|
+
const tmpBehaviors = buildBehaviors();
|
|
58
|
+
Expect(tmpBehaviors.getViewSolverScope(buildView('Measure_alpha', 'Measure'))).to.equal('alpha');
|
|
59
|
+
Expect(tmpBehaviors.getViewSolverScope(buildView('Measure_alphabeta', 'Measure'))).to.equal('alphabeta');
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
suite('gates', () =>
|
|
64
|
+
{
|
|
65
|
+
test('a gate one copy sets does not silence a sibling copy at the same ordinal', () =>
|
|
66
|
+
{
|
|
67
|
+
const tmpBehaviors = buildBehaviors();
|
|
68
|
+
tmpBehaviors.setActiveSolverScope('alpha');
|
|
69
|
+
tmpBehaviors.disableSolverOrdinal(5);
|
|
70
|
+
tmpBehaviors.setActiveSolverScope('');
|
|
71
|
+
|
|
72
|
+
Expect(tmpBehaviors.checkSolverOrdinalEnabled(5, 'alpha'), 'the copy that set it is gated').to.equal(false);
|
|
73
|
+
Expect(tmpBehaviors.checkSolverOrdinalEnabled(5, 'beta'), 'a sibling copy is not').to.equal(true);
|
|
74
|
+
Expect(tmpBehaviors.checkSolverOrdinalEnabled(5, ''), 'the form itself is not').to.equal(true);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
test('a gate the form sets applies everywhere, as it always has', () =>
|
|
78
|
+
{
|
|
79
|
+
const tmpBehaviors = buildBehaviors();
|
|
80
|
+
tmpBehaviors.disableSolverOrdinal(7);
|
|
81
|
+
|
|
82
|
+
Expect(tmpBehaviors.checkSolverOrdinalEnabled(7, '')).to.equal(false);
|
|
83
|
+
Expect(tmpBehaviors.checkSolverOrdinalEnabled(7, 'alpha')).to.equal(false);
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
test('an ordinal nothing has gated runs', () =>
|
|
87
|
+
{
|
|
88
|
+
const tmpBehaviors = buildBehaviors();
|
|
89
|
+
Expect(tmpBehaviors.checkSolverOrdinalEnabled(3, 'alpha')).to.equal(true);
|
|
90
|
+
Expect(tmpBehaviors.checkSolverOrdinalEnabled(3)).to.equal(true);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
test('re-enabling inside a copy only re-enables that copy', () =>
|
|
94
|
+
{
|
|
95
|
+
const tmpBehaviors = buildBehaviors();
|
|
96
|
+
tmpBehaviors.setActiveSolverScope('alpha');
|
|
97
|
+
tmpBehaviors.setSolverOrdinalEnabled(9, false);
|
|
98
|
+
tmpBehaviors.setSolverOrdinalEnabled(9, '1');
|
|
99
|
+
tmpBehaviors.setActiveSolverScope('');
|
|
100
|
+
|
|
101
|
+
Expect(tmpBehaviors.checkSolverOrdinalEnabled(9, 'alpha')).to.equal(true);
|
|
102
|
+
Expect(tmpBehaviors.checkSolverOrdinalEnabled(9, 'beta')).to.equal(true);
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
});
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
/*
|
|
2
|
+
A tab group hash that is not in the input's TabGroupSet used to be passed straight through:
|
|
3
|
+
selectTabByViewHash matched nothing, hid EVERY group, and left no tab selected -- a section
|
|
4
|
+
rendering as a tab strip over empty space, with the bad value never repaired.
|
|
5
|
+
|
|
6
|
+
Two ways in, both seen in the field: a stored value naming a group that was later renamed or
|
|
7
|
+
dropped from the manifest, and a typo'd DefaultTabGroupHash. These cover both, plus the
|
|
8
|
+
guarantee that a valid hash still wins over the fallback.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
const Chai = require('chai');
|
|
12
|
+
const Expect = Chai.expect;
|
|
13
|
+
|
|
14
|
+
const libTabGroupSelector = require('../source/providers/inputs/Pict-Provider-Input-TabGroupSelector.js');
|
|
15
|
+
|
|
16
|
+
const TAB_SET = [ 'GroupOne', 'GroupTwo' ];
|
|
17
|
+
|
|
18
|
+
// The provider without its constructor -- it injects CSS on construction, which these tests
|
|
19
|
+
// neither need nor want.
|
|
20
|
+
function buildProvider(pInput)
|
|
21
|
+
{
|
|
22
|
+
const tmpProvider = Object.create(libTabGroupSelector.prototype);
|
|
23
|
+
tmpProvider.cssHideClass = 'pict-tab-group-hidden';
|
|
24
|
+
tmpProvider.cssSelectedTabClass = 'pict-tab-group-selectedtab';
|
|
25
|
+
tmpProvider.warnings = [];
|
|
26
|
+
tmpProvider.added = [];
|
|
27
|
+
tmpProvider.removed = [];
|
|
28
|
+
tmpProvider.written = [];
|
|
29
|
+
|
|
30
|
+
const tmpView =
|
|
31
|
+
{
|
|
32
|
+
Hash: 'TestSection',
|
|
33
|
+
formID: 'F1',
|
|
34
|
+
getInputFromHash: () => pInput,
|
|
35
|
+
setDataByInput: (pTheInput, pValue) => tmpProvider.written.push(pValue),
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
tmpProvider.pict =
|
|
39
|
+
{
|
|
40
|
+
views: { TestSection: tmpView },
|
|
41
|
+
log:
|
|
42
|
+
{
|
|
43
|
+
warn: (pMessage) => tmpProvider.warnings.push(pMessage),
|
|
44
|
+
error: (pMessage) => tmpProvider.warnings.push(pMessage),
|
|
45
|
+
},
|
|
46
|
+
ContentAssignment:
|
|
47
|
+
{
|
|
48
|
+
addClass: (pSelector, pClass) => tmpProvider.added.push(`${pSelector}|${pClass}`),
|
|
49
|
+
removeClass: (pSelector, pClass) => tmpProvider.removed.push(`${pSelector}|${pClass}`),
|
|
50
|
+
projectContent: () => true,
|
|
51
|
+
},
|
|
52
|
+
providers: { DynamicInput: { getInputTemplateHash: () => 'TabElementTemplate' } },
|
|
53
|
+
parseTemplateByHash: () => '<li></li>',
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
tmpProvider.view = tmpView;
|
|
57
|
+
return tmpProvider;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function buildInput(pPictFormOverrides)
|
|
61
|
+
{
|
|
62
|
+
return {
|
|
63
|
+
Hash: 'TabInput',
|
|
64
|
+
Macro: { RawHTMLID: 'RAW1' },
|
|
65
|
+
PictForm: Object.assign({ TabGroupSet: TAB_SET.slice() }, pPictFormOverrides || {}),
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Which group is visible = the one the hide class was REMOVED from.
|
|
70
|
+
function shownGroup(pProvider)
|
|
71
|
+
{
|
|
72
|
+
const tmpShown = pProvider.removed
|
|
73
|
+
.filter((pEntry) => pEntry.indexOf(`|${pProvider.cssHideClass}`) > -1)
|
|
74
|
+
.map((pEntry) => pEntry.split('|')[0]);
|
|
75
|
+
return tmpShown.length === 1 ? tmpShown[0] : tmpShown;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
suite('Pict-Section-Form - TabGroupSelector tab hash validation', () =>
|
|
79
|
+
{
|
|
80
|
+
suite('isTabInSet', () =>
|
|
81
|
+
{
|
|
82
|
+
test('accepts a member and rejects everything else', () =>
|
|
83
|
+
{
|
|
84
|
+
const tmpProvider = buildProvider();
|
|
85
|
+
const tmpInput = buildInput();
|
|
86
|
+
Expect(tmpProvider.isTabInSet(tmpInput, 'GroupTwo')).to.equal(true);
|
|
87
|
+
Expect(tmpProvider.isTabInSet(tmpInput, 'GroupGone')).to.equal(false);
|
|
88
|
+
Expect(tmpProvider.isTabInSet(tmpInput, '')).to.equal(false);
|
|
89
|
+
Expect(tmpProvider.isTabInSet(tmpInput, undefined)).to.equal(false);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
test('rejects when the input has no usable TabGroupSet', () =>
|
|
93
|
+
{
|
|
94
|
+
const tmpProvider = buildProvider();
|
|
95
|
+
Expect(tmpProvider.isTabInSet(undefined, 'GroupOne')).to.equal(false);
|
|
96
|
+
Expect(tmpProvider.isTabInSet({ PictForm: {} }, 'GroupOne')).to.equal(false);
|
|
97
|
+
Expect(tmpProvider.isTabInSet({ PictForm: { TabGroupSet: 'GroupOne' } }, 'GroupOne')).to.equal(false);
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
suite('selectTabByViewHash', () =>
|
|
102
|
+
{
|
|
103
|
+
test('selects a hash that is in the set and stores it', () =>
|
|
104
|
+
{
|
|
105
|
+
const tmpInput = buildInput();
|
|
106
|
+
const tmpProvider = buildProvider(tmpInput);
|
|
107
|
+
Expect(tmpProvider.selectTabByViewHash('TestSection', 'TabInput', 'GroupTwo')).to.equal(true);
|
|
108
|
+
Expect(shownGroup(tmpProvider)).to.equal('#GROUP-F1-GroupTwo');
|
|
109
|
+
Expect(tmpProvider.written).to.deep.equal([ 'GroupTwo' ]);
|
|
110
|
+
Expect(tmpProvider.warnings).to.deep.equal([]);
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
test('refuses a hash that is not in the set and changes nothing', () =>
|
|
114
|
+
{
|
|
115
|
+
const tmpInput = buildInput();
|
|
116
|
+
const tmpProvider = buildProvider(tmpInput);
|
|
117
|
+
Expect(tmpProvider.selectTabByViewHash('TestSection', 'TabInput', 'GroupGone')).to.equal(false);
|
|
118
|
+
Expect(tmpProvider.added).to.deep.equal([]);
|
|
119
|
+
Expect(tmpProvider.removed).to.deep.equal([]);
|
|
120
|
+
Expect(tmpProvider.written).to.deep.equal([]);
|
|
121
|
+
Expect(tmpProvider.warnings.length).to.equal(1);
|
|
122
|
+
Expect(tmpProvider.warnings[0]).to.contain('GroupGone');
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
test('refuses when TabGroupSet is empty', () =>
|
|
126
|
+
{
|
|
127
|
+
const tmpInput = buildInput({ TabGroupSet: [] });
|
|
128
|
+
const tmpProvider = buildProvider(tmpInput);
|
|
129
|
+
Expect(tmpProvider.selectTabByViewHash('TestSection', 'TabInput', 'GroupOne')).to.equal(false);
|
|
130
|
+
Expect(tmpProvider.written).to.deep.equal([]);
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
suite('onInputInitialize tab precedence', () =>
|
|
135
|
+
{
|
|
136
|
+
test('uses the stored value when it is in the set', () =>
|
|
137
|
+
{
|
|
138
|
+
const tmpInput = buildInput({ DefaultTabGroupHash: 'GroupOne' });
|
|
139
|
+
const tmpProvider = buildProvider(tmpInput);
|
|
140
|
+
tmpProvider.onInputInitialize(tmpProvider.view, {}, {}, tmpInput, 'GroupTwo', '#SEL', 'TXN');
|
|
141
|
+
Expect(tmpProvider.written).to.deep.equal([ 'GroupTwo' ]);
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
test('skips a stored value that is no longer a tab and uses DefaultTabGroupHash', () =>
|
|
145
|
+
{
|
|
146
|
+
const tmpInput = buildInput({ DefaultTabGroupHash: 'GroupTwo' });
|
|
147
|
+
const tmpProvider = buildProvider(tmpInput);
|
|
148
|
+
tmpProvider.onInputInitialize(tmpProvider.view, {}, {}, tmpInput, 'GroupRenamedAwayLastRelease', '#SEL', 'TXN');
|
|
149
|
+
Expect(shownGroup(tmpProvider)).to.equal('#GROUP-F1-GroupTwo');
|
|
150
|
+
Expect(tmpProvider.written).to.deep.equal([ 'GroupTwo' ]);
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
test('skips a typo in DefaultTabGroupHash and uses the first tab', () =>
|
|
154
|
+
{
|
|
155
|
+
const tmpInput = buildInput({ DefaultTabGroupHash: 'GruopTwo' });
|
|
156
|
+
const tmpProvider = buildProvider(tmpInput);
|
|
157
|
+
tmpProvider.onInputInitialize(tmpProvider.view, {}, {}, tmpInput, '', '#SEL', 'TXN');
|
|
158
|
+
Expect(shownGroup(tmpProvider)).to.equal('#GROUP-F1-GroupOne');
|
|
159
|
+
Expect(tmpProvider.written).to.deep.equal([ 'GroupOne' ]);
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
test('DefaultFromData false still ignores the stored value', () =>
|
|
163
|
+
{
|
|
164
|
+
const tmpInput = buildInput({ DefaultFromData: false, DefaultTabGroupHash: 'GroupTwo' });
|
|
165
|
+
const tmpProvider = buildProvider(tmpInput);
|
|
166
|
+
tmpProvider.onInputInitialize(tmpProvider.view, {}, {}, tmpInput, 'GroupOne', '#SEL', 'TXN');
|
|
167
|
+
Expect(tmpProvider.written).to.deep.equal([ 'GroupTwo' ]);
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
test('errors out unchanged when TabGroupSet is missing', () =>
|
|
171
|
+
{
|
|
172
|
+
const tmpInput = { Hash: 'TabInput', Macro: { RawHTMLID: 'RAW1' }, PictForm: {} };
|
|
173
|
+
const tmpProvider = buildProvider(tmpInput);
|
|
174
|
+
Expect(tmpProvider.onInputInitialize(tmpProvider.view, {}, {}, tmpInput, 'GroupOne', '#SEL', 'TXN')).to.equal(false);
|
|
175
|
+
Expect(tmpProvider.written).to.deep.equal([]);
|
|
176
|
+
});
|
|
177
|
+
});
|
|
178
|
+
});
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
/*
|
|
2
|
+
TabSectionSelector twin of the TabGroupSelector tab hash validation. Same two ways in -- a stored
|
|
3
|
+
value naming a section that was later renamed or dropped from the manifest, and a typo'd
|
|
4
|
+
DefaultTabSectionHash -- but two symptoms, because selectTabByViewHash also requires the section's
|
|
5
|
+
view to exist:
|
|
6
|
+
- no such view: an early return, nothing hidden, every tab section stacked on screen;
|
|
7
|
+
- a real section outside TabSectionSet: EVERY tab section hidden, and the bad value stored.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
const Chai = require('chai');
|
|
11
|
+
const Expect = Chai.expect;
|
|
12
|
+
|
|
13
|
+
const libTabSectionSelector = require('../source/providers/inputs/Pict-Provider-Input-TabSectionSelector.js');
|
|
14
|
+
|
|
15
|
+
const TAB_SET = [ 'SectionOne', 'SectionTwo' ];
|
|
16
|
+
|
|
17
|
+
// The provider without its constructor -- it registers CSS on construction, which these tests
|
|
18
|
+
// neither need nor want.
|
|
19
|
+
function buildProvider(pInput)
|
|
20
|
+
{
|
|
21
|
+
const tmpProvider = Object.create(libTabSectionSelector.prototype);
|
|
22
|
+
tmpProvider.cssHideClass = 'pict-tab-section-hidden';
|
|
23
|
+
tmpProvider.cssSelectedTabClass = 'pict-tab-section-selectedtab';
|
|
24
|
+
tmpProvider.warnings = [];
|
|
25
|
+
tmpProvider.added = [];
|
|
26
|
+
tmpProvider.removed = [];
|
|
27
|
+
tmpProvider.written = [];
|
|
28
|
+
|
|
29
|
+
const tmpView =
|
|
30
|
+
{
|
|
31
|
+
Hash: 'NavigationView',
|
|
32
|
+
getInputFromHash: () => pInput,
|
|
33
|
+
setDataByInput: (pTheInput, pValue) => tmpProvider.written.push(pValue),
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
tmpProvider.pict =
|
|
37
|
+
{
|
|
38
|
+
views:
|
|
39
|
+
{
|
|
40
|
+
NavigationView: tmpView,
|
|
41
|
+
PictFormMetacontroller: { UUID: 'MC' },
|
|
42
|
+
// Every section has a view -- Navigation too, though it is not one of the tabs.
|
|
43
|
+
'PictSectionForm-SectionOne': {},
|
|
44
|
+
'PictSectionForm-SectionTwo': {},
|
|
45
|
+
'PictSectionForm-Navigation': {},
|
|
46
|
+
},
|
|
47
|
+
log:
|
|
48
|
+
{
|
|
49
|
+
warn: (pMessage) => tmpProvider.warnings.push(pMessage),
|
|
50
|
+
error: (pMessage) => tmpProvider.warnings.push(pMessage),
|
|
51
|
+
},
|
|
52
|
+
ContentAssignment:
|
|
53
|
+
{
|
|
54
|
+
addClass: (pSelector, pClass) => tmpProvider.added.push(`${pSelector}|${pClass}`),
|
|
55
|
+
removeClass: (pSelector, pClass) => tmpProvider.removed.push(`${pSelector}|${pClass}`),
|
|
56
|
+
projectContent: () => true,
|
|
57
|
+
},
|
|
58
|
+
providers: { DynamicInput: { getInputTemplateHash: () => 'TabElementTemplate' } },
|
|
59
|
+
parseTemplateByHash: () => '<li></li>',
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
tmpProvider.view = tmpView;
|
|
63
|
+
return tmpProvider;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function buildInput(pPictFormOverrides)
|
|
67
|
+
{
|
|
68
|
+
return {
|
|
69
|
+
Hash: 'TabInput',
|
|
70
|
+
Macro: { RawHTMLID: 'RAW1' },
|
|
71
|
+
PictForm: Object.assign({ TabSectionSet: TAB_SET.slice() }, pPictFormOverrides || {}),
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Which section is visible = the one the hide class was REMOVED from.
|
|
76
|
+
function shownSection(pProvider)
|
|
77
|
+
{
|
|
78
|
+
const tmpShown = pProvider.removed
|
|
79
|
+
.filter((pEntry) => pEntry.indexOf(`|${pProvider.cssHideClass}`) > -1)
|
|
80
|
+
.map((pEntry) => pEntry.split('|')[0]);
|
|
81
|
+
return tmpShown.length === 1 ? tmpShown[0] : tmpShown;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
suite('Pict-Section-Form - TabSectionSelector tab hash validation', () =>
|
|
85
|
+
{
|
|
86
|
+
suite('isTabInSet', () =>
|
|
87
|
+
{
|
|
88
|
+
test('accepts a member and rejects everything else', () =>
|
|
89
|
+
{
|
|
90
|
+
const tmpProvider = buildProvider();
|
|
91
|
+
const tmpInput = buildInput();
|
|
92
|
+
Expect(tmpProvider.isTabInSet(tmpInput, 'SectionTwo')).to.equal(true);
|
|
93
|
+
Expect(tmpProvider.isTabInSet(tmpInput, 'Navigation')).to.equal(false);
|
|
94
|
+
Expect(tmpProvider.isTabInSet(tmpInput, '')).to.equal(false);
|
|
95
|
+
Expect(tmpProvider.isTabInSet(tmpInput, undefined)).to.equal(false);
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
test('rejects when the input has no usable TabSectionSet', () =>
|
|
99
|
+
{
|
|
100
|
+
const tmpProvider = buildProvider();
|
|
101
|
+
Expect(tmpProvider.isTabInSet(undefined, 'SectionOne')).to.equal(false);
|
|
102
|
+
Expect(tmpProvider.isTabInSet({ PictForm: {} }, 'SectionOne')).to.equal(false);
|
|
103
|
+
Expect(tmpProvider.isTabInSet({ PictForm: { TabSectionSet: 'SectionOne' } }, 'SectionOne')).to.equal(false);
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
suite('selectTabByViewHash', () =>
|
|
108
|
+
{
|
|
109
|
+
test('selects a hash that is in the set and stores it', () =>
|
|
110
|
+
{
|
|
111
|
+
const tmpInput = buildInput();
|
|
112
|
+
const tmpProvider = buildProvider(tmpInput);
|
|
113
|
+
Expect(tmpProvider.selectTabByViewHash('NavigationView', 'TabInput', 'SectionTwo')).to.equal(true);
|
|
114
|
+
Expect(shownSection(tmpProvider)).to.equal('#Pict-MC-SectionTwo-Wrap');
|
|
115
|
+
Expect(tmpProvider.written).to.deep.equal([ 'SectionTwo' ]);
|
|
116
|
+
Expect(tmpProvider.warnings).to.deep.equal([]);
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
test('refuses a real section that is not one of the tabs and changes nothing', () =>
|
|
120
|
+
{
|
|
121
|
+
const tmpInput = buildInput();
|
|
122
|
+
const tmpProvider = buildProvider(tmpInput);
|
|
123
|
+
Expect(tmpProvider.selectTabByViewHash('NavigationView', 'TabInput', 'Navigation')).to.equal(false);
|
|
124
|
+
Expect(tmpProvider.added).to.deep.equal([]);
|
|
125
|
+
Expect(tmpProvider.removed).to.deep.equal([]);
|
|
126
|
+
Expect(tmpProvider.written).to.deep.equal([]);
|
|
127
|
+
Expect(tmpProvider.warnings.length).to.equal(1);
|
|
128
|
+
Expect(tmpProvider.warnings[0]).to.contain('Navigation');
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
test('refuses when TabSectionSet is empty', () =>
|
|
132
|
+
{
|
|
133
|
+
const tmpInput = buildInput({ TabSectionSet: [] });
|
|
134
|
+
const tmpProvider = buildProvider(tmpInput);
|
|
135
|
+
Expect(tmpProvider.selectTabByViewHash('NavigationView', 'TabInput', 'SectionOne')).to.equal(false);
|
|
136
|
+
Expect(tmpProvider.written).to.deep.equal([]);
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
suite('onInputInitialize tab precedence', () =>
|
|
141
|
+
{
|
|
142
|
+
test('uses the stored value when it is in the set', () =>
|
|
143
|
+
{
|
|
144
|
+
const tmpInput = buildInput({ DefaultTabSectionHash: 'SectionOne' });
|
|
145
|
+
const tmpProvider = buildProvider(tmpInput);
|
|
146
|
+
tmpProvider.onInputInitialize(tmpProvider.view, {}, {}, tmpInput, 'SectionTwo', '#SEL', 'TXN');
|
|
147
|
+
Expect(tmpProvider.written).to.deep.equal([ 'SectionTwo' ]);
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
test('skips a stored section dropped from the manifest and uses DefaultTabSectionHash', () =>
|
|
151
|
+
{
|
|
152
|
+
const tmpInput = buildInput({ DefaultTabSectionHash: 'SectionTwo' });
|
|
153
|
+
const tmpProvider = buildProvider(tmpInput);
|
|
154
|
+
tmpProvider.onInputInitialize(tmpProvider.view, {}, {}, tmpInput, 'SectionDroppedLastRelease', '#SEL', 'TXN');
|
|
155
|
+
Expect(shownSection(tmpProvider)).to.equal('#Pict-MC-SectionTwo-Wrap');
|
|
156
|
+
Expect(tmpProvider.written).to.deep.equal([ 'SectionTwo' ]);
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
test('skips a stored value naming a section that is not a tab and uses the first tab', () =>
|
|
160
|
+
{
|
|
161
|
+
const tmpInput = buildInput();
|
|
162
|
+
const tmpProvider = buildProvider(tmpInput);
|
|
163
|
+
tmpProvider.onInputInitialize(tmpProvider.view, {}, {}, tmpInput, 'Navigation', '#SEL', 'TXN');
|
|
164
|
+
Expect(shownSection(tmpProvider)).to.equal('#Pict-MC-SectionOne-Wrap');
|
|
165
|
+
Expect(tmpProvider.written).to.deep.equal([ 'SectionOne' ]);
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
test('skips a typo in DefaultTabSectionHash and uses the first tab', () =>
|
|
169
|
+
{
|
|
170
|
+
const tmpInput = buildInput({ DefaultTabSectionHash: 'SectoinTwo' });
|
|
171
|
+
const tmpProvider = buildProvider(tmpInput);
|
|
172
|
+
tmpProvider.onInputInitialize(tmpProvider.view, {}, {}, tmpInput, '', '#SEL', 'TXN');
|
|
173
|
+
Expect(shownSection(tmpProvider)).to.equal('#Pict-MC-SectionOne-Wrap');
|
|
174
|
+
Expect(tmpProvider.written).to.deep.equal([ 'SectionOne' ]);
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
test('DefaultFromData false still ignores the stored value', () =>
|
|
178
|
+
{
|
|
179
|
+
const tmpInput = buildInput({ DefaultFromData: false, DefaultTabSectionHash: 'SectionTwo' });
|
|
180
|
+
const tmpProvider = buildProvider(tmpInput);
|
|
181
|
+
tmpProvider.onInputInitialize(tmpProvider.view, {}, {}, tmpInput, 'SectionOne', '#SEL', 'TXN');
|
|
182
|
+
Expect(tmpProvider.written).to.deep.equal([ 'SectionTwo' ]);
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
test('errors out unchanged when TabSectionSet is missing', () =>
|
|
186
|
+
{
|
|
187
|
+
const tmpInput = { Hash: 'TabInput', Macro: { RawHTMLID: 'RAW1' }, PictForm: {} };
|
|
188
|
+
const tmpProvider = buildProvider(tmpInput);
|
|
189
|
+
Expect(tmpProvider.onInputInitialize(tmpProvider.view, {}, {}, tmpInput, 'SectionOne', '#SEL', 'TXN')).to.equal(false);
|
|
190
|
+
Expect(tmpProvider.written).to.deep.equal([]);
|
|
191
|
+
});
|
|
192
|
+
});
|
|
193
|
+
});
|