@legalplace/wizardx-core 4.42.8 → 4.42.10-nightly.20251125115613
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 +376 -1
- package/dist/App.d.ts +1 -6
- package/dist/App.js +2 -7
- package/dist/Loader.d.ts +1 -1
- package/dist/Loader.js +1 -1
- package/dist/PluginLoader.d.ts +21 -36
- package/dist/PluginLoader.js +90 -227
- package/dist/Shimmer.d.ts +8 -11
- package/dist/Shimmer.js +4 -4
- package/dist/ThemeLoader.d.ts +8 -8
- package/dist/WizardCore.d.ts +25 -0
- package/dist/WizardCore.js +119 -0
- package/dist/app.entry.d.ts +2 -0
- package/dist/app.entry.js +1 -0
- package/dist/components/PluginRoute.d.ts +2 -2
- package/dist/components/PluginRoute.js +3 -4
- package/dist/components/SmartScript.d.ts +2 -6
- 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 +5 -7
- package/dist/componentsConnectors/connectBox.d.ts +4 -6
- package/dist/componentsConnectors/connectDocument.d.ts +4 -6
- package/dist/componentsConnectors/connectHeader.d.ts +4 -6
- package/dist/componentsConnectors/connectMetaTitle.d.ts +3 -7
- package/dist/componentsConnectors/connectOption.d.ts +5 -7
- package/dist/componentsConnectors/connectPagination.d.ts +5 -7
- package/dist/componentsConnectors/connectPreview.d.ts +3 -7
- package/dist/componentsConnectors/connectProgress.d.ts +4 -6
- package/dist/componentsConnectors/connectRootOption.d.ts +5 -7
- package/dist/componentsConnectors/connectSection.d.ts +4 -6
- package/dist/componentsConnectors/connectSummary.d.ts +5 -9
- package/dist/componentsConnectors/connectSummaryItem.d.ts +4 -6
- package/dist/componentsConnectors/connectTermsheet.js +1 -1
- package/dist/componentsConnectors/connectVariable.d.ts +6 -8
- package/dist/componentsConnectors/connectWizardWrapper.d.ts +4 -6
- package/dist/componentsConnectors/connector/componentConnector.d.ts +7 -10
- package/dist/componentsConnectors/connector/componentConnector.js +3 -3
- package/dist/componentsConnectors/library.d.ts +47 -81
- 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 +3 -13
- package/dist/helpers/autosave.helper.js +3 -70
- 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 +3 -0
- package/dist/index.js +3 -0
- 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/PathReader.d.ts +96 -1
- package/dist/libs/PathReader.js +1 -2
- package/dist/libs/SmartScriptStore.d.ts +6 -6
- package/dist/redux/actions/app.d.ts +1 -1
- package/dist/redux/actions/inputs.d.ts +1 -1
- package/dist/redux/actions/library.d.ts +15 -21
- package/dist/redux/actions/references.d.ts +2 -2
- package/dist/redux/actions/sagas/data.d.ts +1 -1
- package/dist/redux/actions/sagas/user.d.ts +1 -1
- package/dist/redux/listeners/subscriber.d.ts +1 -1
- package/dist/redux/middlewares/conditionsWatcherMiddleware.d.ts +1 -1
- package/dist/redux/middlewares/evaluationsWatcherMiddleware.d.ts +1 -1
- package/dist/redux/middlewares/mandatoriesWatcherMiddleware.d.ts +1 -1
- package/dist/redux/middlewares/multiplesActionsMiddleware.d.ts +1 -1
- package/dist/redux/middlewares/paginationWatcherMiddleware.d.ts +2 -2
- package/dist/redux/middlewares/pluginsHookMiddleware.d.ts +1 -2
- package/dist/redux/middlewares/pluginsHookMiddleware.js +1 -7
- package/dist/redux/middlewares/prefillerWatcherMiddleware.d.ts +1 -1
- 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/pagination/updateAvailableAppStates.js +1 -2
- package/dist/redux/reducers/app.d.ts +6 -6
- package/dist/redux/reducers/references.js +2 -0
- package/dist/redux/selectors/inputs.d.ts +1 -1
- package/dist/redux/selectors/selectors.d.ts +4 -4
- package/dist/redux/store.d.ts +2 -2
- package/dist/routing/adapters/nextjs.adapter.d.ts +3 -0
- package/dist/routing/adapters/nextjs.adapter.js +63 -0
- package/dist/routing/adapters/reactRouter.adapter.d.ts +2 -0
- package/dist/routing/adapters/reactRouter.adapter.js +19 -0
- package/dist/routing/context.d.ts +14 -0
- package/dist/routing/context.js +25 -0
- package/dist/routing/index.d.ts +4 -0
- package/dist/routing/index.js +4 -0
- package/dist/routing/types.d.ts +26 -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 +70 -6
- package/dist/types/Components.type.d.ts +3 -2
- package/dist/types/PluginConfig.type.d.ts +18 -52
- 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/dist/wizardcore.entry.d.ts +3 -0
- package/dist/wizardcore.entry.js +2 -0
- package/package.json +45 -22
- package/dist/App.test.js +0 -37
- package/dist/PluginLoader.test.d.ts +0 -1
- package/dist/PluginLoader.test.js +0 -52
- package/dist/ThemeLoader.test.d.ts +0 -2
- package/dist/ThemeLoader.test.js +0 -65
- package/dist/components/View.test.d.ts +0 -2
- package/dist/components/View.test.js +0 -84
- package/dist/componentsConnectors/connectBox.test.d.ts +0 -1
- package/dist/componentsConnectors/connectBox.test.js +0 -218
- package/dist/componentsConnectors/connectDocument.test.d.ts +0 -1
- package/dist/componentsConnectors/connectDocument.test.js +0 -95
- package/dist/componentsConnectors/connectMetaTitle.test.d.ts +0 -1
- package/dist/componentsConnectors/connectMetaTitle.test.js +0 -32
- package/dist/config.test.d.ts +0 -1
- package/dist/config.test.js +0 -54
- package/dist/libs/NumAuto.test.d.ts +0 -1
- package/dist/libs/NumAuto.test.js +0 -43
- package/dist/libs/SectionValidity.test.d.ts +0 -1
- package/dist/libs/SectionValidity.test.js +0 -116
- package/dist/redux/actions/app.test.d.ts +0 -1
- package/dist/redux/actions/app.test.js +0 -90
- package/dist/redux/actions/conditions.test.d.ts +0 -1
- package/dist/redux/actions/conditions.test.js +0 -68
- package/dist/redux/actions/inputs.test.d.ts +0 -1
- package/dist/redux/actions/inputs.test.js +0 -53
- package/dist/redux/actions/references.test.d.ts +0 -1
- package/dist/redux/actions/references.test.js +0 -43
- package/dist/redux/actions/sagas/data.test.d.ts +0 -1
- package/dist/redux/actions/sagas/data.test.js +0 -11
- package/dist/redux/actions/sagas/model.test.d.ts +0 -1
- package/dist/redux/actions/sagas/model.test.js +0 -11
- package/dist/redux/actions/user.test.d.ts +0 -1
- package/dist/redux/actions/user.test.js +0 -16
- package/dist/redux/listeners/subscriber.test.d.ts +0 -1
- package/dist/redux/listeners/subscriber.test.js +0 -31
- package/dist/redux/middlewares/conditionsWatcherMiddleware.test.d.ts +0 -1
- package/dist/redux/middlewares/conditionsWatcherMiddleware.test.js +0 -330
- package/dist/redux/middlewares/evaluationsWatcherMiddleware.test.d.ts +0 -1
- package/dist/redux/middlewares/evaluationsWatcherMiddleware.test.js +0 -242
- package/dist/redux/middlewares/multiplesActionsMiddleware.test.d.ts +0 -1
- package/dist/redux/middlewares/multiplesActionsMiddleware.test.js +0 -209
- package/dist/redux/middlewares/prefillerWatcherMiddleware.test.d.ts +0 -1
- package/dist/redux/middlewares/prefillerWatcherMiddleware.test.js +0 -84
- package/dist/redux/reducers/app/instance.test.d.ts +0 -1
- package/dist/redux/reducers/app/instance.test.js +0 -75
- package/dist/redux/reducers/app/meta.test.d.ts +0 -1
- package/dist/redux/reducers/app/meta.test.js +0 -70
- package/dist/redux/reducers/app/pagination.test.d.ts +0 -1
- package/dist/redux/reducers/app/pagination.test.js +0 -134
- package/dist/redux/reducers/app/wizard.test.d.ts +0 -1
- package/dist/redux/reducers/app/wizard.test.js +0 -53
- package/dist/redux/reducers/app.test.d.ts +0 -1
- package/dist/redux/reducers/app.test.js +0 -175
- package/dist/redux/reducers/conditions/addMultipleOccurency.test.d.ts +0 -1
- package/dist/redux/reducers/conditions/addMultipleOccurency.test.js +0 -108
- package/dist/redux/reducers/conditions/deleteMultipleOccurency.test.d.ts +0 -1
- package/dist/redux/reducers/conditions/deleteMultipleOccurency.test.js +0 -77
- package/dist/redux/reducers/conditions/updateDocumentConditions.test.d.ts +0 -1
- package/dist/redux/reducers/conditions/updateDocumentConditions.test.js +0 -35
- package/dist/redux/reducers/conditions/updateOptionValidatorCondition.test.d.ts +0 -1
- package/dist/redux/reducers/conditions/updateOptionValidatorCondition.test.js +0 -35
- package/dist/redux/reducers/conditions/updateVariableValidatorCondition.test.d.ts +0 -1
- package/dist/redux/reducers/conditions/updateVariableValidatorCondition.test.js +0 -35
- package/dist/redux/reducers/conditions.test.d.ts +0 -1
- package/dist/redux/reducers/conditions.test.js +0 -196
- package/dist/redux/reducers/inputs/addMultipleOccurency.test.d.ts +0 -1
- package/dist/redux/reducers/inputs/addMultipleOccurency.test.js +0 -101
- package/dist/redux/reducers/inputs/deleteMultipleOccurency.test.d.ts +0 -1
- package/dist/redux/reducers/inputs/deleteMultipleOccurency.test.js +0 -56
- package/dist/redux/reducers/inputs.test.d.ts +0 -1
- package/dist/redux/reducers/inputs.test.js +0 -171
- package/dist/redux/reducers/user.test.d.ts +0 -1
- package/dist/redux/reducers/user.test.js +0 -42
- package/dist/redux/routerHistore.test.d.ts +0 -1
- package/dist/redux/routerHistore.test.js +0 -15
- package/dist/redux/sagas/fetchModel.test.d.ts +0 -1
- package/dist/redux/sagas/fetchModel.test.js +0 -127
- package/dist/redux/sagas/runner.test.d.ts +0 -1
- package/dist/redux/sagas/runner.test.js +0 -10
- package/dist/redux/sagas/saveData.test.d.ts +0 -1
- package/dist/redux/sagas/saveData.test.js +0 -74
- package/dist/redux/sagas/setDefaults.test.d.ts +0 -1
- package/dist/redux/sagas/setDefaults.test.js +0 -73
- package/dist/redux/selectors/app.test.d.ts +0 -1
- package/dist/redux/selectors/app.test.js +0 -99
- package/dist/redux/selectors/conditions.test.d.ts +0 -1
- package/dist/redux/selectors/conditions.test.js +0 -70
- package/dist/redux/selectors/inputs.test.d.ts +0 -1
- package/dist/redux/selectors/inputs.test.js +0 -44
- package/dist/redux/selectors/references.test.d.ts +0 -1
- package/dist/redux/selectors/references.test.js +0 -471
- package/dist/redux/selectors/selectors.test.d.ts +0 -1
- package/dist/redux/selectors/selectors.test.js +0 -16
- package/dist/redux/selectors/user.test.d.ts +0 -1
- package/dist/redux/selectors/user.test.js +0 -29
- package/dist/redux/store.test.d.ts +0 -1
- package/dist/redux/store.test.js +0 -16
- /package/dist/{App.test.d.ts → routing/types.js} +0 -0
|
@@ -1,330 +0,0 @@
|
|
|
1
|
-
import conditionsWatcherMiddleware from "./conditionsWatcherMiddleware";
|
|
2
|
-
import { addMultipleOccurencyAction, deleteMultipleOccurencyAction, updateOptionAction, updateVariableAction, } from "../actions/inputs";
|
|
3
|
-
import { initConditionsAction } from "../actions/conditions";
|
|
4
|
-
import { selectorsMiddleware } from "../selectors/selectors";
|
|
5
|
-
const mockInputs = {
|
|
6
|
-
variables: {
|
|
7
|
-
1: ["Hello"],
|
|
8
|
-
2: [],
|
|
9
|
-
3: [],
|
|
10
|
-
},
|
|
11
|
-
options: {
|
|
12
|
-
1: [true],
|
|
13
|
-
2: [true, true],
|
|
14
|
-
3: [true, false],
|
|
15
|
-
4: [false, true],
|
|
16
|
-
7: [true, true],
|
|
17
|
-
8: [true, true],
|
|
18
|
-
},
|
|
19
|
-
};
|
|
20
|
-
const mpi = {
|
|
21
|
-
dispatch: jest.fn(),
|
|
22
|
-
getState: () => ({
|
|
23
|
-
app: {
|
|
24
|
-
instance: {
|
|
25
|
-
dataStatus: "saved",
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
inputs: mockInputs,
|
|
29
|
-
}),
|
|
30
|
-
};
|
|
31
|
-
const next = jest.fn();
|
|
32
|
-
const initialConditions = {
|
|
33
|
-
options: {},
|
|
34
|
-
variables: {},
|
|
35
|
-
documents: {},
|
|
36
|
-
sections: {},
|
|
37
|
-
prefillers: {},
|
|
38
|
-
validators: {
|
|
39
|
-
options: {},
|
|
40
|
-
variables: {},
|
|
41
|
-
},
|
|
42
|
-
};
|
|
43
|
-
const mockOptionsRelations = {
|
|
44
|
-
2: {
|
|
45
|
-
options: [],
|
|
46
|
-
variables: [],
|
|
47
|
-
sections: {},
|
|
48
|
-
documents: [],
|
|
49
|
-
prefillers: [],
|
|
50
|
-
validators: {
|
|
51
|
-
options: [],
|
|
52
|
-
variables: [],
|
|
53
|
-
},
|
|
54
|
-
parents: [],
|
|
55
|
-
children: {
|
|
56
|
-
options: [3, 4],
|
|
57
|
-
variables: [2, 3],
|
|
58
|
-
},
|
|
59
|
-
dependants: [7, 8],
|
|
60
|
-
},
|
|
61
|
-
};
|
|
62
|
-
jest.mock("../selectors/inputs", () => ({
|
|
63
|
-
__esModule: true,
|
|
64
|
-
selectOptionInput: (id) => mockInputs.options[id],
|
|
65
|
-
selectOptionInputByIndex: (id, index) => mockInputs.options[id][index],
|
|
66
|
-
selectVariableInput: (id) => mockInputs.variables[id],
|
|
67
|
-
selectVariableInputByIndex: (id, index) => mockInputs.variables[id][index],
|
|
68
|
-
}));
|
|
69
|
-
jest.mock("../../libs/ConditionsRunner", () => {
|
|
70
|
-
class ConditionsRunnerMock {
|
|
71
|
-
constructor(dispatch) {
|
|
72
|
-
this.dispatch = dispatch;
|
|
73
|
-
}
|
|
74
|
-
executeHooks(...args) {
|
|
75
|
-
this.dispatch({
|
|
76
|
-
type: "EXEC_HOOKS_MOCK",
|
|
77
|
-
arguments: args,
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
return {
|
|
82
|
-
__esModule: true,
|
|
83
|
-
ConditionsRunner: ConditionsRunnerMock,
|
|
84
|
-
};
|
|
85
|
-
});
|
|
86
|
-
const mockOptionsConditions = {};
|
|
87
|
-
const mockVariablesConditions = {};
|
|
88
|
-
jest.mock("../selectors/references", () => ({
|
|
89
|
-
__esModule: true,
|
|
90
|
-
selectOptionRelations: (id) => mockOptionsRelations[id],
|
|
91
|
-
selectOptionConditionsObject: (id) => mockOptionsConditions[id],
|
|
92
|
-
selectVariableConditionsObject: (id) => mockVariablesConditions[id],
|
|
93
|
-
}));
|
|
94
|
-
describe("Conditions Watcher Middleware Test suit", () => {
|
|
95
|
-
beforeEach(() => {
|
|
96
|
-
selectorsMiddleware(mpi)(next)({ type: "@INIT" });
|
|
97
|
-
jest.clearAllMocks();
|
|
98
|
-
});
|
|
99
|
-
it("Completes INIT_CONDITIONS action correctly", () => {
|
|
100
|
-
conditionsWatcherMiddleware(mpi)(next)(initConditionsAction(initialConditions));
|
|
101
|
-
expect(next.mock.calls.length).toBe(1);
|
|
102
|
-
expect(next.mock.calls[0][0]).toStrictEqual(Object.assign({ type: "INIT_CONDITIONS" }, initialConditions));
|
|
103
|
-
expect(mpi.dispatch.mock.calls.length).toBe(12);
|
|
104
|
-
expect(mpi.dispatch.mock.calls[0][0]).toStrictEqual({
|
|
105
|
-
type: "EXEC_HOOKS_MOCK",
|
|
106
|
-
arguments: ["options", 1, 0],
|
|
107
|
-
});
|
|
108
|
-
expect(mpi.dispatch.mock.calls[1][0]).toStrictEqual({
|
|
109
|
-
type: "EXEC_HOOKS_MOCK",
|
|
110
|
-
arguments: ["options", 2, 0],
|
|
111
|
-
});
|
|
112
|
-
expect(mpi.dispatch.mock.calls[2][0]).toStrictEqual({
|
|
113
|
-
type: "EXEC_HOOKS_MOCK",
|
|
114
|
-
arguments: ["options", 2, 1],
|
|
115
|
-
});
|
|
116
|
-
expect(mpi.dispatch.mock.calls[3][0]).toStrictEqual({
|
|
117
|
-
type: "EXEC_HOOKS_MOCK",
|
|
118
|
-
arguments: ["options", 3, 0],
|
|
119
|
-
});
|
|
120
|
-
expect(mpi.dispatch.mock.calls[4][0]).toStrictEqual({
|
|
121
|
-
type: "EXEC_HOOKS_MOCK",
|
|
122
|
-
arguments: ["options", 3, 1],
|
|
123
|
-
});
|
|
124
|
-
expect(mpi.dispatch.mock.calls[5][0]).toStrictEqual({
|
|
125
|
-
type: "EXEC_HOOKS_MOCK",
|
|
126
|
-
arguments: ["options", 4, 0],
|
|
127
|
-
});
|
|
128
|
-
expect(mpi.dispatch.mock.calls[6][0]).toStrictEqual({
|
|
129
|
-
type: "EXEC_HOOKS_MOCK",
|
|
130
|
-
arguments: ["options", 4, 1],
|
|
131
|
-
});
|
|
132
|
-
expect(mpi.dispatch.mock.calls[7][0]).toStrictEqual({
|
|
133
|
-
type: "EXEC_HOOKS_MOCK",
|
|
134
|
-
arguments: ["options", 7, 0],
|
|
135
|
-
});
|
|
136
|
-
expect(mpi.dispatch.mock.calls[8][0]).toStrictEqual({
|
|
137
|
-
type: "EXEC_HOOKS_MOCK",
|
|
138
|
-
arguments: ["options", 7, 1],
|
|
139
|
-
});
|
|
140
|
-
expect(mpi.dispatch.mock.calls[9][0]).toStrictEqual({
|
|
141
|
-
type: "EXEC_HOOKS_MOCK",
|
|
142
|
-
arguments: ["options", 8, 0],
|
|
143
|
-
});
|
|
144
|
-
expect(mpi.dispatch.mock.calls[10][0]).toStrictEqual({
|
|
145
|
-
type: "EXEC_HOOKS_MOCK",
|
|
146
|
-
arguments: ["options", 8, 1],
|
|
147
|
-
});
|
|
148
|
-
expect(mpi.dispatch.mock.calls[11][0]).toStrictEqual({
|
|
149
|
-
type: "EXEC_HOOKS_MOCK",
|
|
150
|
-
arguments: ["variables", 1, 0],
|
|
151
|
-
});
|
|
152
|
-
});
|
|
153
|
-
it("Completes UPDATE_OPTION_INPUT action correctly", () => {
|
|
154
|
-
conditionsWatcherMiddleware(mpi)(next)(updateOptionAction(3, false, 0));
|
|
155
|
-
expect(next.mock.calls.length).toBe(1);
|
|
156
|
-
expect(next.mock.calls[0][0]).toStrictEqual({
|
|
157
|
-
type: "UPDATE_OPTION_INPUT",
|
|
158
|
-
id: 3,
|
|
159
|
-
index: 0,
|
|
160
|
-
value: false,
|
|
161
|
-
});
|
|
162
|
-
expect(mpi.dispatch.mock.calls.length).toBe(2);
|
|
163
|
-
expect(mpi.dispatch.mock.calls[0][0]).toStrictEqual({
|
|
164
|
-
type: "SET_DATA_STATUS",
|
|
165
|
-
dataStatus: "unsaved",
|
|
166
|
-
});
|
|
167
|
-
expect(mpi.dispatch.mock.calls[1][0]).toStrictEqual({
|
|
168
|
-
type: "EXEC_HOOKS_MOCK",
|
|
169
|
-
arguments: ["options", 3, 0],
|
|
170
|
-
});
|
|
171
|
-
});
|
|
172
|
-
it("Completes UPDATE_VARIABLE_INPUT action correctly", () => {
|
|
173
|
-
conditionsWatcherMiddleware(mpi)(next)(updateVariableAction(1, "Hey", 0));
|
|
174
|
-
expect(next.mock.calls.length).toBe(1);
|
|
175
|
-
expect(next.mock.calls[0][0]).toStrictEqual({
|
|
176
|
-
type: "UPDATE_VARIABLE_INPUT",
|
|
177
|
-
id: 1,
|
|
178
|
-
index: 0,
|
|
179
|
-
value: "Hey",
|
|
180
|
-
});
|
|
181
|
-
expect(mpi.dispatch.mock.calls.length).toBe(2);
|
|
182
|
-
expect(mpi.dispatch.mock.calls[0][0]).toStrictEqual({
|
|
183
|
-
type: "SET_DATA_STATUS",
|
|
184
|
-
dataStatus: "unsaved",
|
|
185
|
-
});
|
|
186
|
-
expect(mpi.dispatch.mock.calls[1][0]).toStrictEqual({
|
|
187
|
-
type: "EXEC_HOOKS_MOCK",
|
|
188
|
-
arguments: ["variables", 1, 0],
|
|
189
|
-
});
|
|
190
|
-
});
|
|
191
|
-
it("Completes ADD_MULTIPLE_OCCURENCY action correctly", () => {
|
|
192
|
-
conditionsWatcherMiddleware(mpi)(next)(addMultipleOccurencyAction(2));
|
|
193
|
-
expect(next.mock.calls.length).toBe(1);
|
|
194
|
-
expect(next.mock.calls[0][0]).toStrictEqual({
|
|
195
|
-
type: "ADD_MULTIPLE_OCCURENCY",
|
|
196
|
-
id: 2,
|
|
197
|
-
});
|
|
198
|
-
expect(mpi.dispatch.mock.calls.length).toBe(15);
|
|
199
|
-
expect(mpi.dispatch.mock.calls[0][0]).toStrictEqual({
|
|
200
|
-
type: "SET_DATA_STATUS",
|
|
201
|
-
dataStatus: "unsaved",
|
|
202
|
-
});
|
|
203
|
-
expect(mpi.dispatch.mock.calls[1][0]).toStrictEqual({
|
|
204
|
-
type: "EXEC_HOOKS_MOCK",
|
|
205
|
-
arguments: ["options", 2, 0],
|
|
206
|
-
});
|
|
207
|
-
expect(mpi.dispatch.mock.calls[2][0]).toStrictEqual({
|
|
208
|
-
type: "EXEC_HOOKS_MOCK",
|
|
209
|
-
arguments: ["options", 2, 1],
|
|
210
|
-
});
|
|
211
|
-
expect(mpi.dispatch.mock.calls[3][0]).toStrictEqual({
|
|
212
|
-
type: "EXEC_HOOKS_MOCK",
|
|
213
|
-
arguments: ["options", 3, 0],
|
|
214
|
-
});
|
|
215
|
-
expect(mpi.dispatch.mock.calls[4][0]).toStrictEqual({
|
|
216
|
-
type: "EXEC_HOOKS_MOCK",
|
|
217
|
-
arguments: ["options", 3, 1],
|
|
218
|
-
});
|
|
219
|
-
expect(mpi.dispatch.mock.calls[5][0]).toStrictEqual({
|
|
220
|
-
type: "EXEC_HOOKS_MOCK",
|
|
221
|
-
arguments: ["options", 4, 0],
|
|
222
|
-
});
|
|
223
|
-
expect(mpi.dispatch.mock.calls[6][0]).toStrictEqual({
|
|
224
|
-
type: "EXEC_HOOKS_MOCK",
|
|
225
|
-
arguments: ["options", 4, 1],
|
|
226
|
-
});
|
|
227
|
-
expect(mpi.dispatch.mock.calls[7][0]).toStrictEqual({
|
|
228
|
-
type: "EXEC_HOOKS_MOCK",
|
|
229
|
-
arguments: ["options", 7, 0],
|
|
230
|
-
});
|
|
231
|
-
expect(mpi.dispatch.mock.calls[8][0]).toStrictEqual({
|
|
232
|
-
type: "EXEC_HOOKS_MOCK",
|
|
233
|
-
arguments: ["options", 7, 1],
|
|
234
|
-
});
|
|
235
|
-
expect(mpi.dispatch.mock.calls[9][0]).toStrictEqual({
|
|
236
|
-
type: "EXEC_HOOKS_MOCK",
|
|
237
|
-
arguments: ["options", 8, 0],
|
|
238
|
-
});
|
|
239
|
-
expect(mpi.dispatch.mock.calls[10][0]).toStrictEqual({
|
|
240
|
-
type: "EXEC_HOOKS_MOCK",
|
|
241
|
-
arguments: ["options", 8, 1],
|
|
242
|
-
});
|
|
243
|
-
expect(mpi.dispatch.mock.calls[11][0]).toStrictEqual({
|
|
244
|
-
type: "EXEC_HOOKS_MOCK",
|
|
245
|
-
arguments: ["variables", 2, 0],
|
|
246
|
-
});
|
|
247
|
-
expect(mpi.dispatch.mock.calls[12][0]).toStrictEqual({
|
|
248
|
-
type: "EXEC_HOOKS_MOCK",
|
|
249
|
-
arguments: ["variables", 2, 1],
|
|
250
|
-
});
|
|
251
|
-
expect(mpi.dispatch.mock.calls[13][0]).toStrictEqual({
|
|
252
|
-
type: "EXEC_HOOKS_MOCK",
|
|
253
|
-
arguments: ["variables", 3, 0],
|
|
254
|
-
});
|
|
255
|
-
expect(mpi.dispatch.mock.calls[14][0]).toStrictEqual({
|
|
256
|
-
type: "EXEC_HOOKS_MOCK",
|
|
257
|
-
arguments: ["variables", 3, 1],
|
|
258
|
-
});
|
|
259
|
-
});
|
|
260
|
-
it("Completes DELETE_MULTIPLE_OCCURENCY action correctly", () => {
|
|
261
|
-
conditionsWatcherMiddleware(mpi)(next)(deleteMultipleOccurencyAction(2, 1));
|
|
262
|
-
expect(next.mock.calls.length).toBe(1);
|
|
263
|
-
expect(next.mock.calls[0][0]).toStrictEqual({
|
|
264
|
-
type: "DELETE_MULTIPLE_OCCURENCY",
|
|
265
|
-
id: 2,
|
|
266
|
-
index: 1,
|
|
267
|
-
});
|
|
268
|
-
expect(mpi.dispatch.mock.calls.length).toBe(15);
|
|
269
|
-
expect(mpi.dispatch.mock.calls[0][0]).toStrictEqual({
|
|
270
|
-
type: "SET_DATA_STATUS",
|
|
271
|
-
dataStatus: "unsaved",
|
|
272
|
-
});
|
|
273
|
-
expect(mpi.dispatch.mock.calls[1][0]).toStrictEqual({
|
|
274
|
-
type: "EXEC_HOOKS_MOCK",
|
|
275
|
-
arguments: ["options", 2, 0],
|
|
276
|
-
});
|
|
277
|
-
expect(mpi.dispatch.mock.calls[2][0]).toStrictEqual({
|
|
278
|
-
type: "EXEC_HOOKS_MOCK",
|
|
279
|
-
arguments: ["options", 2, 1],
|
|
280
|
-
});
|
|
281
|
-
expect(mpi.dispatch.mock.calls[3][0]).toStrictEqual({
|
|
282
|
-
type: "EXEC_HOOKS_MOCK",
|
|
283
|
-
arguments: ["options", 3, 0],
|
|
284
|
-
});
|
|
285
|
-
expect(mpi.dispatch.mock.calls[4][0]).toStrictEqual({
|
|
286
|
-
type: "EXEC_HOOKS_MOCK",
|
|
287
|
-
arguments: ["options", 3, 1],
|
|
288
|
-
});
|
|
289
|
-
expect(mpi.dispatch.mock.calls[5][0]).toStrictEqual({
|
|
290
|
-
type: "EXEC_HOOKS_MOCK",
|
|
291
|
-
arguments: ["options", 4, 0],
|
|
292
|
-
});
|
|
293
|
-
expect(mpi.dispatch.mock.calls[6][0]).toStrictEqual({
|
|
294
|
-
type: "EXEC_HOOKS_MOCK",
|
|
295
|
-
arguments: ["options", 4, 1],
|
|
296
|
-
});
|
|
297
|
-
expect(mpi.dispatch.mock.calls[7][0]).toStrictEqual({
|
|
298
|
-
type: "EXEC_HOOKS_MOCK",
|
|
299
|
-
arguments: ["options", 7, 0],
|
|
300
|
-
});
|
|
301
|
-
expect(mpi.dispatch.mock.calls[8][0]).toStrictEqual({
|
|
302
|
-
type: "EXEC_HOOKS_MOCK",
|
|
303
|
-
arguments: ["options", 7, 1],
|
|
304
|
-
});
|
|
305
|
-
expect(mpi.dispatch.mock.calls[9][0]).toStrictEqual({
|
|
306
|
-
type: "EXEC_HOOKS_MOCK",
|
|
307
|
-
arguments: ["options", 8, 0],
|
|
308
|
-
});
|
|
309
|
-
expect(mpi.dispatch.mock.calls[10][0]).toStrictEqual({
|
|
310
|
-
type: "EXEC_HOOKS_MOCK",
|
|
311
|
-
arguments: ["options", 8, 1],
|
|
312
|
-
});
|
|
313
|
-
expect(mpi.dispatch.mock.calls[11][0]).toStrictEqual({
|
|
314
|
-
type: "EXEC_HOOKS_MOCK",
|
|
315
|
-
arguments: ["variables", 2, 0],
|
|
316
|
-
});
|
|
317
|
-
expect(mpi.dispatch.mock.calls[12][0]).toStrictEqual({
|
|
318
|
-
type: "EXEC_HOOKS_MOCK",
|
|
319
|
-
arguments: ["variables", 2, 1],
|
|
320
|
-
});
|
|
321
|
-
expect(mpi.dispatch.mock.calls[13][0]).toStrictEqual({
|
|
322
|
-
type: "EXEC_HOOKS_MOCK",
|
|
323
|
-
arguments: ["variables", 3, 0],
|
|
324
|
-
});
|
|
325
|
-
expect(mpi.dispatch.mock.calls[14][0]).toStrictEqual({
|
|
326
|
-
type: "EXEC_HOOKS_MOCK",
|
|
327
|
-
arguments: ["variables", 3, 1],
|
|
328
|
-
});
|
|
329
|
-
});
|
|
330
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,242 +0,0 @@
|
|
|
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 +0,0 @@
|
|
|
1
|
-
export {};
|