@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,171 @@
|
|
|
1
|
+
import { initOptionReducer } from './inputs/initOption';
|
|
2
|
+
import { updateOptionInputReducer } from './inputs/updateOptionInput';
|
|
3
|
+
import { inputsReducer } from './inputs';
|
|
4
|
+
import { initVariableReducer } from './inputs/initVariable';
|
|
5
|
+
import { updateVariableInputReducer } from './inputs/updateVariableInput';
|
|
6
|
+
describe('Inputs Options Reducer', () => {
|
|
7
|
+
it('initOption Reducer', () => {
|
|
8
|
+
const reducer = initOptionReducer({
|
|
9
|
+
variables: {},
|
|
10
|
+
options: {},
|
|
11
|
+
}, {
|
|
12
|
+
type: 'INIT_OPTION',
|
|
13
|
+
id: 123,
|
|
14
|
+
values: [false],
|
|
15
|
+
});
|
|
16
|
+
return expect(reducer).toStrictEqual({
|
|
17
|
+
variables: {},
|
|
18
|
+
options: {
|
|
19
|
+
123: [false],
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
it('updateOptionInput Reducer', () => {
|
|
24
|
+
const reducer = updateOptionInputReducer({
|
|
25
|
+
variables: {},
|
|
26
|
+
options: {
|
|
27
|
+
123: [false, false, false],
|
|
28
|
+
},
|
|
29
|
+
}, {
|
|
30
|
+
type: 'UPDATE_OPTION_INPUT',
|
|
31
|
+
id: 123,
|
|
32
|
+
value: true,
|
|
33
|
+
index: 1,
|
|
34
|
+
});
|
|
35
|
+
return expect(reducer).toStrictEqual({
|
|
36
|
+
variables: {},
|
|
37
|
+
options: {
|
|
38
|
+
123: [false, true, false],
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
it('updateOptionInput Reducer (When values did not change)', () => {
|
|
43
|
+
const initial = {
|
|
44
|
+
variables: {},
|
|
45
|
+
options: {
|
|
46
|
+
123: [false, false, false],
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
const reducer = updateOptionInputReducer(initial, {
|
|
50
|
+
type: 'UPDATE_OPTION_INPUT',
|
|
51
|
+
id: 123,
|
|
52
|
+
value: false,
|
|
53
|
+
index: 1,
|
|
54
|
+
});
|
|
55
|
+
return expect(reducer === initial).toBeTruthy();
|
|
56
|
+
});
|
|
57
|
+
it('initVariable Reducer', () => {
|
|
58
|
+
const reducer = initVariableReducer({
|
|
59
|
+
variables: {},
|
|
60
|
+
options: {},
|
|
61
|
+
}, {
|
|
62
|
+
type: 'INIT_VARIABLE',
|
|
63
|
+
id: 123,
|
|
64
|
+
values: [''],
|
|
65
|
+
});
|
|
66
|
+
return expect(reducer).toStrictEqual({
|
|
67
|
+
variables: {
|
|
68
|
+
123: [''],
|
|
69
|
+
},
|
|
70
|
+
options: {},
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
it('updateVariableInput Reducer', () => {
|
|
74
|
+
const reducer = updateVariableInputReducer({
|
|
75
|
+
variables: {
|
|
76
|
+
123: ['', '', ''],
|
|
77
|
+
},
|
|
78
|
+
options: {},
|
|
79
|
+
}, {
|
|
80
|
+
type: 'UPDATE_VARIABLE_INPUT',
|
|
81
|
+
id: 123,
|
|
82
|
+
value: 232,
|
|
83
|
+
index: 2,
|
|
84
|
+
});
|
|
85
|
+
return expect(reducer).toStrictEqual({
|
|
86
|
+
variables: {
|
|
87
|
+
123: ['', '', 232],
|
|
88
|
+
},
|
|
89
|
+
options: {},
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
it('updateVariableInput Reducer (Value did not change', () => {
|
|
93
|
+
const initial = {
|
|
94
|
+
variables: {
|
|
95
|
+
123: ['', 'Hello', ''],
|
|
96
|
+
},
|
|
97
|
+
options: {},
|
|
98
|
+
};
|
|
99
|
+
const reducer = updateVariableInputReducer(initial, {
|
|
100
|
+
type: 'UPDATE_VARIABLE_INPUT',
|
|
101
|
+
id: 123,
|
|
102
|
+
value: 'Hello',
|
|
103
|
+
index: 1,
|
|
104
|
+
});
|
|
105
|
+
return expect(reducer === initial).toBeTruthy();
|
|
106
|
+
});
|
|
107
|
+
it('inputsReducer INIT_OPTION ACTION', () => {
|
|
108
|
+
const reducer = inputsReducer(undefined, {
|
|
109
|
+
type: 'INIT_OPTION',
|
|
110
|
+
id: 323,
|
|
111
|
+
values: [true],
|
|
112
|
+
});
|
|
113
|
+
return expect(reducer).toStrictEqual({
|
|
114
|
+
variables: {},
|
|
115
|
+
options: {
|
|
116
|
+
323: [true],
|
|
117
|
+
},
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
it('inputsReducer UPDATE_OPTION_INPUT ACTION', () => {
|
|
121
|
+
const reducer = inputsReducer({
|
|
122
|
+
variables: {},
|
|
123
|
+
options: {
|
|
124
|
+
123: [false, false, false],
|
|
125
|
+
},
|
|
126
|
+
}, {
|
|
127
|
+
type: 'UPDATE_OPTION_INPUT',
|
|
128
|
+
id: 123,
|
|
129
|
+
value: true,
|
|
130
|
+
index: 1,
|
|
131
|
+
});
|
|
132
|
+
return expect(reducer).toStrictEqual({
|
|
133
|
+
variables: {},
|
|
134
|
+
options: {
|
|
135
|
+
123: [false, true, false],
|
|
136
|
+
},
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
it('inputsVariablesReducer INIT_VARIABLE ACTION', () => {
|
|
140
|
+
const reducer = inputsReducer(undefined, {
|
|
141
|
+
type: 'INIT_VARIABLE',
|
|
142
|
+
id: 323,
|
|
143
|
+
values: [''],
|
|
144
|
+
});
|
|
145
|
+
return expect(reducer).toStrictEqual({
|
|
146
|
+
variables: {
|
|
147
|
+
323: [''],
|
|
148
|
+
},
|
|
149
|
+
options: {},
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
it('inputsVariablesReducer UPDATE_VARIABLE_INPUT ACTION', () => {
|
|
153
|
+
const reducer = inputsReducer({
|
|
154
|
+
variables: {
|
|
155
|
+
323: ['', '', ''],
|
|
156
|
+
},
|
|
157
|
+
options: {},
|
|
158
|
+
}, {
|
|
159
|
+
type: 'UPDATE_VARIABLE_INPUT',
|
|
160
|
+
id: 323,
|
|
161
|
+
value: 'John',
|
|
162
|
+
index: 0,
|
|
163
|
+
});
|
|
164
|
+
return expect(reducer).toStrictEqual({
|
|
165
|
+
variables: {
|
|
166
|
+
323: ['John', '', ''],
|
|
167
|
+
},
|
|
168
|
+
options: {},
|
|
169
|
+
});
|
|
170
|
+
});
|
|
171
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { initUserReducer } from './user/initUser';
|
|
2
|
+
import { userReducer } from './user';
|
|
3
|
+
describe('User Reducer test suits', () => {
|
|
4
|
+
it('initUserReducer Reducer', () => {
|
|
5
|
+
const reducer = initUserReducer({
|
|
6
|
+
status: 'unauthenticated',
|
|
7
|
+
level: 'GUEST',
|
|
8
|
+
displayName: '',
|
|
9
|
+
email: '',
|
|
10
|
+
validToken: false,
|
|
11
|
+
}, {
|
|
12
|
+
type: 'INIT_USER',
|
|
13
|
+
level: 'ADMIN',
|
|
14
|
+
displayName: 'John Doe',
|
|
15
|
+
email: 'doe@legalplace.fr',
|
|
16
|
+
validToken: false,
|
|
17
|
+
});
|
|
18
|
+
return expect(reducer).toStrictEqual({
|
|
19
|
+
status: 'unauthenticated',
|
|
20
|
+
level: 'ADMIN',
|
|
21
|
+
displayName: 'John Doe',
|
|
22
|
+
email: 'doe@legalplace.fr',
|
|
23
|
+
validToken: false,
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
it('user Reducer INIT_USER Action', () => {
|
|
27
|
+
const reducer = userReducer(undefined, {
|
|
28
|
+
type: 'INIT_USER',
|
|
29
|
+
level: 'ADMIN',
|
|
30
|
+
displayName: 'John Doe',
|
|
31
|
+
email: 'doe@legalplace.fr',
|
|
32
|
+
validToken: false,
|
|
33
|
+
});
|
|
34
|
+
return expect(reducer).toStrictEqual({
|
|
35
|
+
status: 'unauthenticated',
|
|
36
|
+
level: 'ADMIN',
|
|
37
|
+
displayName: 'John Doe',
|
|
38
|
+
email: 'doe@legalplace.fr',
|
|
39
|
+
validToken: false,
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { createHistory, getHistory } from './routerHistory';
|
|
2
|
+
describe('Router History', () => {
|
|
3
|
+
it('Thows an error when history is not initiated', () => {
|
|
4
|
+
expect(getHistory).toThrowError('History not yet created');
|
|
5
|
+
});
|
|
6
|
+
it('Creates and returns history', () => {
|
|
7
|
+
const history = createHistory('memory');
|
|
8
|
+
expect(history).toHaveProperty('location');
|
|
9
|
+
});
|
|
10
|
+
it('Returns history', () => {
|
|
11
|
+
createHistory('memory');
|
|
12
|
+
const history = getHistory();
|
|
13
|
+
expect(history).toHaveProperty('location');
|
|
14
|
+
});
|
|
15
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import * as fs from 'fs';
|
|
11
|
+
import { createAppStore, getStore } from '../store';
|
|
12
|
+
import { initMetaAction, initInstanceAction } from '../actions/app';
|
|
13
|
+
import { fetchModelPrerequisitesAction } from '../actions/sagas/model';
|
|
14
|
+
import { ReferencesParser } from '@legalplace/referencesparser';
|
|
15
|
+
const permalink = 'test-model';
|
|
16
|
+
const uniqid = 'myMockUniqid';
|
|
17
|
+
const mockApiEndpoint = 'https://api.mock/api/v1/';
|
|
18
|
+
const model = JSON.parse(fs.readFileSync('./src/misc/test_models/testmodel.json', 'utf8'));
|
|
19
|
+
const meta = {
|
|
20
|
+
id: 123,
|
|
21
|
+
title: 'Test model',
|
|
22
|
+
permalink,
|
|
23
|
+
};
|
|
24
|
+
jest.mock('../../config', () => ({
|
|
25
|
+
getConfig: () => ({
|
|
26
|
+
apiEndpoint: 'https://api.mock/api/v1/',
|
|
27
|
+
router: {
|
|
28
|
+
wizardPath: '/:permalink/questionnaire/:page([0-9]+|sommaire)',
|
|
29
|
+
wizardInstancePath: '/:permalink/questionnaire/:uniqid([0-9a-zA-Z]+)/:page([0-9]+|sommaire)',
|
|
30
|
+
},
|
|
31
|
+
appStates: ['wizard'],
|
|
32
|
+
plugins: {},
|
|
33
|
+
theme: {
|
|
34
|
+
name: "legacy"
|
|
35
|
+
}
|
|
36
|
+
}),
|
|
37
|
+
updateConfig: () => { }
|
|
38
|
+
}));
|
|
39
|
+
jest.mock('../../Globals.ts', () => ({
|
|
40
|
+
__esModule: true,
|
|
41
|
+
default: {
|
|
42
|
+
loadTheme: () => __awaiter(void 0, void 0, void 0, function* () { return ({ default: {} }); })
|
|
43
|
+
}
|
|
44
|
+
}));
|
|
45
|
+
describe('Fetch model saga', () => {
|
|
46
|
+
let store;
|
|
47
|
+
beforeEach(() => {
|
|
48
|
+
createAppStore('memory');
|
|
49
|
+
store = getStore();
|
|
50
|
+
store.dispatch({
|
|
51
|
+
type: 'SET_DEFAULTS',
|
|
52
|
+
});
|
|
53
|
+
store.dispatch(initMetaAction({
|
|
54
|
+
id: 123,
|
|
55
|
+
title: 'Test model',
|
|
56
|
+
prefix: '',
|
|
57
|
+
permalink,
|
|
58
|
+
modelVersion: 1,
|
|
59
|
+
productType: 'demarche',
|
|
60
|
+
}));
|
|
61
|
+
store.dispatch(initInstanceAction({
|
|
62
|
+
uniqid,
|
|
63
|
+
isPaid: false,
|
|
64
|
+
dataStatus: 'saved',
|
|
65
|
+
steps: '*',
|
|
66
|
+
}));
|
|
67
|
+
fetchMock.resetMocks();
|
|
68
|
+
});
|
|
69
|
+
it('Sends fetch client config request to API', () => {
|
|
70
|
+
fetchMock.mockResponse((request) => __awaiter(void 0, void 0, void 0, function* () {
|
|
71
|
+
switch (request.url) {
|
|
72
|
+
case "https://api.mock/api/v1/client-config?permalink=test-model&disableOnBoarding=true":
|
|
73
|
+
return JSON.stringify({
|
|
74
|
+
clientConfig: {
|
|
75
|
+
domain: "api.mock",
|
|
76
|
+
prefix: null,
|
|
77
|
+
metadata: {}
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
case "https://api.mock/api/v1/wizard/contractv1/config/test-model/myMockUniqid":
|
|
81
|
+
return JSON.stringify({
|
|
82
|
+
modelUuid: "mock-uuid"
|
|
83
|
+
});
|
|
84
|
+
case "https://api.mock/api/v1/wizard/contractv1/model/mock-uuid":
|
|
85
|
+
return JSON.stringify({
|
|
86
|
+
references: new ReferencesParser(model).getReferences(),
|
|
87
|
+
meta: {
|
|
88
|
+
id: 1,
|
|
89
|
+
title: "Mock Model",
|
|
90
|
+
modelVersion: 1,
|
|
91
|
+
productType: "contract",
|
|
92
|
+
metdata: null
|
|
93
|
+
},
|
|
94
|
+
customization: {
|
|
95
|
+
disableAutoDefault: true,
|
|
96
|
+
meta: {
|
|
97
|
+
isTwoSteps: false,
|
|
98
|
+
disableDownloads: false,
|
|
99
|
+
scenario: {},
|
|
100
|
+
contractType: {
|
|
101
|
+
socialType: "individual",
|
|
102
|
+
privacy: "public"
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
dataStorage: {
|
|
106
|
+
extendedDuration: false
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
ovc: {
|
|
110
|
+
options: {},
|
|
111
|
+
variables: {}
|
|
112
|
+
},
|
|
113
|
+
smartScript: false
|
|
114
|
+
});
|
|
115
|
+
case "https://api.mock/api/v1/wizard/contractv1/test-model/myMockUniqid":
|
|
116
|
+
return JSON.stringify({
|
|
117
|
+
model,
|
|
118
|
+
meta
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
return "{}";
|
|
122
|
+
}));
|
|
123
|
+
store.dispatch(fetchModelPrerequisitesAction(permalink));
|
|
124
|
+
expect(fetchMock.mock.calls.length).toEqual(1);
|
|
125
|
+
expect(fetchMock.mock.calls[0][0]).toEqual(`${mockApiEndpoint}contract/instance/${uniqid}/refresh-model`);
|
|
126
|
+
});
|
|
127
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import * as fs from 'fs';
|
|
2
|
+
import { ReferencesParser } from '@legalplace/referencesparser';
|
|
3
|
+
import { createAppStore, getStore } from '../store';
|
|
4
|
+
import { initMetaAction, initPaginationAction, initInstanceAction, } from '../actions/app';
|
|
5
|
+
import { initReferencesAction } from '../actions/references';
|
|
6
|
+
import { IntputsInitiator } from '../../libs/InputsInitiator';
|
|
7
|
+
import { initOptionAction, initVariableAction, updateOptionAction, } from '../actions/inputs';
|
|
8
|
+
import { initConditionsAction } from '../actions/conditions';
|
|
9
|
+
import { ConditionsInitiator } from '../../libs/ConditionsInitiator';
|
|
10
|
+
import { saveDataAction } from '../actions/sagas/data';
|
|
11
|
+
require('jest-fetch-mock').enableMocks();
|
|
12
|
+
const permalink = 'test-model';
|
|
13
|
+
const uniqid = 'myMockUniqid';
|
|
14
|
+
const mockApiEndpoint = 'https://api.mock/api/v1/';
|
|
15
|
+
jest.mock('../../config', () => ({
|
|
16
|
+
getConfig: () => ({
|
|
17
|
+
apiEndpoint: mockApiEndpoint,
|
|
18
|
+
}),
|
|
19
|
+
}));
|
|
20
|
+
describe('Save data saga', () => {
|
|
21
|
+
let store;
|
|
22
|
+
beforeEach(() => {
|
|
23
|
+
createAppStore('memory');
|
|
24
|
+
store = getStore();
|
|
25
|
+
store.dispatch({
|
|
26
|
+
type: 'SET_DEFAULTS',
|
|
27
|
+
});
|
|
28
|
+
const model = JSON.parse(fs.readFileSync('./src/misc/test_models/setDefaults.testmodel.json', 'utf8'));
|
|
29
|
+
const references = new ReferencesParser(model).getReferences();
|
|
30
|
+
store.dispatch(initReferencesAction(references));
|
|
31
|
+
const inputs = new IntputsInitiator(references, null).getInputs();
|
|
32
|
+
Object.keys(inputs.options).forEach((optionId) => {
|
|
33
|
+
const values = inputs.options[optionId];
|
|
34
|
+
store.dispatch(initOptionAction(parseInt(optionId, 10), values));
|
|
35
|
+
});
|
|
36
|
+
Object.keys(inputs.variables).forEach((variableId) => {
|
|
37
|
+
const values = inputs.variables[variableId];
|
|
38
|
+
store.dispatch(initVariableAction(parseInt(variableId, 10), values));
|
|
39
|
+
});
|
|
40
|
+
store.dispatch(initMetaAction({
|
|
41
|
+
id: 123,
|
|
42
|
+
title: 'Test model',
|
|
43
|
+
permalink,
|
|
44
|
+
modelVersion: 1,
|
|
45
|
+
prefix: '',
|
|
46
|
+
productType: 'demarche',
|
|
47
|
+
}));
|
|
48
|
+
store.dispatch(initInstanceAction({
|
|
49
|
+
uniqid,
|
|
50
|
+
isPaid: false,
|
|
51
|
+
dataStatus: 'unsaved',
|
|
52
|
+
steps: '*',
|
|
53
|
+
}));
|
|
54
|
+
store.dispatch(initPaginationAction({
|
|
55
|
+
availableAppStates: ['wizard', 'termsheet'],
|
|
56
|
+
currentAppState: 'wizard',
|
|
57
|
+
currentPage: 4,
|
|
58
|
+
greatestPage: 4,
|
|
59
|
+
currentSectionId: 1,
|
|
60
|
+
availableSections: [1, 3],
|
|
61
|
+
}));
|
|
62
|
+
const conditions = new ConditionsInitiator(references, inputs).getConditions();
|
|
63
|
+
store.dispatch(initConditionsAction(conditions));
|
|
64
|
+
store.dispatch({ type: 'SET_DEFAULTS' });
|
|
65
|
+
store.dispatch(updateOptionAction(15, true, 0));
|
|
66
|
+
fetchMock.resetMocks();
|
|
67
|
+
});
|
|
68
|
+
it('Sends save request to API', () => {
|
|
69
|
+
fetchMock.mockResponseOnce(JSON.stringify({ status: 'success' }));
|
|
70
|
+
store.dispatch(saveDataAction());
|
|
71
|
+
expect(fetchMock.mock.calls.length).toEqual(1);
|
|
72
|
+
expect(fetchMock.mock.calls[0][0]).toEqual(`${mockApiEndpoint}wizard/instance/${permalink}/${uniqid}`);
|
|
73
|
+
});
|
|
74
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import * as fs from 'fs';
|
|
2
|
+
import { ReferencesParser } from '@legalplace/referencesparser';
|
|
3
|
+
import { createAppStore, getStore } from '../store';
|
|
4
|
+
import { initMetaAction, initPaginationAction } from '../actions/app';
|
|
5
|
+
import { initReferencesAction } from '../actions/references';
|
|
6
|
+
import { IntputsInitiator } from '../../libs/InputsInitiator';
|
|
7
|
+
import { initOptionAction, initVariableAction } from '../actions/inputs';
|
|
8
|
+
import { initConditionsAction } from '../actions/conditions';
|
|
9
|
+
import { ConditionsInitiator } from '../../libs/ConditionsInitiator';
|
|
10
|
+
describe('Set defaults saga', () => {
|
|
11
|
+
let store;
|
|
12
|
+
beforeEach(() => {
|
|
13
|
+
createAppStore('memory');
|
|
14
|
+
store = getStore();
|
|
15
|
+
store.dispatch({
|
|
16
|
+
type: 'SET_DEFAULTS',
|
|
17
|
+
});
|
|
18
|
+
const model = JSON.parse(fs.readFileSync('./src/misc/test_models/setDefaults.testmodel.json', 'utf8'));
|
|
19
|
+
const references = new ReferencesParser(model).getReferences();
|
|
20
|
+
store.dispatch(initReferencesAction(references));
|
|
21
|
+
const inputs = new IntputsInitiator(references, null).getInputs();
|
|
22
|
+
Object.keys(inputs.options).forEach((optionId) => {
|
|
23
|
+
const values = inputs.options[optionId];
|
|
24
|
+
store.dispatch(initOptionAction(parseInt(optionId, 10), values));
|
|
25
|
+
});
|
|
26
|
+
Object.keys(inputs.variables).forEach((variableId) => {
|
|
27
|
+
const values = inputs.variables[variableId];
|
|
28
|
+
store.dispatch(initVariableAction(parseInt(variableId, 10), values));
|
|
29
|
+
});
|
|
30
|
+
store.dispatch(initMetaAction({
|
|
31
|
+
id: 123,
|
|
32
|
+
title: 'Test model',
|
|
33
|
+
permalink: 'test-model',
|
|
34
|
+
prefix: '',
|
|
35
|
+
modelVersion: 1,
|
|
36
|
+
productType: 'demarche',
|
|
37
|
+
}));
|
|
38
|
+
store.dispatch(initPaginationAction({
|
|
39
|
+
availableAppStates: ['wizard', 'termsheet'],
|
|
40
|
+
currentAppState: 'wizard',
|
|
41
|
+
currentPage: 4,
|
|
42
|
+
greatestPage: 4,
|
|
43
|
+
currentSectionId: 1,
|
|
44
|
+
availableSections: [1, 3],
|
|
45
|
+
}));
|
|
46
|
+
const conditions = new ConditionsInitiator(references, inputs).getConditions();
|
|
47
|
+
store.dispatch(initConditionsAction(conditions));
|
|
48
|
+
});
|
|
49
|
+
it('Sets defaults properly', () => {
|
|
50
|
+
store.dispatch({ type: 'SET_DEFAULTS' });
|
|
51
|
+
expect(store.getState().app.wizard.availableSections).toStrictEqual([
|
|
52
|
+
1, 2, 3,
|
|
53
|
+
]);
|
|
54
|
+
expect(store.getState().inputs.options).toStrictEqual({
|
|
55
|
+
1: [true],
|
|
56
|
+
2: [true],
|
|
57
|
+
3: [false],
|
|
58
|
+
4: [true],
|
|
59
|
+
5: [true],
|
|
60
|
+
6: [true],
|
|
61
|
+
7: [true],
|
|
62
|
+
8: [true],
|
|
63
|
+
9: [true],
|
|
64
|
+
10: [true],
|
|
65
|
+
11: [false],
|
|
66
|
+
12: [true],
|
|
67
|
+
13: [false],
|
|
68
|
+
14: [true],
|
|
69
|
+
15: [false],
|
|
70
|
+
16: [false],
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { createAppStore, getStore } from '../store';
|
|
2
|
+
import { initPaginationAction, initMetaAction, initInstanceAction, } from '../actions/app';
|
|
3
|
+
import { selectCurrentPage, selectCurrentSectionId, selectAvailableSections, selectPermalink, selectDocumentId, selectDocumentTitle, selectInstanceUniqid, selectInstanceIsPaid, } from './app';
|
|
4
|
+
createAppStore('memory');
|
|
5
|
+
const store = getStore();
|
|
6
|
+
describe('App selectors test suit', () => {
|
|
7
|
+
it('Returns current page correctly', () => {
|
|
8
|
+
store.dispatch(initPaginationAction({
|
|
9
|
+
currentSectionId: 1,
|
|
10
|
+
currentPage: 13,
|
|
11
|
+
greatestPage: 1,
|
|
12
|
+
availableSections: [1, 2, 3],
|
|
13
|
+
availableAppStates: ['wizard'],
|
|
14
|
+
currentAppState: 'wizard',
|
|
15
|
+
}));
|
|
16
|
+
const selector = selectCurrentPage();
|
|
17
|
+
expect(selector).toBe(13);
|
|
18
|
+
});
|
|
19
|
+
it('Returns current section id correctly', () => {
|
|
20
|
+
store.dispatch(initPaginationAction({
|
|
21
|
+
currentSectionId: 32,
|
|
22
|
+
currentPage: 13,
|
|
23
|
+
greatestPage: 13,
|
|
24
|
+
availableSections: [1, 2, 3],
|
|
25
|
+
availableAppStates: ['wizard'],
|
|
26
|
+
currentAppState: 'wizard',
|
|
27
|
+
}));
|
|
28
|
+
const selector = selectCurrentSectionId();
|
|
29
|
+
expect(selector).toBe(32);
|
|
30
|
+
});
|
|
31
|
+
it('Returns available sections correctly', () => {
|
|
32
|
+
store.dispatch(initPaginationAction({
|
|
33
|
+
currentSectionId: 32,
|
|
34
|
+
currentPage: 13,
|
|
35
|
+
greatestPage: 13,
|
|
36
|
+
availableSections: [1, 2, 3],
|
|
37
|
+
availableAppStates: ['wizard'],
|
|
38
|
+
currentAppState: 'wizard',
|
|
39
|
+
}));
|
|
40
|
+
const selector = selectAvailableSections();
|
|
41
|
+
expect(selector).toEqual([1, 2, 3]);
|
|
42
|
+
});
|
|
43
|
+
it('Returns permalink correctly', () => {
|
|
44
|
+
store.dispatch(initMetaAction({
|
|
45
|
+
permalink: 'some-permalink',
|
|
46
|
+
title: 'Some title',
|
|
47
|
+
prefix: '',
|
|
48
|
+
id: 123,
|
|
49
|
+
modelVersion: 1,
|
|
50
|
+
productType: 'demarche',
|
|
51
|
+
}));
|
|
52
|
+
const selector = selectPermalink();
|
|
53
|
+
expect(selector).toBe('some-permalink');
|
|
54
|
+
});
|
|
55
|
+
it('Returns document id correctly', () => {
|
|
56
|
+
store.dispatch(initMetaAction({
|
|
57
|
+
permalink: 'some-permalink',
|
|
58
|
+
title: 'Some title',
|
|
59
|
+
prefix: '',
|
|
60
|
+
id: 123,
|
|
61
|
+
modelVersion: 1,
|
|
62
|
+
productType: 'demarche',
|
|
63
|
+
}));
|
|
64
|
+
const selector = selectDocumentId();
|
|
65
|
+
expect(selector).toBe(123);
|
|
66
|
+
});
|
|
67
|
+
it('Returns document title correctly', () => {
|
|
68
|
+
store.dispatch(initMetaAction({
|
|
69
|
+
permalink: 'some-permalink',
|
|
70
|
+
title: 'Some title',
|
|
71
|
+
prefix: '',
|
|
72
|
+
id: 123,
|
|
73
|
+
modelVersion: 1,
|
|
74
|
+
productType: 'demarche',
|
|
75
|
+
}));
|
|
76
|
+
const selector = selectDocumentTitle();
|
|
77
|
+
expect(selector).toBe('Some title');
|
|
78
|
+
});
|
|
79
|
+
it('Returns instance uniqid correctly', () => {
|
|
80
|
+
store.dispatch(initInstanceAction({
|
|
81
|
+
dataStatus: 'saved',
|
|
82
|
+
uniqid: 'SomeUNiqID',
|
|
83
|
+
isPaid: false,
|
|
84
|
+
steps: '*',
|
|
85
|
+
}));
|
|
86
|
+
const selector = selectInstanceUniqid();
|
|
87
|
+
expect(selector).toBe('SomeUNiqID');
|
|
88
|
+
});
|
|
89
|
+
it('Returns instance isPaid correctly', () => {
|
|
90
|
+
store.dispatch(initInstanceAction({
|
|
91
|
+
dataStatus: 'saved',
|
|
92
|
+
uniqid: 'SomeUNiqID',
|
|
93
|
+
isPaid: true,
|
|
94
|
+
steps: '*',
|
|
95
|
+
}));
|
|
96
|
+
const selector = selectInstanceIsPaid();
|
|
97
|
+
expect(selector).toBeTruthy();
|
|
98
|
+
});
|
|
99
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|