@legalplace/wizardx-core 4.42.9 → 4.42.10-nightly.20251125120616

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.
Files changed (211) hide show
  1. package/README.md +376 -1
  2. package/dist/App.d.ts +1 -6
  3. package/dist/App.js +2 -7
  4. package/dist/Loader.d.ts +1 -1
  5. package/dist/Loader.js +1 -1
  6. package/dist/PluginLoader.d.ts +21 -36
  7. package/dist/PluginLoader.js +90 -227
  8. package/dist/Shimmer.d.ts +8 -11
  9. package/dist/Shimmer.js +4 -4
  10. package/dist/ThemeLoader.d.ts +8 -8
  11. package/dist/WizardCore.d.ts +29 -0
  12. package/dist/WizardCore.js +153 -0
  13. package/dist/app.entry.d.ts +2 -0
  14. package/dist/app.entry.js +1 -0
  15. package/dist/components/PluginRoute.d.ts +2 -2
  16. package/dist/components/PluginRoute.js +3 -4
  17. package/dist/components/SmartScript.d.ts +2 -6
  18. package/dist/components/SmartScript.js +1 -1
  19. package/dist/components/UserLocked/UserLockedComponent.js +2 -2
  20. package/dist/components/View.d.ts +3 -3
  21. package/dist/components/View.js +5 -7
  22. package/dist/componentsConnectors/connectBox.d.ts +4 -6
  23. package/dist/componentsConnectors/connectDocument.d.ts +4 -6
  24. package/dist/componentsConnectors/connectHeader.d.ts +4 -6
  25. package/dist/componentsConnectors/connectMetaTitle.d.ts +3 -7
  26. package/dist/componentsConnectors/connectOption.d.ts +5 -7
  27. package/dist/componentsConnectors/connectPagination.d.ts +5 -7
  28. package/dist/componentsConnectors/connectPreview.d.ts +3 -7
  29. package/dist/componentsConnectors/connectProgress.d.ts +4 -6
  30. package/dist/componentsConnectors/connectRootOption.d.ts +5 -7
  31. package/dist/componentsConnectors/connectSection.d.ts +4 -6
  32. package/dist/componentsConnectors/connectSummary.d.ts +5 -9
  33. package/dist/componentsConnectors/connectSummaryItem.d.ts +4 -6
  34. package/dist/componentsConnectors/connectTermsheet.js +1 -1
  35. package/dist/componentsConnectors/connectVariable.d.ts +6 -8
  36. package/dist/componentsConnectors/connectWizardWrapper.d.ts +4 -6
  37. package/dist/componentsConnectors/connector/componentConnector.d.ts +7 -10
  38. package/dist/componentsConnectors/connector/componentConnector.js +3 -3
  39. package/dist/componentsConnectors/library.d.ts +47 -81
  40. package/dist/helpers/activitiesHelper.d.ts +3 -3
  41. package/dist/helpers/autocomplete.helper.d.ts +2 -2
  42. package/dist/helpers/autocomplete.helper.js +1 -1
  43. package/dist/helpers/autosave.helper.d.ts +3 -13
  44. package/dist/helpers/autosave.helper.js +3 -70
  45. package/dist/helpers/inpiCitiesHelper.js +1 -1
  46. package/dist/helpers/outputsParsing.d.ts +9 -9
  47. package/dist/hooks/useDispatch.d.ts +1 -1
  48. package/dist/hooks/usePrevious.js +1 -1
  49. package/dist/index.d.ts +3 -0
  50. package/dist/index.js +3 -0
  51. package/dist/libs/ConditionsRunner.d.ts +1 -1
  52. package/dist/libs/Formatter/FormatAddress.d.ts +1 -1
  53. package/dist/libs/InputsInitiator.d.ts +1 -1
  54. package/dist/libs/PathReader.d.ts +96 -1
  55. package/dist/libs/PathReader.js +1 -2
  56. package/dist/libs/SmartScriptStore.d.ts +6 -6
  57. package/dist/redux/actions/app.d.ts +1 -1
  58. package/dist/redux/actions/inputs.d.ts +1 -1
  59. package/dist/redux/actions/library.d.ts +15 -21
  60. package/dist/redux/actions/references.d.ts +2 -2
  61. package/dist/redux/actions/sagas/data.d.ts +1 -1
  62. package/dist/redux/actions/sagas/user.d.ts +1 -1
  63. package/dist/redux/listeners/subscriber.d.ts +1 -1
  64. package/dist/redux/middlewares/conditionsWatcherMiddleware.d.ts +1 -1
  65. package/dist/redux/middlewares/evaluationsWatcherMiddleware.d.ts +1 -1
  66. package/dist/redux/middlewares/mandatoriesWatcherMiddleware.d.ts +1 -1
  67. package/dist/redux/middlewares/multiplesActionsMiddleware.d.ts +1 -1
  68. package/dist/redux/middlewares/paginationWatcherMiddleware.d.ts +2 -2
  69. package/dist/redux/middlewares/pluginsHookMiddleware.d.ts +1 -2
  70. package/dist/redux/middlewares/pluginsHookMiddleware.js +1 -7
  71. package/dist/redux/middlewares/prefillerWatcherMiddleware.d.ts +1 -1
  72. package/dist/redux/middlewares/smartscriptMiddleware.d.ts +1 -1
  73. package/dist/redux/middlewares/smartscriptMiddleware.js +2 -2
  74. package/dist/redux/middlewares/thirdpartyScriptsMiddleware.d.ts +1 -1
  75. package/dist/redux/reducers/app/pagination/updateAvailableAppStates.js +1 -2
  76. package/dist/redux/reducers/app.d.ts +6 -6
  77. package/dist/redux/reducers/references.js +2 -0
  78. package/dist/redux/selectors/inputs.d.ts +1 -1
  79. package/dist/redux/selectors/selectors.d.ts +4 -4
  80. package/dist/redux/store.d.ts +5 -3
  81. package/dist/redux/store.js +2 -1
  82. package/dist/routing/adapters/nextjs.adapter.d.ts +3 -0
  83. package/dist/routing/adapters/nextjs.adapter.js +61 -0
  84. package/dist/routing/adapters/reactRouter.adapter.d.ts +2 -0
  85. package/dist/routing/adapters/reactRouter.adapter.js +16 -0
  86. package/dist/routing/context.d.ts +14 -0
  87. package/dist/routing/context.js +23 -0
  88. package/dist/routing/index.d.ts +4 -0
  89. package/dist/routing/index.js +4 -0
  90. package/dist/routing/types.d.ts +26 -0
  91. package/dist/service/api.manager.d.ts +2 -2
  92. package/dist/service/autocomplete.manager.d.ts +3 -3
  93. package/dist/service/autocomplete.manager.js +3 -3
  94. package/dist/tests-misc/plugins/jestTestPlugin/after.js +1 -1
  95. package/dist/tests-misc/plugins/jestTestPlugin/before.js +1 -1
  96. package/dist/tests-misc/plugins/jestTestPlugin/title.js +1 -1
  97. package/dist/tests-misc/themes/jestTestTheme/components/EmailComponent.d.ts +1 -1
  98. package/dist/tests-misc/themes/jestTestTheme/components/EmailComponent.js +1 -1
  99. package/dist/tests-misc/themes/jestTestTheme/components/TermsheetComponent.d.ts +1 -1
  100. package/dist/tests-misc/themes/jestTestTheme/components/TermsheetComponent.js +1 -1
  101. package/dist/tests-misc/themes/jestTestTheme/components/WizardComponent.d.ts +1 -1
  102. package/dist/tests-misc/themes/jestTestTheme/components/WizardComponent.js +1 -1
  103. package/dist/types/Actions.type.d.ts +70 -6
  104. package/dist/types/Components.type.d.ts +3 -2
  105. package/dist/types/PluginConfig.type.d.ts +18 -52
  106. package/dist/types/State.type.d.ts +2 -2
  107. package/dist/types/config.type.d.ts +1 -1
  108. package/dist/types/getActions.type.d.ts +1 -1
  109. package/dist/types/getConnectors.type.d.ts +2 -2
  110. package/dist/types/getSelectors.type.d.ts +1 -1
  111. package/dist/wizardcore.entry.d.ts +3 -0
  112. package/dist/wizardcore.entry.js +2 -0
  113. package/package.json +40 -17
  114. package/dist/App.test.js +0 -37
  115. package/dist/PluginLoader.test.d.ts +0 -1
  116. package/dist/PluginLoader.test.js +0 -52
  117. package/dist/ThemeLoader.test.d.ts +0 -2
  118. package/dist/ThemeLoader.test.js +0 -65
  119. package/dist/components/View.test.d.ts +0 -2
  120. package/dist/components/View.test.js +0 -84
  121. package/dist/componentsConnectors/connectBox.test.d.ts +0 -1
  122. package/dist/componentsConnectors/connectBox.test.js +0 -218
  123. package/dist/componentsConnectors/connectDocument.test.d.ts +0 -1
  124. package/dist/componentsConnectors/connectDocument.test.js +0 -95
  125. package/dist/componentsConnectors/connectMetaTitle.test.d.ts +0 -1
  126. package/dist/componentsConnectors/connectMetaTitle.test.js +0 -32
  127. package/dist/config.test.d.ts +0 -1
  128. package/dist/config.test.js +0 -54
  129. package/dist/libs/NumAuto.test.d.ts +0 -1
  130. package/dist/libs/NumAuto.test.js +0 -43
  131. package/dist/libs/SectionValidity.test.d.ts +0 -1
  132. package/dist/libs/SectionValidity.test.js +0 -116
  133. package/dist/redux/actions/app.test.d.ts +0 -1
  134. package/dist/redux/actions/app.test.js +0 -90
  135. package/dist/redux/actions/conditions.test.d.ts +0 -1
  136. package/dist/redux/actions/conditions.test.js +0 -68
  137. package/dist/redux/actions/inputs.test.d.ts +0 -1
  138. package/dist/redux/actions/inputs.test.js +0 -53
  139. package/dist/redux/actions/references.test.d.ts +0 -1
  140. package/dist/redux/actions/references.test.js +0 -43
  141. package/dist/redux/actions/sagas/data.test.d.ts +0 -1
  142. package/dist/redux/actions/sagas/data.test.js +0 -11
  143. package/dist/redux/actions/sagas/model.test.d.ts +0 -1
  144. package/dist/redux/actions/sagas/model.test.js +0 -11
  145. package/dist/redux/actions/user.test.d.ts +0 -1
  146. package/dist/redux/actions/user.test.js +0 -16
  147. package/dist/redux/listeners/subscriber.test.d.ts +0 -1
  148. package/dist/redux/listeners/subscriber.test.js +0 -31
  149. package/dist/redux/middlewares/conditionsWatcherMiddleware.test.d.ts +0 -1
  150. package/dist/redux/middlewares/conditionsWatcherMiddleware.test.js +0 -330
  151. package/dist/redux/middlewares/evaluationsWatcherMiddleware.test.d.ts +0 -1
  152. package/dist/redux/middlewares/evaluationsWatcherMiddleware.test.js +0 -242
  153. package/dist/redux/middlewares/multiplesActionsMiddleware.test.d.ts +0 -1
  154. package/dist/redux/middlewares/multiplesActionsMiddleware.test.js +0 -209
  155. package/dist/redux/middlewares/prefillerWatcherMiddleware.test.d.ts +0 -1
  156. package/dist/redux/middlewares/prefillerWatcherMiddleware.test.js +0 -84
  157. package/dist/redux/reducers/app/instance.test.d.ts +0 -1
  158. package/dist/redux/reducers/app/instance.test.js +0 -75
  159. package/dist/redux/reducers/app/meta.test.d.ts +0 -1
  160. package/dist/redux/reducers/app/meta.test.js +0 -70
  161. package/dist/redux/reducers/app/pagination.test.d.ts +0 -1
  162. package/dist/redux/reducers/app/pagination.test.js +0 -134
  163. package/dist/redux/reducers/app/wizard.test.d.ts +0 -1
  164. package/dist/redux/reducers/app/wizard.test.js +0 -53
  165. package/dist/redux/reducers/app.test.d.ts +0 -1
  166. package/dist/redux/reducers/app.test.js +0 -175
  167. package/dist/redux/reducers/conditions/addMultipleOccurency.test.d.ts +0 -1
  168. package/dist/redux/reducers/conditions/addMultipleOccurency.test.js +0 -108
  169. package/dist/redux/reducers/conditions/deleteMultipleOccurency.test.d.ts +0 -1
  170. package/dist/redux/reducers/conditions/deleteMultipleOccurency.test.js +0 -77
  171. package/dist/redux/reducers/conditions/updateDocumentConditions.test.d.ts +0 -1
  172. package/dist/redux/reducers/conditions/updateDocumentConditions.test.js +0 -35
  173. package/dist/redux/reducers/conditions/updateOptionValidatorCondition.test.d.ts +0 -1
  174. package/dist/redux/reducers/conditions/updateOptionValidatorCondition.test.js +0 -35
  175. package/dist/redux/reducers/conditions/updateVariableValidatorCondition.test.d.ts +0 -1
  176. package/dist/redux/reducers/conditions/updateVariableValidatorCondition.test.js +0 -35
  177. package/dist/redux/reducers/conditions.test.d.ts +0 -1
  178. package/dist/redux/reducers/conditions.test.js +0 -196
  179. package/dist/redux/reducers/inputs/addMultipleOccurency.test.d.ts +0 -1
  180. package/dist/redux/reducers/inputs/addMultipleOccurency.test.js +0 -101
  181. package/dist/redux/reducers/inputs/deleteMultipleOccurency.test.d.ts +0 -1
  182. package/dist/redux/reducers/inputs/deleteMultipleOccurency.test.js +0 -56
  183. package/dist/redux/reducers/inputs.test.d.ts +0 -1
  184. package/dist/redux/reducers/inputs.test.js +0 -171
  185. package/dist/redux/reducers/user.test.d.ts +0 -1
  186. package/dist/redux/reducers/user.test.js +0 -42
  187. package/dist/redux/routerHistore.test.d.ts +0 -1
  188. package/dist/redux/routerHistore.test.js +0 -15
  189. package/dist/redux/sagas/fetchModel.test.d.ts +0 -1
  190. package/dist/redux/sagas/fetchModel.test.js +0 -127
  191. package/dist/redux/sagas/runner.test.d.ts +0 -1
  192. package/dist/redux/sagas/runner.test.js +0 -10
  193. package/dist/redux/sagas/saveData.test.d.ts +0 -1
  194. package/dist/redux/sagas/saveData.test.js +0 -74
  195. package/dist/redux/sagas/setDefaults.test.d.ts +0 -1
  196. package/dist/redux/sagas/setDefaults.test.js +0 -73
  197. package/dist/redux/selectors/app.test.d.ts +0 -1
  198. package/dist/redux/selectors/app.test.js +0 -99
  199. package/dist/redux/selectors/conditions.test.d.ts +0 -1
  200. package/dist/redux/selectors/conditions.test.js +0 -70
  201. package/dist/redux/selectors/inputs.test.d.ts +0 -1
  202. package/dist/redux/selectors/inputs.test.js +0 -44
  203. package/dist/redux/selectors/references.test.d.ts +0 -1
  204. package/dist/redux/selectors/references.test.js +0 -471
  205. package/dist/redux/selectors/selectors.test.d.ts +0 -1
  206. package/dist/redux/selectors/selectors.test.js +0 -16
  207. package/dist/redux/selectors/user.test.d.ts +0 -1
  208. package/dist/redux/selectors/user.test.js +0 -29
  209. package/dist/redux/store.test.d.ts +0 -1
  210. package/dist/redux/store.test.js +0 -16
  211. /package/dist/{App.test.d.ts → routing/types.js} +0 -0
@@ -1,101 +0,0 @@
1
- import { addMultipleOccurencyReducer } from './addMultipleOccurency';
2
- const state = {
3
- options: {
4
- 2: [true],
5
- 3: [false],
6
- 4: [true],
7
- },
8
- variables: {
9
- 2: [''],
10
- 3: [''],
11
- },
12
- };
13
- describe('addMultipleOccurencyReducer test suit', () => {
14
- it('Throws an error if optionRelations or optionsReferences are undefined', () => {
15
- expect(() => {
16
- addMultipleOccurencyReducer(state, {
17
- id: 3,
18
- optionRelations: undefined,
19
- optionsReferences: undefined,
20
- });
21
- }).toThrowError('ADD_MULTIPLE_OCCURENCY reducer did not recieve complete data when adding ' +
22
- `occurency for 3, please make sure "multiplesActions" middleware is ` +
23
- 'plugged and working properly');
24
- });
25
- it('Adds a multiple occurency conditions correctly', () => {
26
- const optionRelations = {
27
- options: [],
28
- variables: [],
29
- sections: {},
30
- documents: [],
31
- prefillers: [],
32
- validators: {
33
- options: [],
34
- variables: [],
35
- },
36
- parents: [],
37
- children: {
38
- options: [3, 4],
39
- variables: [2, 3],
40
- },
41
- dependants: [7, 8],
42
- };
43
- const optionsReferences = {
44
- '2': {
45
- meta: {
46
- id: 2,
47
- type: 'static',
48
- label: 'Multiple question',
49
- step: '*',
50
- tags: [],
51
- defaultRadio: 4,
52
- multiple: {
53
- enabled: true,
54
- },
55
- validator: {},
56
- },
57
- options: [3, 4],
58
- variables: [2, 3],
59
- },
60
- '3': {
61
- meta: {
62
- id: 3,
63
- type: 'radio',
64
- label: 'Option 1',
65
- step: '*',
66
- tags: [],
67
- defaultRadio: 0,
68
- validator: {},
69
- },
70
- options: [],
71
- variables: [],
72
- },
73
- '4': {
74
- meta: {
75
- id: 4,
76
- type: 'radio',
77
- label: 'Option 2',
78
- step: '*',
79
- tags: [],
80
- defaultRadio: 0,
81
- validator: {},
82
- },
83
- options: [],
84
- variables: [],
85
- },
86
- };
87
- const reducerResult = addMultipleOccurencyReducer(state, {
88
- id: 2,
89
- optionRelations,
90
- optionsReferences,
91
- type: 'ADD_MULTIPLE_OCCURENCY',
92
- });
93
- expect(reducerResult).toStrictEqual({
94
- options: Object.assign(Object.assign({}, state.options), { 2: [true, true], 3: [false, false], 4: [true, false] }),
95
- variables: {
96
- 2: ['', ''],
97
- 3: ['', ''],
98
- },
99
- });
100
- });
101
- });
@@ -1,56 +0,0 @@
1
- import { deleteMultipleOccurencyReducer } from './deleteMultipleOccurency';
2
- const state = {
3
- options: {
4
- 2: [true, true, true],
5
- 3: [false, true, true],
6
- 4: [true, true, false],
7
- },
8
- variables: {
9
- 2: ['21', '22', '23'],
10
- 3: ['31', '32', '33'],
11
- },
12
- };
13
- describe('deleteMultipleOccurencyReducer test suit', () => {
14
- it('Throws an error if optionRelations are undefined', () => {
15
- expect(() => {
16
- deleteMultipleOccurencyReducer(state, {
17
- id: 3,
18
- optionRelations: undefined,
19
- });
20
- }).toThrowError('DELETE_MULTIPLE_OCCURENCY reducer did not recieve complete data when removing ' +
21
- `occurency for 3, please make sure "multiplesActions" middleware is ` +
22
- 'plugged and working properly');
23
- });
24
- it('Deletes a multiple occurency conditions correctly', () => {
25
- const optionRelations = {
26
- options: [],
27
- variables: [],
28
- sections: {},
29
- documents: [],
30
- prefillers: [],
31
- validators: {
32
- options: [],
33
- variables: [],
34
- },
35
- parents: [],
36
- children: {
37
- options: [3, 4],
38
- variables: [2, 3],
39
- },
40
- dependants: [7, 8],
41
- };
42
- const reducerResult = deleteMultipleOccurencyReducer(state, {
43
- id: 2,
44
- index: 1,
45
- optionRelations,
46
- type: 'DELETE_MULTIPLE_OCCURENCY',
47
- });
48
- expect(reducerResult).toStrictEqual({
49
- options: Object.assign(Object.assign({}, state.options), { 2: [true, true], 3: [false, true], 4: [true, false] }),
50
- variables: {
51
- 2: ['21', '23'],
52
- 3: ['31', '33'],
53
- },
54
- });
55
- });
56
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,171 +0,0 @@
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
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,42 +0,0 @@
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
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,15 +0,0 @@
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
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,127 +0,0 @@
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
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,10 +0,0 @@
1
- import { sagasRunner } from './runner';
2
- describe('Runner', () => {
3
- it('Runs sagas', () => {
4
- const SagaMiddleware = {
5
- run: jest.fn(),
6
- };
7
- sagasRunner(SagaMiddleware);
8
- expect(SagaMiddleware.run).toHaveBeenCalled();
9
- });
10
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,74 +0,0 @@
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
- });
@@ -1 +0,0 @@
1
- export {};