@legalplace/wizardx-core 4.42.10-nightly.20251125120616 → 4.42.11
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/README.md +1 -376
- package/dist/App.d.ts +6 -1
- package/dist/App.js +7 -2
- package/dist/App.test.js +37 -0
- package/dist/Loader.d.ts +1 -1
- package/dist/Loader.js +1 -1
- package/dist/PluginLoader.d.ts +36 -21
- package/dist/PluginLoader.js +227 -90
- package/dist/PluginLoader.test.d.ts +1 -0
- package/dist/PluginLoader.test.js +52 -0
- package/dist/Shimmer.d.ts +11 -8
- package/dist/Shimmer.js +4 -4
- package/dist/ThemeLoader.d.ts +8 -8
- package/dist/ThemeLoader.test.d.ts +2 -0
- package/dist/ThemeLoader.test.js +65 -0
- package/dist/components/PluginRoute.d.ts +2 -2
- package/dist/components/PluginRoute.js +4 -3
- package/dist/components/SmartScript.d.ts +6 -2
- package/dist/components/SmartScript.js +1 -1
- package/dist/components/UserLocked/UserLockedComponent.js +2 -2
- package/dist/components/View.d.ts +3 -3
- package/dist/components/View.js +7 -5
- package/dist/components/View.test.d.ts +2 -0
- package/dist/components/View.test.js +84 -0
- package/dist/componentsConnectors/connectBox.d.ts +6 -4
- package/dist/componentsConnectors/connectBox.test.d.ts +1 -0
- package/dist/componentsConnectors/connectBox.test.js +218 -0
- package/dist/componentsConnectors/connectDocument.d.ts +6 -4
- package/dist/componentsConnectors/connectDocument.test.d.ts +1 -0
- package/dist/componentsConnectors/connectDocument.test.js +95 -0
- package/dist/componentsConnectors/connectHeader.d.ts +6 -4
- package/dist/componentsConnectors/connectMetaTitle.d.ts +7 -3
- package/dist/componentsConnectors/connectMetaTitle.test.d.ts +1 -0
- package/dist/componentsConnectors/connectMetaTitle.test.js +32 -0
- package/dist/componentsConnectors/connectOption.d.ts +7 -5
- package/dist/componentsConnectors/connectPagination.d.ts +7 -5
- package/dist/componentsConnectors/connectPreview.d.ts +7 -3
- package/dist/componentsConnectors/connectProgress.d.ts +6 -4
- package/dist/componentsConnectors/connectRootOption.d.ts +7 -5
- package/dist/componentsConnectors/connectSection.d.ts +6 -4
- package/dist/componentsConnectors/connectSummary.d.ts +9 -5
- package/dist/componentsConnectors/connectSummaryItem.d.ts +6 -4
- package/dist/componentsConnectors/connectTermsheet.js +1 -1
- package/dist/componentsConnectors/connectVariable.d.ts +8 -6
- package/dist/componentsConnectors/connectWizardWrapper.d.ts +6 -4
- package/dist/componentsConnectors/connector/componentConnector.d.ts +10 -7
- package/dist/componentsConnectors/connector/componentConnector.js +3 -3
- package/dist/componentsConnectors/library.d.ts +81 -47
- package/dist/config.test.d.ts +1 -0
- package/dist/config.test.js +54 -0
- package/dist/helpers/activitiesHelper.d.ts +3 -3
- package/dist/helpers/autocomplete.helper.d.ts +2 -2
- package/dist/helpers/autocomplete.helper.js +1 -1
- package/dist/helpers/autosave.helper.d.ts +13 -3
- package/dist/helpers/autosave.helper.js +70 -3
- package/dist/helpers/inpiCitiesHelper.js +1 -1
- package/dist/helpers/outputsParsing.d.ts +9 -9
- package/dist/hooks/useDispatch.d.ts +1 -1
- package/dist/hooks/usePrevious.js +1 -1
- package/dist/index.d.ts +0 -3
- package/dist/index.js +0 -3
- package/dist/libs/ConditionsRunner.d.ts +1 -1
- package/dist/libs/Formatter/FormatAddress.d.ts +1 -1
- package/dist/libs/InputsInitiator.d.ts +1 -1
- package/dist/libs/NumAuto.test.d.ts +1 -0
- package/dist/libs/NumAuto.test.js +43 -0
- package/dist/libs/PathReader.d.ts +1 -96
- package/dist/libs/PathReader.js +2 -1
- package/dist/libs/SectionValidity.test.d.ts +1 -0
- package/dist/libs/SectionValidity.test.js +116 -0
- package/dist/libs/SmartScriptStore.d.ts +6 -6
- package/dist/redux/actions/app.d.ts +1 -1
- package/dist/redux/actions/app.test.d.ts +1 -0
- package/dist/redux/actions/app.test.js +90 -0
- package/dist/redux/actions/conditions.test.d.ts +1 -0
- package/dist/redux/actions/conditions.test.js +68 -0
- package/dist/redux/actions/inputs.d.ts +1 -1
- package/dist/redux/actions/inputs.test.d.ts +1 -0
- package/dist/redux/actions/inputs.test.js +53 -0
- package/dist/redux/actions/library.d.ts +21 -15
- package/dist/redux/actions/references.d.ts +2 -2
- package/dist/redux/actions/references.test.d.ts +1 -0
- package/dist/redux/actions/references.test.js +43 -0
- package/dist/redux/actions/sagas/data.d.ts +1 -1
- package/dist/redux/actions/sagas/data.test.d.ts +1 -0
- package/dist/redux/actions/sagas/data.test.js +11 -0
- package/dist/redux/actions/sagas/model.test.d.ts +1 -0
- package/dist/redux/actions/sagas/model.test.js +11 -0
- package/dist/redux/actions/sagas/user.d.ts +1 -1
- package/dist/redux/actions/user.test.d.ts +1 -0
- package/dist/redux/actions/user.test.js +16 -0
- package/dist/redux/listeners/subscriber.d.ts +1 -1
- package/dist/redux/listeners/subscriber.test.d.ts +1 -0
- package/dist/redux/listeners/subscriber.test.js +31 -0
- package/dist/redux/middlewares/conditionsWatcherMiddleware.d.ts +1 -1
- package/dist/redux/middlewares/conditionsWatcherMiddleware.test.d.ts +1 -0
- package/dist/redux/middlewares/conditionsWatcherMiddleware.test.js +330 -0
- package/dist/redux/middlewares/evaluationsWatcherMiddleware.d.ts +1 -1
- package/dist/redux/middlewares/evaluationsWatcherMiddleware.test.d.ts +1 -0
- package/dist/redux/middlewares/evaluationsWatcherMiddleware.test.js +242 -0
- package/dist/redux/middlewares/mandatoriesWatcherMiddleware.d.ts +1 -1
- package/dist/redux/middlewares/multiplesActionsMiddleware.d.ts +1 -1
- package/dist/redux/middlewares/multiplesActionsMiddleware.test.d.ts +1 -0
- package/dist/redux/middlewares/multiplesActionsMiddleware.test.js +209 -0
- package/dist/redux/middlewares/paginationWatcherMiddleware.d.ts +2 -2
- package/dist/redux/middlewares/pluginsHookMiddleware.d.ts +2 -1
- package/dist/redux/middlewares/pluginsHookMiddleware.js +7 -1
- package/dist/redux/middlewares/prefillerWatcherMiddleware.d.ts +1 -1
- package/dist/redux/middlewares/prefillerWatcherMiddleware.test.d.ts +1 -0
- package/dist/redux/middlewares/prefillerWatcherMiddleware.test.js +84 -0
- package/dist/redux/middlewares/smartscriptMiddleware.d.ts +1 -1
- package/dist/redux/middlewares/smartscriptMiddleware.js +2 -2
- package/dist/redux/middlewares/thirdpartyScriptsMiddleware.d.ts +1 -1
- package/dist/redux/reducers/app/instance.test.d.ts +1 -0
- package/dist/redux/reducers/app/instance.test.js +75 -0
- package/dist/redux/reducers/app/meta.test.d.ts +1 -0
- package/dist/redux/reducers/app/meta.test.js +70 -0
- package/dist/redux/reducers/app/pagination/updateAvailableAppStates.js +2 -1
- package/dist/redux/reducers/app/pagination.test.d.ts +1 -0
- package/dist/redux/reducers/app/pagination.test.js +134 -0
- package/dist/redux/reducers/app/wizard.test.d.ts +1 -0
- package/dist/redux/reducers/app/wizard.test.js +53 -0
- package/dist/redux/reducers/app.d.ts +6 -6
- package/dist/redux/reducers/app.test.d.ts +1 -0
- package/dist/redux/reducers/app.test.js +175 -0
- package/dist/redux/reducers/conditions/addMultipleOccurency.test.d.ts +1 -0
- package/dist/redux/reducers/conditions/addMultipleOccurency.test.js +108 -0
- package/dist/redux/reducers/conditions/deleteMultipleOccurency.test.d.ts +1 -0
- package/dist/redux/reducers/conditions/deleteMultipleOccurency.test.js +77 -0
- package/dist/redux/reducers/conditions/updateDocumentConditions.test.d.ts +1 -0
- package/dist/redux/reducers/conditions/updateDocumentConditions.test.js +35 -0
- package/dist/redux/reducers/conditions/updateOptionValidatorCondition.test.d.ts +1 -0
- package/dist/redux/reducers/conditions/updateOptionValidatorCondition.test.js +35 -0
- package/dist/redux/reducers/conditions/updateVariableValidatorCondition.test.d.ts +1 -0
- package/dist/redux/reducers/conditions/updateVariableValidatorCondition.test.js +35 -0
- package/dist/redux/reducers/conditions.test.d.ts +1 -0
- package/dist/redux/reducers/conditions.test.js +196 -0
- package/dist/redux/reducers/inputs/addMultipleOccurency.test.d.ts +1 -0
- package/dist/redux/reducers/inputs/addMultipleOccurency.test.js +101 -0
- package/dist/redux/reducers/inputs/deleteMultipleOccurency.test.d.ts +1 -0
- package/dist/redux/reducers/inputs/deleteMultipleOccurency.test.js +56 -0
- package/dist/redux/reducers/inputs.test.d.ts +1 -0
- package/dist/redux/reducers/inputs.test.js +171 -0
- package/dist/redux/reducers/references.js +0 -2
- package/dist/redux/reducers/user.test.d.ts +1 -0
- package/dist/redux/reducers/user.test.js +42 -0
- package/dist/redux/routerHistore.test.d.ts +1 -0
- package/dist/redux/routerHistore.test.js +15 -0
- package/dist/redux/sagas/fetchModel.test.d.ts +1 -0
- package/dist/redux/sagas/fetchModel.test.js +127 -0
- package/dist/redux/sagas/runner.test.d.ts +1 -0
- package/dist/redux/sagas/runner.test.js +10 -0
- package/dist/redux/sagas/saveData.test.d.ts +1 -0
- package/dist/redux/sagas/saveData.test.js +74 -0
- package/dist/redux/sagas/setDefaults.test.d.ts +1 -0
- package/dist/redux/sagas/setDefaults.test.js +73 -0
- package/dist/redux/selectors/app.test.d.ts +1 -0
- package/dist/redux/selectors/app.test.js +99 -0
- package/dist/redux/selectors/conditions.test.d.ts +1 -0
- package/dist/redux/selectors/conditions.test.js +70 -0
- package/dist/redux/selectors/inputs.d.ts +1 -1
- package/dist/redux/selectors/inputs.test.d.ts +1 -0
- package/dist/redux/selectors/inputs.test.js +44 -0
- package/dist/redux/selectors/references.test.d.ts +1 -0
- package/dist/redux/selectors/references.test.js +471 -0
- package/dist/redux/selectors/selectors.d.ts +4 -4
- package/dist/redux/selectors/selectors.test.d.ts +1 -0
- package/dist/redux/selectors/selectors.test.js +16 -0
- package/dist/redux/selectors/user.test.d.ts +1 -0
- package/dist/redux/selectors/user.test.js +29 -0
- package/dist/redux/store.d.ts +3 -5
- package/dist/redux/store.js +1 -2
- package/dist/redux/store.test.d.ts +1 -0
- package/dist/redux/store.test.js +16 -0
- package/dist/service/api.manager.d.ts +2 -2
- package/dist/service/autocomplete.manager.d.ts +3 -3
- package/dist/service/autocomplete.manager.js +3 -3
- package/dist/tests-misc/plugins/jestTestPlugin/after.js +1 -1
- package/dist/tests-misc/plugins/jestTestPlugin/before.js +1 -1
- package/dist/tests-misc/plugins/jestTestPlugin/title.js +1 -1
- package/dist/tests-misc/themes/jestTestTheme/components/EmailComponent.d.ts +1 -1
- package/dist/tests-misc/themes/jestTestTheme/components/EmailComponent.js +1 -1
- package/dist/tests-misc/themes/jestTestTheme/components/TermsheetComponent.d.ts +1 -1
- package/dist/tests-misc/themes/jestTestTheme/components/TermsheetComponent.js +1 -1
- package/dist/tests-misc/themes/jestTestTheme/components/WizardComponent.d.ts +1 -1
- package/dist/tests-misc/themes/jestTestTheme/components/WizardComponent.js +1 -1
- package/dist/types/Actions.type.d.ts +6 -70
- package/dist/types/Components.type.d.ts +2 -3
- package/dist/types/PluginConfig.type.d.ts +52 -18
- package/dist/types/State.type.d.ts +2 -2
- package/dist/types/config.type.d.ts +1 -1
- package/dist/types/getActions.type.d.ts +1 -1
- package/dist/types/getConnectors.type.d.ts +2 -2
- package/dist/types/getSelectors.type.d.ts +1 -1
- package/package.json +22 -45
- package/dist/WizardCore.d.ts +0 -29
- package/dist/WizardCore.js +0 -153
- package/dist/app.entry.d.ts +0 -2
- package/dist/app.entry.js +0 -1
- package/dist/routing/adapters/nextjs.adapter.d.ts +0 -3
- package/dist/routing/adapters/nextjs.adapter.js +0 -61
- package/dist/routing/adapters/reactRouter.adapter.d.ts +0 -2
- package/dist/routing/adapters/reactRouter.adapter.js +0 -16
- package/dist/routing/context.d.ts +0 -14
- package/dist/routing/context.js +0 -23
- package/dist/routing/index.d.ts +0 -4
- package/dist/routing/index.js +0 -4
- package/dist/routing/types.d.ts +0 -26
- package/dist/wizardcore.entry.d.ts +0 -3
- package/dist/wizardcore.entry.js +0 -2
- /package/dist/{routing/types.js → App.test.d.ts} +0 -0
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
import evaluationsWatcherMiddleware from './evaluationsWatcherMiddleware';
|
|
2
|
+
import { updateVariableAction, updateOptionAction } from '../actions/inputs';
|
|
3
|
+
import { fetchModelSucceededAction } from '../actions/app';
|
|
4
|
+
import { updateOptionConditionsAction, updateVariableConditionsAction, } from '../actions/conditions';
|
|
5
|
+
let mockState = {
|
|
6
|
+
inputs: {
|
|
7
|
+
variables: {
|
|
8
|
+
4: [32],
|
|
9
|
+
5: [67],
|
|
10
|
+
6: [''],
|
|
11
|
+
7: [22],
|
|
12
|
+
},
|
|
13
|
+
options: {
|
|
14
|
+
10: [false],
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
references: {
|
|
18
|
+
variables: {
|
|
19
|
+
'6': {
|
|
20
|
+
id: 6,
|
|
21
|
+
label: 'A+B',
|
|
22
|
+
type: 'eval',
|
|
23
|
+
placeholderLength: 16,
|
|
24
|
+
step: '*',
|
|
25
|
+
eval: {
|
|
26
|
+
formula: '[var:4]+[var:5]+[var:7]',
|
|
27
|
+
decimals: 0,
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
'8': {
|
|
31
|
+
id: 8,
|
|
32
|
+
label: 'TODAY',
|
|
33
|
+
type: 'eval',
|
|
34
|
+
placeholderLength: 16,
|
|
35
|
+
step: '*',
|
|
36
|
+
eval: {
|
|
37
|
+
formula: 'AFFICHER_DATE(TODAY())',
|
|
38
|
+
decimals: 0,
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
relations: {
|
|
43
|
+
options: {
|
|
44
|
+
'4': {
|
|
45
|
+
options: [7, 8],
|
|
46
|
+
variables: [2],
|
|
47
|
+
sections: {},
|
|
48
|
+
documents: [],
|
|
49
|
+
prefillers: [3],
|
|
50
|
+
validators: {
|
|
51
|
+
options: [],
|
|
52
|
+
variables: [],
|
|
53
|
+
},
|
|
54
|
+
parents: [2],
|
|
55
|
+
children: {
|
|
56
|
+
options: [],
|
|
57
|
+
variables: [],
|
|
58
|
+
},
|
|
59
|
+
dependants: [],
|
|
60
|
+
radioSiblings: [3],
|
|
61
|
+
},
|
|
62
|
+
'8': {
|
|
63
|
+
options: [],
|
|
64
|
+
variables: [],
|
|
65
|
+
sections: {},
|
|
66
|
+
documents: [],
|
|
67
|
+
prefillers: [],
|
|
68
|
+
validators: {
|
|
69
|
+
options: [],
|
|
70
|
+
variables: [],
|
|
71
|
+
},
|
|
72
|
+
parents: [6],
|
|
73
|
+
children: {
|
|
74
|
+
options: [],
|
|
75
|
+
variables: [],
|
|
76
|
+
},
|
|
77
|
+
dependants: [],
|
|
78
|
+
},
|
|
79
|
+
'10': {
|
|
80
|
+
options: [],
|
|
81
|
+
variables: [],
|
|
82
|
+
sections: {},
|
|
83
|
+
documents: [],
|
|
84
|
+
prefillers: [],
|
|
85
|
+
validators: {
|
|
86
|
+
options: [],
|
|
87
|
+
variables: [],
|
|
88
|
+
},
|
|
89
|
+
parents: [9],
|
|
90
|
+
children: {
|
|
91
|
+
options: [],
|
|
92
|
+
variables: [7],
|
|
93
|
+
},
|
|
94
|
+
dependants: [],
|
|
95
|
+
radioSiblings: [11],
|
|
96
|
+
},
|
|
97
|
+
'11': {
|
|
98
|
+
options: [],
|
|
99
|
+
variables: [],
|
|
100
|
+
sections: {},
|
|
101
|
+
documents: [],
|
|
102
|
+
prefillers: [],
|
|
103
|
+
validators: {
|
|
104
|
+
options: [],
|
|
105
|
+
variables: [],
|
|
106
|
+
},
|
|
107
|
+
parents: [9],
|
|
108
|
+
children: {
|
|
109
|
+
options: [],
|
|
110
|
+
variables: [],
|
|
111
|
+
},
|
|
112
|
+
dependants: [],
|
|
113
|
+
radioSiblings: [10],
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
evaluations: {
|
|
118
|
+
4: [6],
|
|
119
|
+
5: [6],
|
|
120
|
+
7: [6],
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
};
|
|
124
|
+
const originalState = JSON.stringify(mockState);
|
|
125
|
+
const mpi = {
|
|
126
|
+
dispatch: jest.fn(),
|
|
127
|
+
getState: () => mockState,
|
|
128
|
+
};
|
|
129
|
+
const next = jest.fn();
|
|
130
|
+
jest.mock('../selectors/references', () => ({
|
|
131
|
+
__esModule: true,
|
|
132
|
+
selectVariableReference: (id) => mockState.references.variables[id],
|
|
133
|
+
selectOptionRelations: (id) => mockState.references.relations.options[id],
|
|
134
|
+
}));
|
|
135
|
+
jest.mock('../../libs/EvalVariable', () => {
|
|
136
|
+
class EvalVariable {
|
|
137
|
+
constructor(ref, index) {
|
|
138
|
+
var _a;
|
|
139
|
+
if (ref.id === 8 && ((_a = ref.eval) === null || _a === void 0 ? void 0 : _a.formula) === 'AFFICHER_DATE(TODAY())')
|
|
140
|
+
this.result = '01/01/1976';
|
|
141
|
+
else if (ref.id === 6 && mockState.inputs.options[10][index] === true)
|
|
142
|
+
this.result =
|
|
143
|
+
mockState.inputs.variables[4][index] +
|
|
144
|
+
mockState.inputs.variables[5][index] +
|
|
145
|
+
mockState.inputs.variables[7][index];
|
|
146
|
+
else if (ref.id === 6 && mockState.inputs.options[10][index] === false)
|
|
147
|
+
this.result =
|
|
148
|
+
mockState.inputs.variables[4][index] +
|
|
149
|
+
mockState.inputs.variables[5][index];
|
|
150
|
+
else
|
|
151
|
+
this.result = 'UNDEFINED RESULT PLEASE CHECK MOCK';
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return {
|
|
155
|
+
__esModule: true,
|
|
156
|
+
EvalVariable,
|
|
157
|
+
};
|
|
158
|
+
});
|
|
159
|
+
describe('Prefillers Watcher Middleware Test suit', () => {
|
|
160
|
+
beforeEach(() => {
|
|
161
|
+
jest.clearAllMocks();
|
|
162
|
+
mockState = JSON.parse(originalState);
|
|
163
|
+
});
|
|
164
|
+
it('Completes FETCH_MODEL_SUCCEEDED action correctly', () => {
|
|
165
|
+
evaluationsWatcherMiddleware(mpi)(next)(fetchModelSucceededAction());
|
|
166
|
+
expect(mpi.dispatch.mock.calls.length).toBe(2);
|
|
167
|
+
expect(mpi.dispatch.mock.calls[0][0]).toStrictEqual({
|
|
168
|
+
type: 'UPDATE_VARIABLE_INPUT',
|
|
169
|
+
id: 6,
|
|
170
|
+
index: 0,
|
|
171
|
+
value: 99,
|
|
172
|
+
});
|
|
173
|
+
expect(mpi.dispatch.mock.calls[1][0]).toStrictEqual({
|
|
174
|
+
type: 'UPDATE_VARIABLE_INPUT',
|
|
175
|
+
id: 8,
|
|
176
|
+
index: 0,
|
|
177
|
+
value: '01/01/1976',
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
it('Completes UPDATE_VARIABLE_INPUT action correctly', () => {
|
|
181
|
+
evaluationsWatcherMiddleware(mpi)(next)(updateVariableAction(4, 3, 0));
|
|
182
|
+
expect(mpi.dispatch.mock.calls.length).toBe(1);
|
|
183
|
+
expect(mpi.dispatch.mock.calls[0][0]).toStrictEqual({
|
|
184
|
+
type: 'UPDATE_VARIABLE_INPUT',
|
|
185
|
+
id: 6,
|
|
186
|
+
index: 0,
|
|
187
|
+
value: 99,
|
|
188
|
+
});
|
|
189
|
+
});
|
|
190
|
+
it('Completes UPDATE_OPTION_INPUT action correctly', () => {
|
|
191
|
+
mockState.inputs.options[10][0] = true;
|
|
192
|
+
evaluationsWatcherMiddleware(mpi)(next)(updateOptionAction(10, true, 0));
|
|
193
|
+
expect(mpi.dispatch.mock.calls.length).toBe(1);
|
|
194
|
+
expect(mpi.dispatch.mock.calls[0][0]).toStrictEqual({
|
|
195
|
+
type: 'UPDATE_VARIABLE_INPUT',
|
|
196
|
+
id: 6,
|
|
197
|
+
index: 0,
|
|
198
|
+
value: 121,
|
|
199
|
+
});
|
|
200
|
+
});
|
|
201
|
+
it('Completes UPDATE_OPTION_CONDITION action correctly', () => {
|
|
202
|
+
mockState.inputs.options[10][0] = true;
|
|
203
|
+
evaluationsWatcherMiddleware(mpi)(next)(updateOptionConditionsAction(10, 0, true));
|
|
204
|
+
expect(mpi.dispatch.mock.calls.length).toBe(1);
|
|
205
|
+
expect(mpi.dispatch.mock.calls[0][0]).toStrictEqual({
|
|
206
|
+
type: 'UPDATE_VARIABLE_INPUT',
|
|
207
|
+
id: 6,
|
|
208
|
+
index: 0,
|
|
209
|
+
value: 121,
|
|
210
|
+
});
|
|
211
|
+
});
|
|
212
|
+
it('Completes UPDATE_OPTION_CONDITION action correctly', () => {
|
|
213
|
+
mockState.inputs.options[10][0] = false;
|
|
214
|
+
evaluationsWatcherMiddleware(mpi)(next)(updateOptionConditionsAction(10, 0, true));
|
|
215
|
+
expect(mpi.dispatch.mock.calls.length).toBe(1);
|
|
216
|
+
expect(mpi.dispatch.mock.calls[0][0]).toStrictEqual({
|
|
217
|
+
type: 'UPDATE_VARIABLE_INPUT',
|
|
218
|
+
id: 6,
|
|
219
|
+
index: 0,
|
|
220
|
+
value: 99,
|
|
221
|
+
});
|
|
222
|
+
});
|
|
223
|
+
it('Completes UPDATE_VARIABLE_CONDITION action correctly', () => {
|
|
224
|
+
mockState.inputs.options[10][0] = true;
|
|
225
|
+
evaluationsWatcherMiddleware(mpi)(next)(updateVariableConditionsAction(7, 0, true));
|
|
226
|
+
expect(mpi.dispatch.mock.calls.length).toBe(1);
|
|
227
|
+
expect(mpi.dispatch.mock.calls[0][0]).toStrictEqual({
|
|
228
|
+
type: 'UPDATE_VARIABLE_INPUT',
|
|
229
|
+
id: 6,
|
|
230
|
+
index: 0,
|
|
231
|
+
value: 121,
|
|
232
|
+
});
|
|
233
|
+
});
|
|
234
|
+
it('Throws an error on UPDATE_VARIABLE_INPUT action if variable is undefined', () => {
|
|
235
|
+
mockState.references.variables[6] = undefined;
|
|
236
|
+
expect(() => evaluationsWatcherMiddleware(mpi)(next)(updateVariableAction(4, 3, 0))).toThrowError('Variable 6 does not exist');
|
|
237
|
+
});
|
|
238
|
+
it('Throws an error on UPDATE_OPTION_INPUT action if variable is undefined', () => {
|
|
239
|
+
mockState.references.variables[6] = undefined;
|
|
240
|
+
expect(() => evaluationsWatcherMiddleware(mpi)(next)(updateOptionAction(10, true, 0))).toThrowError('Variable 6 does not exist');
|
|
241
|
+
});
|
|
242
|
+
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Dispatch, MiddlewareAPI } from "redux";
|
|
2
2
|
import type { ActionsType } from "../../types/Actions.type";
|
|
3
|
-
export type WatcherActions = ActionsType.Inputs.updateOptionInput | ActionsType.Inputs.updateVariableInput | ActionsType.Inputs.addMultipleOccurency | ActionsType.Inputs.deleteMultipleOccurency | ActionsType.Mandatories.setMandatoryOption | ActionsType.Mandatories.setMandatoryVariable;
|
|
3
|
+
export declare type WatcherActions = ActionsType.Inputs.updateOptionInput | ActionsType.Inputs.updateVariableInput | ActionsType.Inputs.addMultipleOccurency | ActionsType.Inputs.deleteMultipleOccurency | ActionsType.Mandatories.setMandatoryOption | ActionsType.Mandatories.setMandatoryVariable;
|
|
4
4
|
declare const mandatoriesWatcherMiddleware: (mpi: MiddlewareAPI) => (next: Dispatch) => (action: WatcherActions) => void | WatcherActions;
|
|
5
5
|
export default mandatoriesWatcherMiddleware;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { MiddlewareAPI, Dispatch } from "redux";
|
|
2
2
|
import type { ActionsType } from "../../types/Actions.type";
|
|
3
|
-
export type WatcherActions = ActionsType.Inputs.addMultipleOccurency | ActionsType.Inputs.deleteMultipleOccurency;
|
|
3
|
+
export declare type WatcherActions = ActionsType.Inputs.addMultipleOccurency | ActionsType.Inputs.deleteMultipleOccurency;
|
|
4
4
|
declare const multiplesActionsMiddleware: (mpi: MiddlewareAPI) => (next: Dispatch) => (action: WatcherActions) => void | WatcherActions;
|
|
5
5
|
export default multiplesActionsMiddleware;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import multiplesActionsMiddleware from './multiplesActionsMiddleware';
|
|
2
|
+
import { addMultipleOccurencyAction, deleteMultipleOccurencyAction, } from '../actions/inputs';
|
|
3
|
+
const mpi = {
|
|
4
|
+
dispatch: jest.fn(),
|
|
5
|
+
getState: () => ({
|
|
6
|
+
conditions: {
|
|
7
|
+
prefillers: {
|
|
8
|
+
'3': [[false, false, false]],
|
|
9
|
+
},
|
|
10
|
+
},
|
|
11
|
+
}),
|
|
12
|
+
};
|
|
13
|
+
const next = jest.fn();
|
|
14
|
+
const mockVariablesReferences = {
|
|
15
|
+
3: {
|
|
16
|
+
id: 3,
|
|
17
|
+
label: 'Variable',
|
|
18
|
+
type: 'textarea',
|
|
19
|
+
step: '*',
|
|
20
|
+
prefillings: [
|
|
21
|
+
{
|
|
22
|
+
value: 'Option 4 selected',
|
|
23
|
+
conditions: {
|
|
24
|
+
selected: [
|
|
25
|
+
{
|
|
26
|
+
var: 'o.4',
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
value: 'Option 3 selected',
|
|
33
|
+
conditions: {
|
|
34
|
+
selected: [
|
|
35
|
+
{
|
|
36
|
+
var: 'o.3',
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
value: 'Variable 1 = Hello',
|
|
43
|
+
conditions: {
|
|
44
|
+
contains: [
|
|
45
|
+
{
|
|
46
|
+
var: 'v.1',
|
|
47
|
+
},
|
|
48
|
+
'Hello',
|
|
49
|
+
],
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
const mockOptionsRelations = {
|
|
56
|
+
2: {
|
|
57
|
+
options: [],
|
|
58
|
+
variables: [],
|
|
59
|
+
sections: {},
|
|
60
|
+
documents: [],
|
|
61
|
+
prefillers: [],
|
|
62
|
+
validators: {
|
|
63
|
+
options: [],
|
|
64
|
+
variables: [],
|
|
65
|
+
},
|
|
66
|
+
parents: [],
|
|
67
|
+
children: {
|
|
68
|
+
options: [3, 4],
|
|
69
|
+
variables: [2, 3],
|
|
70
|
+
},
|
|
71
|
+
dependants: [7, 8],
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
const mockOptionsReferences = {
|
|
75
|
+
2: {
|
|
76
|
+
meta: {
|
|
77
|
+
id: 2,
|
|
78
|
+
type: 'static',
|
|
79
|
+
label: 'Multiple question',
|
|
80
|
+
step: '*',
|
|
81
|
+
tags: [],
|
|
82
|
+
defaultRadio: 4,
|
|
83
|
+
multiple: {
|
|
84
|
+
enabled: true,
|
|
85
|
+
},
|
|
86
|
+
validator: {},
|
|
87
|
+
},
|
|
88
|
+
options: [3, 4],
|
|
89
|
+
variables: [2, 3],
|
|
90
|
+
},
|
|
91
|
+
3: {
|
|
92
|
+
meta: {
|
|
93
|
+
id: 3,
|
|
94
|
+
type: 'radio',
|
|
95
|
+
label: 'Option 1',
|
|
96
|
+
step: '*',
|
|
97
|
+
tags: [],
|
|
98
|
+
defaultRadio: 0,
|
|
99
|
+
validator: {},
|
|
100
|
+
},
|
|
101
|
+
options: [],
|
|
102
|
+
variables: [],
|
|
103
|
+
},
|
|
104
|
+
4: {
|
|
105
|
+
meta: {
|
|
106
|
+
id: 4,
|
|
107
|
+
type: 'radio',
|
|
108
|
+
label: 'Option 2',
|
|
109
|
+
step: '*',
|
|
110
|
+
tags: [],
|
|
111
|
+
defaultRadio: 0,
|
|
112
|
+
validator: {},
|
|
113
|
+
},
|
|
114
|
+
options: [],
|
|
115
|
+
variables: [],
|
|
116
|
+
},
|
|
117
|
+
7: {
|
|
118
|
+
meta: {
|
|
119
|
+
id: 4,
|
|
120
|
+
type: 'hidden',
|
|
121
|
+
label: 'Option 2',
|
|
122
|
+
step: '*',
|
|
123
|
+
tags: [],
|
|
124
|
+
defaultRadio: 0,
|
|
125
|
+
validator: {},
|
|
126
|
+
},
|
|
127
|
+
options: [],
|
|
128
|
+
variables: [],
|
|
129
|
+
},
|
|
130
|
+
8: {
|
|
131
|
+
meta: {
|
|
132
|
+
id: 4,
|
|
133
|
+
type: 'hidden',
|
|
134
|
+
label: 'Option 2',
|
|
135
|
+
step: '*',
|
|
136
|
+
tags: [],
|
|
137
|
+
defaultRadio: 0,
|
|
138
|
+
validator: {},
|
|
139
|
+
},
|
|
140
|
+
options: [],
|
|
141
|
+
variables: [],
|
|
142
|
+
},
|
|
143
|
+
};
|
|
144
|
+
jest.mock('../selectors/references', () => ({
|
|
145
|
+
__esModule: true,
|
|
146
|
+
selectVariableReference: (id) => mockVariablesReferences[id],
|
|
147
|
+
selectOptionRelations: (id) => mockOptionsRelations[id],
|
|
148
|
+
selectOptionReference: (id) => mockOptionsReferences[id],
|
|
149
|
+
}));
|
|
150
|
+
describe('Prefillers Watcher Middleware Test suit', () => {
|
|
151
|
+
beforeEach(() => {
|
|
152
|
+
jest.clearAllMocks();
|
|
153
|
+
});
|
|
154
|
+
it('Completes ADD_MULTIPLE_OCCURENCY action correctly', () => {
|
|
155
|
+
multiplesActionsMiddleware(mpi)(next)(addMultipleOccurencyAction(2));
|
|
156
|
+
expect(next.mock.calls.length).toBe(1);
|
|
157
|
+
expect(next.mock.calls[0][0]).toStrictEqual({
|
|
158
|
+
type: 'ADD_MULTIPLE_OCCURENCY',
|
|
159
|
+
id: 2,
|
|
160
|
+
optionRelations: mockOptionsRelations[2],
|
|
161
|
+
optionsReferences: mockOptionsReferences,
|
|
162
|
+
prefillersVariables: {
|
|
163
|
+
'3': [
|
|
164
|
+
{
|
|
165
|
+
value: 'Option 4 selected',
|
|
166
|
+
conditions: {
|
|
167
|
+
selected: [
|
|
168
|
+
{
|
|
169
|
+
var: 'o.4',
|
|
170
|
+
},
|
|
171
|
+
],
|
|
172
|
+
},
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
value: 'Option 3 selected',
|
|
176
|
+
conditions: {
|
|
177
|
+
selected: [
|
|
178
|
+
{
|
|
179
|
+
var: 'o.3',
|
|
180
|
+
},
|
|
181
|
+
],
|
|
182
|
+
},
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
value: 'Variable 1 = Hello',
|
|
186
|
+
conditions: {
|
|
187
|
+
contains: [
|
|
188
|
+
{
|
|
189
|
+
var: 'v.1',
|
|
190
|
+
},
|
|
191
|
+
'Hello',
|
|
192
|
+
],
|
|
193
|
+
},
|
|
194
|
+
},
|
|
195
|
+
],
|
|
196
|
+
},
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
it('Completes DELETE_MULTIPLE_OCCURENCY action correctly', () => {
|
|
200
|
+
multiplesActionsMiddleware(mpi)(next)(deleteMultipleOccurencyAction(2, 3));
|
|
201
|
+
expect(next.mock.calls.length).toBe(1);
|
|
202
|
+
expect(next.mock.calls[0][0]).toStrictEqual({
|
|
203
|
+
type: 'DELETE_MULTIPLE_OCCURENCY',
|
|
204
|
+
id: 2,
|
|
205
|
+
index: 3,
|
|
206
|
+
optionRelations: mockOptionsRelations[2],
|
|
207
|
+
});
|
|
208
|
+
});
|
|
209
|
+
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { LocationChangeAction } from "connected-react-router";
|
|
2
2
|
import type { MiddlewareAPI, Dispatch } from "redux";
|
|
3
3
|
import type { ActionsType } from "../../types/Actions.type";
|
|
4
|
-
export type WatcherActions = ActionsType.Conditions.updateSectionCondition | LocationChangeAction;
|
|
5
|
-
declare const paginationWatcherMiddleware: (mpi: MiddlewareAPI) => (next: Dispatch) => (action: WatcherActions) =>
|
|
4
|
+
export declare type WatcherActions = ActionsType.Conditions.updateSectionCondition | LocationChangeAction;
|
|
5
|
+
declare const paginationWatcherMiddleware: (mpi: MiddlewareAPI) => (next: Dispatch) => (action: WatcherActions) => void | WatcherActions;
|
|
6
6
|
export default paginationWatcherMiddleware;
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
+
import { RunActionAnchor, RunOverrideActionAnchor } from "../../PluginLoader";
|
|
1
2
|
const pluginsHookMiddleware = (mpi) => (next) => (action) => {
|
|
2
|
-
|
|
3
|
+
const previousState = mpi.getState();
|
|
4
|
+
const overridenAction = RunOverrideActionAnchor(action);
|
|
5
|
+
const nextResult = next(overridenAction);
|
|
6
|
+
const nextState = mpi.getState();
|
|
7
|
+
RunActionAnchor(action.type, previousState, nextState);
|
|
8
|
+
return nextResult;
|
|
3
9
|
};
|
|
4
10
|
export default pluginsHookMiddleware;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { MiddlewareAPI, Dispatch } from "redux";
|
|
2
2
|
import type { ActionsType } from "../../types/Actions.type";
|
|
3
|
-
export type WatcherActions = ActionsType.Conditions.updatePrefillerCondition;
|
|
3
|
+
export declare type WatcherActions = ActionsType.Conditions.updatePrefillerCondition;
|
|
4
4
|
declare const prefillerWatcherMiddleware: (mpi: MiddlewareAPI) => (next: Dispatch) => (action: WatcherActions) => void | ActionsType.Conditions.updatePrefillerCondition;
|
|
5
5
|
export default prefillerWatcherMiddleware;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import prefillerWatcherMiddleware from './prefillerWatcherMiddleware';
|
|
2
|
+
import { updatePrefillersConditionsAction } from '../actions/conditions';
|
|
3
|
+
const mpi = {
|
|
4
|
+
dispatch: jest.fn(),
|
|
5
|
+
getState: jest.fn(),
|
|
6
|
+
};
|
|
7
|
+
const next = jest.fn();
|
|
8
|
+
const mockVariablesInputs = {
|
|
9
|
+
3: ['Option 4 selected', 'Random text'],
|
|
10
|
+
};
|
|
11
|
+
const mockVariablesReferences = {
|
|
12
|
+
3: {
|
|
13
|
+
id: 3,
|
|
14
|
+
label: 'Variable',
|
|
15
|
+
type: 'textarea',
|
|
16
|
+
step: '*',
|
|
17
|
+
prefillings: [
|
|
18
|
+
{
|
|
19
|
+
value: 'Option 4 selected',
|
|
20
|
+
conditions: {
|
|
21
|
+
selected: [
|
|
22
|
+
{
|
|
23
|
+
var: 'o.4',
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
value: 'Option 3 selected',
|
|
30
|
+
conditions: {
|
|
31
|
+
selected: [
|
|
32
|
+
{
|
|
33
|
+
var: 'o.3',
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
value: 'Variable 1 = Hello',
|
|
40
|
+
conditions: {
|
|
41
|
+
contains: [
|
|
42
|
+
{
|
|
43
|
+
var: 'v.1',
|
|
44
|
+
},
|
|
45
|
+
'Hello',
|
|
46
|
+
],
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
jest.mock('../selectors/inputs', () => ({
|
|
53
|
+
__esModule: true,
|
|
54
|
+
selectVariableInputByIndex: (id, index) => mockVariablesInputs[id][index],
|
|
55
|
+
}));
|
|
56
|
+
jest.mock('../selectors/references', () => ({
|
|
57
|
+
__esModule: true,
|
|
58
|
+
selectVariableReference: (id) => mockVariablesReferences[id],
|
|
59
|
+
}));
|
|
60
|
+
describe('Prefillers Watcher Middleware Test suit', () => {
|
|
61
|
+
beforeEach(() => {
|
|
62
|
+
jest.clearAllMocks();
|
|
63
|
+
});
|
|
64
|
+
it('Updates variables properly if prefillers conditions changed', () => {
|
|
65
|
+
prefillerWatcherMiddleware(mpi)(next)(updatePrefillersConditionsAction(3, 0, [false, false, true]));
|
|
66
|
+
expect(mpi.dispatch.mock.calls[0][0]).toStrictEqual({
|
|
67
|
+
type: 'UPDATE_VARIABLE_INPUT',
|
|
68
|
+
id: 3,
|
|
69
|
+
value: 'Variable 1 = Hello',
|
|
70
|
+
index: 0,
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
it('Should throw an error if variable does not exist', () => {
|
|
74
|
+
expect(() => prefillerWatcherMiddleware(mpi)(next)(updatePrefillersConditionsAction(13243, 0, [true, false, false]))).toThrowError('Variable 13243 does not exist');
|
|
75
|
+
});
|
|
76
|
+
it('Should not send update variable value if value is already equal to the prefiller', () => {
|
|
77
|
+
prefillerWatcherMiddleware(mpi)(next)(updatePrefillersConditionsAction(3, 0, [true, false, false]));
|
|
78
|
+
expect(mpi.dispatch.mock.calls.length).toEqual(0);
|
|
79
|
+
});
|
|
80
|
+
it('Should not send update variable value if value has been changed by user', () => {
|
|
81
|
+
prefillerWatcherMiddleware(mpi)(next)(updatePrefillersConditionsAction(3, 1, [true, true, true]));
|
|
82
|
+
expect(mpi.dispatch.mock.calls.length).toEqual(0);
|
|
83
|
+
});
|
|
84
|
+
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { MiddlewareAPI, Dispatch } from "redux";
|
|
2
2
|
import type { ActionsType } from "../../types/Actions.type";
|
|
3
|
-
export type WatcherActions = ActionsType.SmartScript.enableSmartScript | ActionsType.Inputs.updateOptionInput | ActionsType.Inputs.updateVariableInput;
|
|
3
|
+
export declare type WatcherActions = ActionsType.SmartScript.enableSmartScript | ActionsType.Inputs.updateOptionInput | ActionsType.Inputs.updateVariableInput;
|
|
4
4
|
declare const smartscriptMiddleware: (mpi: MiddlewareAPI) => (next: Dispatch) => (action: WatcherActions) => void | WatcherActions;
|
|
5
5
|
export default smartscriptMiddleware;
|
|
@@ -89,13 +89,13 @@ const watchUpdateOptionInput = (mpi, next, action) => __awaiter(void 0, void 0,
|
|
|
89
89
|
}
|
|
90
90
|
});
|
|
91
91
|
const watchUpdateVariableInput = (mpi, next, action) => __awaiter(void 0, void 0, void 0, function* () {
|
|
92
|
-
var
|
|
92
|
+
var _b;
|
|
93
93
|
next(action);
|
|
94
94
|
const state = mpi.getState();
|
|
95
95
|
const { id } = action;
|
|
96
96
|
if (state.smartscript.triggers.variables.includes(id)) {
|
|
97
97
|
try {
|
|
98
|
-
const actions = yield ((
|
|
98
|
+
const actions = yield ((_b = iframe === null || iframe === void 0 ? void 0 : iframe.contentWindow) === null || _b === void 0 ? void 0 : _b.triggerListeners("variable", id, cloneDeep(state.inputs)));
|
|
99
99
|
if (Array.isArray(actions)) {
|
|
100
100
|
actions.forEach((_action) => {
|
|
101
101
|
mpi.dispatch(_action);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { MiddlewareAPI, Dispatch } from "redux";
|
|
2
2
|
import type { ActionsType } from "../../types/Actions.type";
|
|
3
|
-
export type WatcherActions = ActionsType.App.fetchModelSucceeded;
|
|
3
|
+
export declare type WatcherActions = ActionsType.App.fetchModelSucceeded;
|
|
4
4
|
declare const thirdPartyScriptsMiddleware: (mpi: MiddlewareAPI) => (next: Dispatch) => (action: WatcherActions) => void | ActionsType.App.fetchModelSucceeded;
|
|
5
5
|
export default thirdPartyScriptsMiddleware;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|