@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.
Files changed (211) hide show
  1. package/README.md +1 -376
  2. package/dist/App.d.ts +6 -1
  3. package/dist/App.js +7 -2
  4. package/dist/App.test.js +37 -0
  5. package/dist/Loader.d.ts +1 -1
  6. package/dist/Loader.js +1 -1
  7. package/dist/PluginLoader.d.ts +36 -21
  8. package/dist/PluginLoader.js +227 -90
  9. package/dist/PluginLoader.test.d.ts +1 -0
  10. package/dist/PluginLoader.test.js +52 -0
  11. package/dist/Shimmer.d.ts +11 -8
  12. package/dist/Shimmer.js +4 -4
  13. package/dist/ThemeLoader.d.ts +8 -8
  14. package/dist/ThemeLoader.test.d.ts +2 -0
  15. package/dist/ThemeLoader.test.js +65 -0
  16. package/dist/components/PluginRoute.d.ts +2 -2
  17. package/dist/components/PluginRoute.js +4 -3
  18. package/dist/components/SmartScript.d.ts +6 -2
  19. package/dist/components/SmartScript.js +1 -1
  20. package/dist/components/UserLocked/UserLockedComponent.js +2 -2
  21. package/dist/components/View.d.ts +3 -3
  22. package/dist/components/View.js +7 -5
  23. package/dist/components/View.test.d.ts +2 -0
  24. package/dist/components/View.test.js +84 -0
  25. package/dist/componentsConnectors/connectBox.d.ts +6 -4
  26. package/dist/componentsConnectors/connectBox.test.d.ts +1 -0
  27. package/dist/componentsConnectors/connectBox.test.js +218 -0
  28. package/dist/componentsConnectors/connectDocument.d.ts +6 -4
  29. package/dist/componentsConnectors/connectDocument.test.d.ts +1 -0
  30. package/dist/componentsConnectors/connectDocument.test.js +95 -0
  31. package/dist/componentsConnectors/connectHeader.d.ts +6 -4
  32. package/dist/componentsConnectors/connectMetaTitle.d.ts +7 -3
  33. package/dist/componentsConnectors/connectMetaTitle.test.d.ts +1 -0
  34. package/dist/componentsConnectors/connectMetaTitle.test.js +32 -0
  35. package/dist/componentsConnectors/connectOption.d.ts +7 -5
  36. package/dist/componentsConnectors/connectPagination.d.ts +7 -5
  37. package/dist/componentsConnectors/connectPreview.d.ts +7 -3
  38. package/dist/componentsConnectors/connectProgress.d.ts +6 -4
  39. package/dist/componentsConnectors/connectRootOption.d.ts +7 -5
  40. package/dist/componentsConnectors/connectSection.d.ts +6 -4
  41. package/dist/componentsConnectors/connectSummary.d.ts +9 -5
  42. package/dist/componentsConnectors/connectSummaryItem.d.ts +6 -4
  43. package/dist/componentsConnectors/connectTermsheet.js +1 -1
  44. package/dist/componentsConnectors/connectVariable.d.ts +8 -6
  45. package/dist/componentsConnectors/connectWizardWrapper.d.ts +6 -4
  46. package/dist/componentsConnectors/connector/componentConnector.d.ts +10 -7
  47. package/dist/componentsConnectors/connector/componentConnector.js +3 -3
  48. package/dist/componentsConnectors/library.d.ts +81 -47
  49. package/dist/config.test.d.ts +1 -0
  50. package/dist/config.test.js +54 -0
  51. package/dist/helpers/activitiesHelper.d.ts +3 -3
  52. package/dist/helpers/autocomplete.helper.d.ts +2 -2
  53. package/dist/helpers/autocomplete.helper.js +1 -1
  54. package/dist/helpers/autosave.helper.d.ts +13 -3
  55. package/dist/helpers/autosave.helper.js +70 -3
  56. package/dist/helpers/inpiCitiesHelper.js +1 -1
  57. package/dist/helpers/outputsParsing.d.ts +9 -9
  58. package/dist/hooks/useDispatch.d.ts +1 -1
  59. package/dist/hooks/usePrevious.js +1 -1
  60. package/dist/index.d.ts +0 -3
  61. package/dist/index.js +0 -3
  62. package/dist/libs/ConditionsRunner.d.ts +1 -1
  63. package/dist/libs/Formatter/FormatAddress.d.ts +1 -1
  64. package/dist/libs/InputsInitiator.d.ts +1 -1
  65. package/dist/libs/NumAuto.test.d.ts +1 -0
  66. package/dist/libs/NumAuto.test.js +43 -0
  67. package/dist/libs/PathReader.d.ts +1 -96
  68. package/dist/libs/PathReader.js +2 -1
  69. package/dist/libs/SectionValidity.test.d.ts +1 -0
  70. package/dist/libs/SectionValidity.test.js +116 -0
  71. package/dist/libs/SmartScriptStore.d.ts +6 -6
  72. package/dist/redux/actions/app.d.ts +1 -1
  73. package/dist/redux/actions/app.test.d.ts +1 -0
  74. package/dist/redux/actions/app.test.js +90 -0
  75. package/dist/redux/actions/conditions.test.d.ts +1 -0
  76. package/dist/redux/actions/conditions.test.js +68 -0
  77. package/dist/redux/actions/inputs.d.ts +1 -1
  78. package/dist/redux/actions/inputs.test.d.ts +1 -0
  79. package/dist/redux/actions/inputs.test.js +53 -0
  80. package/dist/redux/actions/library.d.ts +21 -15
  81. package/dist/redux/actions/references.d.ts +2 -2
  82. package/dist/redux/actions/references.test.d.ts +1 -0
  83. package/dist/redux/actions/references.test.js +43 -0
  84. package/dist/redux/actions/sagas/data.d.ts +1 -1
  85. package/dist/redux/actions/sagas/data.test.d.ts +1 -0
  86. package/dist/redux/actions/sagas/data.test.js +11 -0
  87. package/dist/redux/actions/sagas/model.test.d.ts +1 -0
  88. package/dist/redux/actions/sagas/model.test.js +11 -0
  89. package/dist/redux/actions/sagas/user.d.ts +1 -1
  90. package/dist/redux/actions/user.test.d.ts +1 -0
  91. package/dist/redux/actions/user.test.js +16 -0
  92. package/dist/redux/listeners/subscriber.d.ts +1 -1
  93. package/dist/redux/listeners/subscriber.test.d.ts +1 -0
  94. package/dist/redux/listeners/subscriber.test.js +31 -0
  95. package/dist/redux/middlewares/conditionsWatcherMiddleware.d.ts +1 -1
  96. package/dist/redux/middlewares/conditionsWatcherMiddleware.test.d.ts +1 -0
  97. package/dist/redux/middlewares/conditionsWatcherMiddleware.test.js +330 -0
  98. package/dist/redux/middlewares/evaluationsWatcherMiddleware.d.ts +1 -1
  99. package/dist/redux/middlewares/evaluationsWatcherMiddleware.test.d.ts +1 -0
  100. package/dist/redux/middlewares/evaluationsWatcherMiddleware.test.js +242 -0
  101. package/dist/redux/middlewares/mandatoriesWatcherMiddleware.d.ts +1 -1
  102. package/dist/redux/middlewares/multiplesActionsMiddleware.d.ts +1 -1
  103. package/dist/redux/middlewares/multiplesActionsMiddleware.test.d.ts +1 -0
  104. package/dist/redux/middlewares/multiplesActionsMiddleware.test.js +209 -0
  105. package/dist/redux/middlewares/paginationWatcherMiddleware.d.ts +2 -2
  106. package/dist/redux/middlewares/pluginsHookMiddleware.d.ts +2 -1
  107. package/dist/redux/middlewares/pluginsHookMiddleware.js +7 -1
  108. package/dist/redux/middlewares/prefillerWatcherMiddleware.d.ts +1 -1
  109. package/dist/redux/middlewares/prefillerWatcherMiddleware.test.d.ts +1 -0
  110. package/dist/redux/middlewares/prefillerWatcherMiddleware.test.js +84 -0
  111. package/dist/redux/middlewares/smartscriptMiddleware.d.ts +1 -1
  112. package/dist/redux/middlewares/smartscriptMiddleware.js +2 -2
  113. package/dist/redux/middlewares/thirdpartyScriptsMiddleware.d.ts +1 -1
  114. package/dist/redux/reducers/app/instance.test.d.ts +1 -0
  115. package/dist/redux/reducers/app/instance.test.js +75 -0
  116. package/dist/redux/reducers/app/meta.test.d.ts +1 -0
  117. package/dist/redux/reducers/app/meta.test.js +70 -0
  118. package/dist/redux/reducers/app/pagination/updateAvailableAppStates.js +2 -1
  119. package/dist/redux/reducers/app/pagination.test.d.ts +1 -0
  120. package/dist/redux/reducers/app/pagination.test.js +134 -0
  121. package/dist/redux/reducers/app/wizard.test.d.ts +1 -0
  122. package/dist/redux/reducers/app/wizard.test.js +53 -0
  123. package/dist/redux/reducers/app.d.ts +6 -6
  124. package/dist/redux/reducers/app.test.d.ts +1 -0
  125. package/dist/redux/reducers/app.test.js +175 -0
  126. package/dist/redux/reducers/conditions/addMultipleOccurency.test.d.ts +1 -0
  127. package/dist/redux/reducers/conditions/addMultipleOccurency.test.js +108 -0
  128. package/dist/redux/reducers/conditions/deleteMultipleOccurency.test.d.ts +1 -0
  129. package/dist/redux/reducers/conditions/deleteMultipleOccurency.test.js +77 -0
  130. package/dist/redux/reducers/conditions/updateDocumentConditions.test.d.ts +1 -0
  131. package/dist/redux/reducers/conditions/updateDocumentConditions.test.js +35 -0
  132. package/dist/redux/reducers/conditions/updateOptionValidatorCondition.test.d.ts +1 -0
  133. package/dist/redux/reducers/conditions/updateOptionValidatorCondition.test.js +35 -0
  134. package/dist/redux/reducers/conditions/updateVariableValidatorCondition.test.d.ts +1 -0
  135. package/dist/redux/reducers/conditions/updateVariableValidatorCondition.test.js +35 -0
  136. package/dist/redux/reducers/conditions.test.d.ts +1 -0
  137. package/dist/redux/reducers/conditions.test.js +196 -0
  138. package/dist/redux/reducers/inputs/addMultipleOccurency.test.d.ts +1 -0
  139. package/dist/redux/reducers/inputs/addMultipleOccurency.test.js +101 -0
  140. package/dist/redux/reducers/inputs/deleteMultipleOccurency.test.d.ts +1 -0
  141. package/dist/redux/reducers/inputs/deleteMultipleOccurency.test.js +56 -0
  142. package/dist/redux/reducers/inputs.test.d.ts +1 -0
  143. package/dist/redux/reducers/inputs.test.js +171 -0
  144. package/dist/redux/reducers/references.js +0 -2
  145. package/dist/redux/reducers/user.test.d.ts +1 -0
  146. package/dist/redux/reducers/user.test.js +42 -0
  147. package/dist/redux/routerHistore.test.d.ts +1 -0
  148. package/dist/redux/routerHistore.test.js +15 -0
  149. package/dist/redux/sagas/fetchModel.test.d.ts +1 -0
  150. package/dist/redux/sagas/fetchModel.test.js +127 -0
  151. package/dist/redux/sagas/runner.test.d.ts +1 -0
  152. package/dist/redux/sagas/runner.test.js +10 -0
  153. package/dist/redux/sagas/saveData.test.d.ts +1 -0
  154. package/dist/redux/sagas/saveData.test.js +74 -0
  155. package/dist/redux/sagas/setDefaults.test.d.ts +1 -0
  156. package/dist/redux/sagas/setDefaults.test.js +73 -0
  157. package/dist/redux/selectors/app.test.d.ts +1 -0
  158. package/dist/redux/selectors/app.test.js +99 -0
  159. package/dist/redux/selectors/conditions.test.d.ts +1 -0
  160. package/dist/redux/selectors/conditions.test.js +70 -0
  161. package/dist/redux/selectors/inputs.d.ts +1 -1
  162. package/dist/redux/selectors/inputs.test.d.ts +1 -0
  163. package/dist/redux/selectors/inputs.test.js +44 -0
  164. package/dist/redux/selectors/references.test.d.ts +1 -0
  165. package/dist/redux/selectors/references.test.js +471 -0
  166. package/dist/redux/selectors/selectors.d.ts +4 -4
  167. package/dist/redux/selectors/selectors.test.d.ts +1 -0
  168. package/dist/redux/selectors/selectors.test.js +16 -0
  169. package/dist/redux/selectors/user.test.d.ts +1 -0
  170. package/dist/redux/selectors/user.test.js +29 -0
  171. package/dist/redux/store.d.ts +3 -5
  172. package/dist/redux/store.js +1 -2
  173. package/dist/redux/store.test.d.ts +1 -0
  174. package/dist/redux/store.test.js +16 -0
  175. package/dist/service/api.manager.d.ts +2 -2
  176. package/dist/service/autocomplete.manager.d.ts +3 -3
  177. package/dist/service/autocomplete.manager.js +3 -3
  178. package/dist/tests-misc/plugins/jestTestPlugin/after.js +1 -1
  179. package/dist/tests-misc/plugins/jestTestPlugin/before.js +1 -1
  180. package/dist/tests-misc/plugins/jestTestPlugin/title.js +1 -1
  181. package/dist/tests-misc/themes/jestTestTheme/components/EmailComponent.d.ts +1 -1
  182. package/dist/tests-misc/themes/jestTestTheme/components/EmailComponent.js +1 -1
  183. package/dist/tests-misc/themes/jestTestTheme/components/TermsheetComponent.d.ts +1 -1
  184. package/dist/tests-misc/themes/jestTestTheme/components/TermsheetComponent.js +1 -1
  185. package/dist/tests-misc/themes/jestTestTheme/components/WizardComponent.d.ts +1 -1
  186. package/dist/tests-misc/themes/jestTestTheme/components/WizardComponent.js +1 -1
  187. package/dist/types/Actions.type.d.ts +6 -70
  188. package/dist/types/Components.type.d.ts +2 -3
  189. package/dist/types/PluginConfig.type.d.ts +52 -18
  190. package/dist/types/State.type.d.ts +2 -2
  191. package/dist/types/config.type.d.ts +1 -1
  192. package/dist/types/getActions.type.d.ts +1 -1
  193. package/dist/types/getConnectors.type.d.ts +2 -2
  194. package/dist/types/getSelectors.type.d.ts +1 -1
  195. package/package.json +22 -45
  196. package/dist/WizardCore.d.ts +0 -29
  197. package/dist/WizardCore.js +0 -153
  198. package/dist/app.entry.d.ts +0 -2
  199. package/dist/app.entry.js +0 -1
  200. package/dist/routing/adapters/nextjs.adapter.d.ts +0 -3
  201. package/dist/routing/adapters/nextjs.adapter.js +0 -61
  202. package/dist/routing/adapters/reactRouter.adapter.d.ts +0 -2
  203. package/dist/routing/adapters/reactRouter.adapter.js +0 -16
  204. package/dist/routing/context.d.ts +0 -14
  205. package/dist/routing/context.js +0 -23
  206. package/dist/routing/index.d.ts +0 -4
  207. package/dist/routing/index.js +0 -4
  208. package/dist/routing/types.d.ts +0 -26
  209. package/dist/wizardcore.entry.d.ts +0 -3
  210. package/dist/wizardcore.entry.js +0 -2
  211. /package/dist/{routing/types.js → App.test.d.ts} +0 -0
@@ -0,0 +1,75 @@
1
+ import { initInstanceReducer } from './instance/initInstance';
2
+ import { updateInstancePaidReducer } from './instance/updateInstancePaid';
3
+ import { setDataStatusReducer } from './instance/setDataStatus';
4
+ const appStateMock = {
5
+ meta: {
6
+ fetchStatus: 'succeeded',
7
+ id: 0,
8
+ prefix: '',
9
+ permalink: 'permalink',
10
+ title: 'title',
11
+ modelVersion: 1,
12
+ productType: 'demarche',
13
+ },
14
+ wizard: {
15
+ availableSections: [1, 2, 3],
16
+ currentSectionId: 1,
17
+ },
18
+ pagination: {
19
+ currentPage: 1,
20
+ greatestPage: 1,
21
+ currentAppState: 'wizard',
22
+ availableAppStates: ['wizard'],
23
+ isFirstPage: true,
24
+ isLastPage: false,
25
+ totalPages: 4,
26
+ },
27
+ instance: {
28
+ dataStatus: 'saved',
29
+ uniqid: '3jHD42343sDE',
30
+ isPaid: false,
31
+ steps: '*',
32
+ },
33
+ customization: {},
34
+ };
35
+ describe('App Instance Reducer', () => {
36
+ it('initInstance Reducer', () => {
37
+ const reducer = initInstanceReducer(appStateMock, {
38
+ type: 'INIT_INSTANCE',
39
+ dataStatus: 'saved',
40
+ uniqid: '3jHD42343sDE',
41
+ isPaid: true,
42
+ steps: '*',
43
+ });
44
+ return expect(reducer).toStrictEqual(Object.assign(Object.assign({}, appStateMock), { instance: {
45
+ dataStatus: 'saved',
46
+ uniqid: '3jHD42343sDE',
47
+ companyUuid: undefined,
48
+ employeeUuid: undefined,
49
+ filename: undefined,
50
+ isPaid: true,
51
+ steps: '*',
52
+ } }));
53
+ });
54
+ it('updateInstancePaid Reducer', () => {
55
+ const reducer = updateInstancePaidReducer(appStateMock, {
56
+ type: 'UPDATE_INSTANCE_PAID',
57
+ isPaid: false,
58
+ });
59
+ expect(reducer).toEqual(appStateMock);
60
+ });
61
+ it('updateInstancePaid Reducer should not change state if isPaid did not change', () => {
62
+ const reducer = updateInstancePaidReducer(appStateMock, {
63
+ type: 'UPDATE_INSTANCE_PAID',
64
+ isPaid: true,
65
+ });
66
+ expect(reducer).toStrictEqual(Object.assign(Object.assign({}, appStateMock), { instance: Object.assign(Object.assign({}, appStateMock.instance), { uniqid: '3jHD42343sDE', isPaid: true }) }));
67
+ });
68
+ it('setDataStatus Reducer', () => {
69
+ const reducer = setDataStatusReducer(appStateMock, {
70
+ type: 'SET_DATA_STATUS',
71
+ dataStatus: 'unsaved',
72
+ });
73
+ return expect(reducer).toStrictEqual(Object.assign(Object.assign({}, appStateMock), { instance: Object.assign(Object.assign({}, appStateMock.instance), { dataStatus: 'unsaved' }) }));
74
+ });
75
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,70 @@
1
+ import { initMetaReducer } from './meta/initMeta';
2
+ import { fetchModelSucceededReducer } from './meta/fetchModelSucceeded';
3
+ import { fetchModelFailedReducer } from './meta/fetchModelFailed';
4
+ const appStateMock = {
5
+ meta: {
6
+ fetchStatus: 'succeeded',
7
+ id: 0,
8
+ prefix: '',
9
+ permalink: 'permalink',
10
+ title: 'title',
11
+ modelVersion: 1,
12
+ productType: 'demarche',
13
+ },
14
+ wizard: {
15
+ availableSections: [1, 2, 3],
16
+ currentSectionId: 1,
17
+ },
18
+ pagination: {
19
+ currentPage: 1,
20
+ greatestPage: 1,
21
+ currentAppState: 'wizard',
22
+ availableAppStates: ['wizard'],
23
+ isFirstPage: true,
24
+ isLastPage: false,
25
+ totalPages: 4,
26
+ },
27
+ instance: {
28
+ dataStatus: 'saved',
29
+ uniqid: '3jHD42343sDE',
30
+ isPaid: false,
31
+ steps: '*',
32
+ },
33
+ customization: {},
34
+ };
35
+ describe('App Meta Reducer', () => {
36
+ it('initMeta Reducer', () => {
37
+ const reducer = initMetaReducer(appStateMock, {
38
+ type: 'INIT_META',
39
+ id: 123,
40
+ prefix: '',
41
+ permalink: 'permalink',
42
+ title: 'title',
43
+ modelVersion: 1,
44
+ productType: 'demarche',
45
+ metadata: {
46
+ metaTypology: "contract"
47
+ }
48
+ });
49
+ return expect(reducer).toStrictEqual(Object.assign(Object.assign({}, appStateMock), { meta: {
50
+ fetchStatus: 'succeeded',
51
+ id: 123,
52
+ prefix: '',
53
+ permalink: 'permalink',
54
+ title: 'title',
55
+ modelVersion: 1,
56
+ productType: 'demarche',
57
+ metadata: {
58
+ metaTypology: "contract"
59
+ }
60
+ } }));
61
+ });
62
+ it('fetchModelSucceeded Reducer', () => {
63
+ const reducer = fetchModelSucceededReducer(appStateMock);
64
+ return expect(reducer).toStrictEqual(Object.assign(Object.assign({}, appStateMock), { meta: Object.assign(Object.assign({}, appStateMock.meta), { fetchStatus: 'succeeded' }) }));
65
+ });
66
+ it('fetchModelFailed Reducer', () => {
67
+ const reducer = fetchModelFailedReducer(appStateMock);
68
+ return expect(reducer).toStrictEqual(Object.assign(Object.assign({}, appStateMock), { meta: Object.assign(Object.assign({}, appStateMock.meta), { fetchStatus: 'failed' }) }));
69
+ });
70
+ });
@@ -1,7 +1,8 @@
1
+ import { registerPluginsAppStates } from "../../../../PluginLoader";
1
2
  export const updateAvailableAppStatesReducer = (state, action) => {
2
3
  let availableAppStates;
3
4
  if (!action.ingorePluginAppStateReset) {
4
- availableAppStates = action.availableAppStates;
5
+ availableAppStates = registerPluginsAppStates(action.availableAppStates);
5
6
  }
6
7
  else {
7
8
  availableAppStates = action.availableAppStates;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,134 @@
1
+ import { initPaginationReducer } from './pagination/initPagination';
2
+ import { goPageReducer } from './pagination/goPage';
3
+ import { goNextPageReducer } from './pagination/goNextPage';
4
+ import { goPreviousPageReducer } from './pagination/goPreviousPage';
5
+ const appStateMock = {
6
+ meta: {
7
+ fetchStatus: 'succeeded',
8
+ id: 0,
9
+ prefix: '',
10
+ permalink: 'permalink',
11
+ title: 'title',
12
+ modelVersion: 1,
13
+ productType: 'demarche',
14
+ },
15
+ wizard: {
16
+ availableSections: [1, 2, 3],
17
+ currentSectionId: 1,
18
+ },
19
+ pagination: {
20
+ currentPage: 1,
21
+ greatestPage: 1,
22
+ currentAppState: 'one',
23
+ availableAppStates: ['one', 'wizard', 'three', 'four'],
24
+ isFirstPage: true,
25
+ isLastPage: false,
26
+ totalPages: 6,
27
+ },
28
+ instance: {
29
+ dataStatus: 'saved',
30
+ uniqid: '3jHD42343sDE',
31
+ isPaid: false,
32
+ steps: '*',
33
+ },
34
+ customization: {},
35
+ };
36
+ describe('Pagination reducers test suit', () => {
37
+ it('initPaginationReducer', () => {
38
+ const state = Object.assign(Object.assign({}, appStateMock), { pagination: Object.assign(Object.assign({}, appStateMock.pagination), { currentPage: 2, greatestPage: 2 }), wizard: {
39
+ currentSectionId: 2,
40
+ availableSections: [1, 2, 5],
41
+ } });
42
+ const reducer = initPaginationReducer(state, {
43
+ type: 'INIT_PAGINATION',
44
+ currentSectionId: 1,
45
+ currentPage: 3,
46
+ greatestPage: 3,
47
+ availableSections: [1, 2, 3],
48
+ availableAppStates: ['one', 'wizard', 'three', 'four'],
49
+ currentAppState: 'one',
50
+ });
51
+ return expect(reducer).toStrictEqual(Object.assign(Object.assign({}, state), { pagination: Object.assign(Object.assign({}, state.pagination), { currentPage: 3, greatestPage: 3, isFirstPage: false, isLastPage: false }), wizard: {
52
+ currentSectionId: 1,
53
+ availableSections: [1, 2, 3],
54
+ } }));
55
+ });
56
+ it('goPageReducer move to wizard', () => {
57
+ const state = Object.assign(Object.assign({}, appStateMock), { pagination: Object.assign(Object.assign({}, appStateMock.pagination), { currentPage: 2, greatestPage: 2 }), wizard: {
58
+ currentSectionId: 2,
59
+ availableSections: [1, 2, 5],
60
+ } });
61
+ const reducer = goPageReducer(state, {
62
+ type: 'GO_PAGE',
63
+ currentPage: 3,
64
+ pushHistory: false,
65
+ });
66
+ return expect(reducer).toStrictEqual(Object.assign(Object.assign({}, appStateMock), { pagination: Object.assign(Object.assign({}, appStateMock.pagination), { currentPage: 3, greatestPage: 3, isFirstPage: false, isLastPage: false, currentAppState: 'wizard' }), wizard: Object.assign(Object.assign({}, appStateMock.wizard), { currentSectionId: 2, availableSections: [1, 2, 5] }) }));
67
+ });
68
+ it('goPageReducer go to "one"', () => {
69
+ const state = Object.assign(Object.assign({}, appStateMock), { pagination: Object.assign(Object.assign({}, appStateMock.pagination), { currentPage: 2, greatestPage: 4 }) });
70
+ const reducer = goPageReducer(state, {
71
+ type: 'GO_PAGE',
72
+ currentPage: 1,
73
+ pushHistory: false,
74
+ });
75
+ return expect(reducer).toStrictEqual(Object.assign(Object.assign({}, appStateMock), { pagination: Object.assign(Object.assign({}, appStateMock.pagination), { currentPage: 1, greatestPage: 4, isFirstPage: true, isLastPage: false, currentAppState: 'one' }) }));
76
+ });
77
+ it('goPageReducer go to "three"', () => {
78
+ const state = Object.assign(Object.assign({}, appStateMock), { pagination: Object.assign(Object.assign({}, appStateMock.pagination), { currentPage: 2, greatestPage: 3 }) });
79
+ const reducer = goPageReducer(state, {
80
+ type: 'GO_PAGE',
81
+ currentPage: 5,
82
+ pushHistory: false,
83
+ });
84
+ return expect(reducer).toStrictEqual(Object.assign(Object.assign({}, appStateMock), { pagination: Object.assign(Object.assign({}, appStateMock.pagination), { currentPage: 5, greatestPage: 5, isFirstPage: false, isLastPage: false, currentAppState: 'three' }), wizard: Object.assign(Object.assign({}, state.wizard), { currentSectionId: 3 }) }));
85
+ });
86
+ it('goNextPageReducer from 0 to "one"', () => {
87
+ const state = Object.assign(Object.assign({}, appStateMock), { pagination: Object.assign(Object.assign({}, appStateMock.pagination), { currentPage: 0, greatestPage: 5 }), wizard: {
88
+ currentSectionId: 1,
89
+ availableSections: [1, 4, 3],
90
+ } });
91
+ const reducer = goNextPageReducer(state);
92
+ return expect(reducer).toStrictEqual(Object.assign(Object.assign({}, state), { pagination: Object.assign(Object.assign({}, state.pagination), { currentPage: 1, greatestPage: 5, isFirstPage: false, currentAppState: 'one' }), wizard: Object.assign(Object.assign({}, state.wizard), { currentSectionId: 1 }) }));
93
+ });
94
+ it('goNextPageReducer from "wizard to "three"', () => {
95
+ const state = Object.assign(Object.assign({}, appStateMock), { pagination: Object.assign(Object.assign({}, appStateMock.pagination), { currentPage: 4, greatestPage: 5, currentAppState: 'wizard' }), wizard: {
96
+ currentSectionId: 3,
97
+ availableSections: [1, 4, 3],
98
+ } });
99
+ const reducer = goNextPageReducer(state);
100
+ return expect(reducer).toStrictEqual(Object.assign(Object.assign({}, state), { pagination: Object.assign(Object.assign({}, state.pagination), { currentPage: 5, greatestPage: 5, isFirstPage: false, currentAppState: 'three' }), wizard: Object.assign(Object.assign({}, state.wizard), { currentSectionId: 3 }) }));
101
+ });
102
+ it('goNextPageReducer should not change state on last page', () => {
103
+ const state = Object.assign(Object.assign({}, appStateMock), { pagination: Object.assign(Object.assign({}, appStateMock.pagination), { currentPage: 6, greatestPage: 6, currentAppState: 'four' }), wizard: {
104
+ currentSectionId: 3,
105
+ availableSections: [1, 4, 3],
106
+ } });
107
+ const reducer = goNextPageReducer(state);
108
+ return expect(reducer).toEqual(state);
109
+ });
110
+ it('goPreviousPageReducer when page > 1', () => {
111
+ const state = Object.assign(Object.assign({}, appStateMock), { pagination: Object.assign(Object.assign({}, appStateMock.pagination), { currentPage: 2, greatestPage: 5 }), wizard: {
112
+ currentSectionId: 2,
113
+ availableSections: [1, 2, 3],
114
+ } });
115
+ const reducer = goPreviousPageReducer(state);
116
+ return expect(reducer).toStrictEqual(Object.assign(Object.assign({}, state), { pagination: Object.assign(Object.assign({}, state.pagination), { currentPage: 1, greatestPage: 5 }), wizard: Object.assign(Object.assign({}, state.wizard), { currentSectionId: 1 }) }));
117
+ });
118
+ it('goPreviousPageReducer when page =< 1', () => {
119
+ const currentState = Object.assign(Object.assign({}, appStateMock), { pagination: Object.assign(Object.assign({}, appStateMock.pagination), { currentPage: 1, greatestPage: 2 }), wizard: {
120
+ currentSectionId: 1,
121
+ availableSections: [1, 2, 3],
122
+ } });
123
+ const reducer = goPreviousPageReducer(currentState);
124
+ return expect(reducer).toStrictEqual(Object.assign(Object.assign({}, currentState), { pagination: Object.assign(Object.assign({}, currentState.pagination), { currentPage: 1, greatestPage: 2 }), wizard: Object.assign(Object.assign({}, currentState.wizard), { currentSectionId: 1 }) }));
125
+ });
126
+ it('goPreviousPageReducer from "four" to "three"', () => {
127
+ const currentState = Object.assign(Object.assign({}, appStateMock), { pagination: Object.assign(Object.assign({}, appStateMock.pagination), { currentPage: 6, greatestPage: 6, currentAppState: 'four', isFirstPage: false, isLastPage: true }), wizard: {
128
+ currentSectionId: 3,
129
+ availableSections: [1, 2, 3],
130
+ } });
131
+ const reducer = goPreviousPageReducer(currentState);
132
+ return expect(reducer).toStrictEqual(Object.assign(Object.assign({}, currentState), { pagination: Object.assign(Object.assign({}, currentState.pagination), { currentPage: 5, greatestPage: 6, currentAppState: 'three', isLastPage: false }) }));
133
+ });
134
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,53 @@
1
+ import { updateAvailableSectionsReducer } from './wizard/updateAvailableSections';
2
+ const appStateMock = {
3
+ meta: {
4
+ fetchStatus: 'succeeded',
5
+ id: 0,
6
+ prefix: '',
7
+ permalink: 'permalink',
8
+ title: 'title',
9
+ modelVersion: 1,
10
+ productType: 'demarche',
11
+ },
12
+ wizard: {
13
+ availableSections: [1, 2, 3],
14
+ currentSectionId: 1,
15
+ },
16
+ pagination: {
17
+ currentPage: 1,
18
+ greatestPage: 1,
19
+ currentAppState: 'wizard',
20
+ availableAppStates: ['wizard', 'termsheet'],
21
+ isFirstPage: true,
22
+ isLastPage: false,
23
+ totalPages: 4,
24
+ },
25
+ instance: {
26
+ dataStatus: 'saved',
27
+ uniqid: '3jHD42343sDE',
28
+ isPaid: false,
29
+ steps: '*',
30
+ },
31
+ customization: {},
32
+ };
33
+ describe('Wizard reducers test suit', () => {
34
+ it('updateAvailableSectionsReducer', () => {
35
+ const state = Object.assign(Object.assign({}, appStateMock), { wizard: Object.assign(Object.assign({}, appStateMock.wizard), { availableSections: [1, 2, 3], currentSectionId: 1 }) });
36
+ const reducer = updateAvailableSectionsReducer(state, {
37
+ type: 'UPDATE_AVAILABLE_SECTIONS',
38
+ availableSections: [1, 4, 5, 6],
39
+ });
40
+ return expect(reducer).toStrictEqual(Object.assign(Object.assign({}, appStateMock), { pagination: Object.assign(Object.assign({}, appStateMock.pagination), { totalPages: 5 }), wizard: {
41
+ currentSectionId: 1,
42
+ availableSections: [1, 4, 5, 6],
43
+ } }));
44
+ });
45
+ it('updateAvailableSectionsReducer should not update state if sections did not change', () => {
46
+ const state = Object.assign(Object.assign({}, appStateMock), { wizard: Object.assign(Object.assign({}, appStateMock.wizard), { availableSections: [1, 2, 3], currentSectionId: 1 }) });
47
+ const reducer = updateAvailableSectionsReducer(state, {
48
+ type: 'UPDATE_AVAILABLE_SECTIONS',
49
+ availableSections: [1, 2, 3],
50
+ });
51
+ return expect(reducer).toEqual(state);
52
+ });
53
+ });
@@ -1,9 +1,9 @@
1
1
  import type { ActionsType } from "../../types/Actions.type";
2
2
  import type { StateType } from "../../types/State.type";
3
- export type PaginationReducerActions = ActionsType.App.initPagination | ActionsType.App.goPage | ActionsType.App.goNextPage | ActionsType.App.goPreviousPage | ActionsType.App.updateAvailableAppStates;
4
- export type WizardReducerActions = ActionsType.App.updateAvailableSections;
5
- export type CustomizationsReducerActions = ActionsType.App.initCustomizationMeta | ActionsType.App.initCustomizationAutoDefault;
6
- export type MetaReducerActions = ActionsType.App.initMeta | ActionsType.App.fetchModelSucceeded | ActionsType.App.fetchModelFailed;
7
- export type InstanceReducerActions = ActionsType.App.initInstance | ActionsType.App.updateInstancePaid | ActionsType.App.setDataStatus;
8
- export type appReducerActions = PaginationReducerActions | MetaReducerActions | WizardReducerActions | CustomizationsReducerActions | InstanceReducerActions | ActionsType.App.resetState;
3
+ export declare type PaginationReducerActions = ActionsType.App.initPagination | ActionsType.App.goPage | ActionsType.App.goNextPage | ActionsType.App.goPreviousPage | ActionsType.App.updateAvailableAppStates;
4
+ export declare type WizardReducerActions = ActionsType.App.updateAvailableSections;
5
+ export declare type CustomizationsReducerActions = ActionsType.App.initCustomizationMeta | ActionsType.App.initCustomizationAutoDefault;
6
+ export declare type MetaReducerActions = ActionsType.App.initMeta | ActionsType.App.fetchModelSucceeded | ActionsType.App.fetchModelFailed;
7
+ export declare type InstanceReducerActions = ActionsType.App.initInstance | ActionsType.App.updateInstancePaid | ActionsType.App.setDataStatus;
8
+ export declare type appReducerActions = PaginationReducerActions | MetaReducerActions | WizardReducerActions | CustomizationsReducerActions | InstanceReducerActions | ActionsType.App.resetState;
9
9
  export declare const appReducer: (state: StateType.App | undefined, action: appReducerActions) => StateType.App;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,175 @@
1
+ import { appReducer } from './app';
2
+ const appStateMock = {
3
+ meta: {
4
+ fetchStatus: 'waiting',
5
+ id: 0,
6
+ prefix: '',
7
+ permalink: 'permalink',
8
+ title: 'title',
9
+ modelVersion: 1,
10
+ productType: 'demarche',
11
+ metadata: {
12
+ metaTypology: "contract"
13
+ }
14
+ },
15
+ wizard: {
16
+ availableSections: [1, 2, 3],
17
+ currentSectionId: 1,
18
+ },
19
+ pagination: {
20
+ currentPage: 1,
21
+ greatestPage: 1,
22
+ currentAppState: 'wizard',
23
+ availableAppStates: ['wizard'],
24
+ isFirstPage: true,
25
+ isLastPage: false,
26
+ totalPages: 3,
27
+ },
28
+ instance: {
29
+ companyUuid: undefined,
30
+ employeeUuid: undefined,
31
+ filename: undefined,
32
+ dataStatus: 'saved',
33
+ uniqid: '3jHD42343sDE',
34
+ isPaid: false,
35
+ steps: '*',
36
+ },
37
+ customization: {},
38
+ };
39
+ describe('App Reducer test suit', () => {
40
+ it('Combines meta reducer', () => {
41
+ const reducer = appReducer(appStateMock, {
42
+ type: 'INIT_META',
43
+ prefix: '',
44
+ id: 123,
45
+ permalink: 'some-other-permalink',
46
+ title: 'Some other title',
47
+ modelVersion: 1,
48
+ productType: 'demarche',
49
+ metadata: {
50
+ metaTypology: "contract"
51
+ }
52
+ });
53
+ return expect(reducer).toStrictEqual(Object.assign(Object.assign({}, appStateMock), { meta: {
54
+ fetchStatus: 'waiting',
55
+ id: 123,
56
+ prefix: '',
57
+ permalink: 'some-other-permalink',
58
+ title: 'Some other title',
59
+ modelVersion: 1,
60
+ productType: 'demarche',
61
+ metadata: {
62
+ metaTypology: "contract"
63
+ }
64
+ } }));
65
+ });
66
+ it('Combines pagination reducer', () => {
67
+ const reducer = appReducer(appStateMock, {
68
+ type: 'INIT_PAGINATION',
69
+ currentPage: 11,
70
+ currentSectionId: 13,
71
+ greatestPage: 11,
72
+ availableSections: [1, 12, 13, 14, 15],
73
+ currentAppState: 'wizard',
74
+ availableAppStates: ['wizard'],
75
+ });
76
+ return expect(reducer).toStrictEqual(Object.assign(Object.assign({}, appStateMock), { pagination: {
77
+ currentPage: 11,
78
+ greatestPage: 11,
79
+ currentAppState: 'wizard',
80
+ availableAppStates: ['wizard'],
81
+ isFirstPage: false,
82
+ isLastPage: false,
83
+ totalPages: 5,
84
+ }, wizard: {
85
+ currentSectionId: 13,
86
+ availableSections: [1, 12, 13, 14, 15],
87
+ } }));
88
+ });
89
+ it('Combines instance reducer', () => {
90
+ const reducer = appReducer(appStateMock, {
91
+ type: 'INIT_INSTANCE',
92
+ dataStatus: 'saved',
93
+ uniqid: 'SomeUniqid123',
94
+ isPaid: true,
95
+ steps: '*',
96
+ });
97
+ return expect(reducer).toStrictEqual(Object.assign(Object.assign({}, appStateMock), { instance: {
98
+ dataStatus: 'saved',
99
+ uniqid: 'SomeUniqid123',
100
+ employeeUuid: undefined,
101
+ companyUuid: undefined,
102
+ filename: undefined,
103
+ isPaid: true,
104
+ steps: '*',
105
+ } }));
106
+ });
107
+ it('App Reducer INIT_INSTANCE Action', () => {
108
+ const reducer = appReducer(appStateMock, {
109
+ type: 'INIT_INSTANCE',
110
+ dataStatus: 'saved',
111
+ uniqid: '3jHD42343sDE',
112
+ isPaid: false,
113
+ steps: '*',
114
+ });
115
+ return expect(reducer).toStrictEqual(Object.assign(Object.assign({}, appStateMock), { instance: {
116
+ dataStatus: 'saved',
117
+ employeeUuid: undefined,
118
+ companyUuid: undefined,
119
+ filename: undefined,
120
+ uniqid: '3jHD42343sDE',
121
+ isPaid: false,
122
+ steps: '*',
123
+ } }));
124
+ });
125
+ it('App Reducer UPDATE_INSTANCE_PAID Action', () => {
126
+ const reducer = appReducer(appStateMock, {
127
+ type: 'UPDATE_INSTANCE_PAID',
128
+ isPaid: true,
129
+ });
130
+ return expect(reducer).toStrictEqual(Object.assign(Object.assign({}, appStateMock), { instance: Object.assign(Object.assign({}, appStateMock.instance), { isPaid: true }) }));
131
+ });
132
+ it('appReducer INIT_PAGINATION Action', () => {
133
+ const reducer = appReducer(appStateMock, {
134
+ type: 'INIT_PAGINATION',
135
+ currentSectionId: 32,
136
+ currentPage: 32,
137
+ greatestPage: 32,
138
+ availableSections: [32, 2, 3],
139
+ availableAppStates: ['wizard'],
140
+ currentAppState: 'wizard',
141
+ });
142
+ return expect(reducer).toStrictEqual(Object.assign(Object.assign({}, appStateMock), { pagination: Object.assign(Object.assign({}, appStateMock.pagination), { currentPage: 32, greatestPage: 32, availableAppStates: ['wizard'], currentAppState: 'wizard', isFirstPage: false }), wizard: Object.assign(Object.assign({}, appStateMock.wizard), { currentSectionId: 32, availableSections: [32, 2, 3] }) }));
143
+ });
144
+ it('appReducer GO_PAGE Action', () => {
145
+ const state = Object.assign(Object.assign({}, appStateMock), { pagination: Object.assign(Object.assign({}, appStateMock.pagination), { currentPage: 1, greatestPage: 1 }), wizard: Object.assign(Object.assign({}, appStateMock.wizard), { currentSectionId: 1, availableSections: [1, 6, 3] }) });
146
+ const reducer = appReducer(state, {
147
+ type: 'GO_PAGE',
148
+ currentPage: 2,
149
+ pushHistory: false,
150
+ });
151
+ return expect(reducer).toStrictEqual(Object.assign(Object.assign({}, appStateMock), { pagination: Object.assign(Object.assign({}, appStateMock.pagination), { currentPage: 2, greatestPage: 2, isFirstPage: false }), wizard: Object.assign(Object.assign({}, appStateMock.wizard), { currentSectionId: 6, availableSections: [1, 6, 3] }) }));
152
+ });
153
+ it('appReducer UPDATE_AVAILABLE_SECTIONS Action', () => {
154
+ const state = Object.assign(Object.assign({}, appStateMock), { pagination: Object.assign(Object.assign({}, appStateMock.pagination), { currentPage: 1, greatestPage: 14 }), wizard: Object.assign(Object.assign({}, appStateMock.wizard), { currentSectionId: 1, availableSections: [1, 2, 3] }) });
155
+ const reducer = appReducer(state, {
156
+ type: 'UPDATE_AVAILABLE_SECTIONS',
157
+ availableSections: [1, 3, 4],
158
+ });
159
+ return expect(reducer).toStrictEqual(Object.assign(Object.assign({}, appStateMock), { pagination: Object.assign(Object.assign({}, appStateMock.pagination), { currentPage: 1, greatestPage: 14 }), wizard: Object.assign(Object.assign({}, appStateMock.wizard), { currentSectionId: 1, availableSections: [1, 3, 4] }) }));
160
+ });
161
+ it('appReducer GO_NEXT_PAGE Action', () => {
162
+ const state = Object.assign(Object.assign({}, appStateMock), { pagination: Object.assign(Object.assign({}, appStateMock.pagination), { currentPage: 1, greatestPage: 1 }), wizard: Object.assign(Object.assign({}, appStateMock.wizard), { currentSectionId: 1, availableSections: [1, 6, 3] }) });
163
+ const reducer = appReducer(state, {
164
+ type: 'GO_NEXT_PAGE',
165
+ });
166
+ return expect(reducer).toStrictEqual(Object.assign(Object.assign({}, appStateMock), { pagination: Object.assign(Object.assign({}, appStateMock.pagination), { currentPage: 2, greatestPage: 2, isFirstPage: false }), wizard: Object.assign(Object.assign({}, appStateMock.wizard), { currentSectionId: 6, availableSections: [1, 6, 3] }) }));
167
+ });
168
+ it('appReducer GO_PREVIOUS_PAGE Action', () => {
169
+ const state = Object.assign(Object.assign({}, appStateMock), { pagination: Object.assign(Object.assign({}, appStateMock.pagination), { currentPage: 3, greatestPage: 3, isFirstPage: false }), wizard: Object.assign(Object.assign({}, appStateMock.wizard), { currentSectionId: 3, availableSections: [1, 5, 3] }) });
170
+ const reducer = appReducer(state, {
171
+ type: 'GO_PREVIOUS_PAGE',
172
+ });
173
+ return expect(reducer).toStrictEqual(Object.assign(Object.assign({}, state), { pagination: Object.assign(Object.assign({}, state.pagination), { currentPage: 2, greatestPage: 3 }), wizard: Object.assign(Object.assign({}, state.wizard), { currentSectionId: 5, availableSections: [1, 5, 3] }) }));
174
+ });
175
+ });
@@ -0,0 +1,108 @@
1
+ import { addMultipleOccurencyReducer } from './addMultipleOccurency';
2
+ const state = {
3
+ options: {
4
+ 4: [true],
5
+ },
6
+ variables: {
7
+ 2: [false],
8
+ },
9
+ validators: {
10
+ options: {
11
+ 4: [false],
12
+ },
13
+ variables: {
14
+ 3: [false],
15
+ },
16
+ },
17
+ documents: {},
18
+ sections: {},
19
+ prefillers: {
20
+ 3: [[false, false, false]],
21
+ },
22
+ };
23
+ describe('addMultipleOccurencyReducer test suit', () => {
24
+ it('Throws an error if optionRelations or prefillersVariables are undefined', () => {
25
+ expect(() => {
26
+ addMultipleOccurencyReducer(state, {
27
+ id: 3,
28
+ optionRelations: undefined,
29
+ prefillersVariables: undefined,
30
+ });
31
+ }).toThrowError('ADD_MULTIPLE_OCCURENCY reducer did not recieve complete data when adding occurency for 3,' +
32
+ ' please make sure "multiplesActions" middleware is plugged and working properly');
33
+ });
34
+ it('Adds a multiple occurency conditions correctly', () => {
35
+ const optionRelations = {
36
+ options: [],
37
+ variables: [],
38
+ sections: {},
39
+ documents: [],
40
+ prefillers: [],
41
+ validators: {
42
+ options: [],
43
+ variables: [],
44
+ },
45
+ parents: [],
46
+ children: {
47
+ options: [3, 4],
48
+ variables: [2, 3],
49
+ },
50
+ dependants: [7, 8],
51
+ };
52
+ const prefillersVariables = {
53
+ '3': [
54
+ {
55
+ value: 'Option 2 selected',
56
+ conditions: {
57
+ selected: [
58
+ {
59
+ var: 'o.4',
60
+ },
61
+ ],
62
+ },
63
+ },
64
+ {
65
+ value: 'Option 1 selected',
66
+ conditions: {
67
+ selected: [
68
+ {
69
+ var: 'o.3',
70
+ },
71
+ ],
72
+ },
73
+ },
74
+ {
75
+ value: 'Variable 1 = Hello',
76
+ conditions: {
77
+ contains: [
78
+ {
79
+ var: 'v.1',
80
+ },
81
+ 'Hello',
82
+ ],
83
+ },
84
+ },
85
+ ],
86
+ };
87
+ const reducerResult = addMultipleOccurencyReducer(state, {
88
+ id: 2,
89
+ optionRelations,
90
+ prefillersVariables,
91
+ });
92
+ expect(reducerResult).toStrictEqual(Object.assign(Object.assign({}, state), { options: Object.assign(Object.assign({}, state.options), { 4: [true, false] }), variables: {
93
+ 2: [false, false],
94
+ }, prefillers: {
95
+ 3: [
96
+ [false, false, false],
97
+ [false, false, false],
98
+ ],
99
+ }, validators: {
100
+ options: {
101
+ 4: [false, false],
102
+ },
103
+ variables: {
104
+ 3: [false, false],
105
+ },
106
+ } }));
107
+ });
108
+ });