@legalplace/wizardx-core 4.42.8 → 4.42.10-nightly.20251125115613

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (210) 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 +25 -0
  12. package/dist/WizardCore.js +119 -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 +2 -2
  81. package/dist/routing/adapters/nextjs.adapter.d.ts +3 -0
  82. package/dist/routing/adapters/nextjs.adapter.js +63 -0
  83. package/dist/routing/adapters/reactRouter.adapter.d.ts +2 -0
  84. package/dist/routing/adapters/reactRouter.adapter.js +19 -0
  85. package/dist/routing/context.d.ts +14 -0
  86. package/dist/routing/context.js +25 -0
  87. package/dist/routing/index.d.ts +4 -0
  88. package/dist/routing/index.js +4 -0
  89. package/dist/routing/types.d.ts +26 -0
  90. package/dist/service/api.manager.d.ts +2 -2
  91. package/dist/service/autocomplete.manager.d.ts +3 -3
  92. package/dist/service/autocomplete.manager.js +3 -3
  93. package/dist/tests-misc/plugins/jestTestPlugin/after.js +1 -1
  94. package/dist/tests-misc/plugins/jestTestPlugin/before.js +1 -1
  95. package/dist/tests-misc/plugins/jestTestPlugin/title.js +1 -1
  96. package/dist/tests-misc/themes/jestTestTheme/components/EmailComponent.d.ts +1 -1
  97. package/dist/tests-misc/themes/jestTestTheme/components/EmailComponent.js +1 -1
  98. package/dist/tests-misc/themes/jestTestTheme/components/TermsheetComponent.d.ts +1 -1
  99. package/dist/tests-misc/themes/jestTestTheme/components/TermsheetComponent.js +1 -1
  100. package/dist/tests-misc/themes/jestTestTheme/components/WizardComponent.d.ts +1 -1
  101. package/dist/tests-misc/themes/jestTestTheme/components/WizardComponent.js +1 -1
  102. package/dist/types/Actions.type.d.ts +70 -6
  103. package/dist/types/Components.type.d.ts +3 -2
  104. package/dist/types/PluginConfig.type.d.ts +18 -52
  105. package/dist/types/State.type.d.ts +2 -2
  106. package/dist/types/config.type.d.ts +1 -1
  107. package/dist/types/getActions.type.d.ts +1 -1
  108. package/dist/types/getConnectors.type.d.ts +2 -2
  109. package/dist/types/getSelectors.type.d.ts +1 -1
  110. package/dist/wizardcore.entry.d.ts +3 -0
  111. package/dist/wizardcore.entry.js +2 -0
  112. package/package.json +45 -22
  113. package/dist/App.test.js +0 -37
  114. package/dist/PluginLoader.test.d.ts +0 -1
  115. package/dist/PluginLoader.test.js +0 -52
  116. package/dist/ThemeLoader.test.d.ts +0 -2
  117. package/dist/ThemeLoader.test.js +0 -65
  118. package/dist/components/View.test.d.ts +0 -2
  119. package/dist/components/View.test.js +0 -84
  120. package/dist/componentsConnectors/connectBox.test.d.ts +0 -1
  121. package/dist/componentsConnectors/connectBox.test.js +0 -218
  122. package/dist/componentsConnectors/connectDocument.test.d.ts +0 -1
  123. package/dist/componentsConnectors/connectDocument.test.js +0 -95
  124. package/dist/componentsConnectors/connectMetaTitle.test.d.ts +0 -1
  125. package/dist/componentsConnectors/connectMetaTitle.test.js +0 -32
  126. package/dist/config.test.d.ts +0 -1
  127. package/dist/config.test.js +0 -54
  128. package/dist/libs/NumAuto.test.d.ts +0 -1
  129. package/dist/libs/NumAuto.test.js +0 -43
  130. package/dist/libs/SectionValidity.test.d.ts +0 -1
  131. package/dist/libs/SectionValidity.test.js +0 -116
  132. package/dist/redux/actions/app.test.d.ts +0 -1
  133. package/dist/redux/actions/app.test.js +0 -90
  134. package/dist/redux/actions/conditions.test.d.ts +0 -1
  135. package/dist/redux/actions/conditions.test.js +0 -68
  136. package/dist/redux/actions/inputs.test.d.ts +0 -1
  137. package/dist/redux/actions/inputs.test.js +0 -53
  138. package/dist/redux/actions/references.test.d.ts +0 -1
  139. package/dist/redux/actions/references.test.js +0 -43
  140. package/dist/redux/actions/sagas/data.test.d.ts +0 -1
  141. package/dist/redux/actions/sagas/data.test.js +0 -11
  142. package/dist/redux/actions/sagas/model.test.d.ts +0 -1
  143. package/dist/redux/actions/sagas/model.test.js +0 -11
  144. package/dist/redux/actions/user.test.d.ts +0 -1
  145. package/dist/redux/actions/user.test.js +0 -16
  146. package/dist/redux/listeners/subscriber.test.d.ts +0 -1
  147. package/dist/redux/listeners/subscriber.test.js +0 -31
  148. package/dist/redux/middlewares/conditionsWatcherMiddleware.test.d.ts +0 -1
  149. package/dist/redux/middlewares/conditionsWatcherMiddleware.test.js +0 -330
  150. package/dist/redux/middlewares/evaluationsWatcherMiddleware.test.d.ts +0 -1
  151. package/dist/redux/middlewares/evaluationsWatcherMiddleware.test.js +0 -242
  152. package/dist/redux/middlewares/multiplesActionsMiddleware.test.d.ts +0 -1
  153. package/dist/redux/middlewares/multiplesActionsMiddleware.test.js +0 -209
  154. package/dist/redux/middlewares/prefillerWatcherMiddleware.test.d.ts +0 -1
  155. package/dist/redux/middlewares/prefillerWatcherMiddleware.test.js +0 -84
  156. package/dist/redux/reducers/app/instance.test.d.ts +0 -1
  157. package/dist/redux/reducers/app/instance.test.js +0 -75
  158. package/dist/redux/reducers/app/meta.test.d.ts +0 -1
  159. package/dist/redux/reducers/app/meta.test.js +0 -70
  160. package/dist/redux/reducers/app/pagination.test.d.ts +0 -1
  161. package/dist/redux/reducers/app/pagination.test.js +0 -134
  162. package/dist/redux/reducers/app/wizard.test.d.ts +0 -1
  163. package/dist/redux/reducers/app/wizard.test.js +0 -53
  164. package/dist/redux/reducers/app.test.d.ts +0 -1
  165. package/dist/redux/reducers/app.test.js +0 -175
  166. package/dist/redux/reducers/conditions/addMultipleOccurency.test.d.ts +0 -1
  167. package/dist/redux/reducers/conditions/addMultipleOccurency.test.js +0 -108
  168. package/dist/redux/reducers/conditions/deleteMultipleOccurency.test.d.ts +0 -1
  169. package/dist/redux/reducers/conditions/deleteMultipleOccurency.test.js +0 -77
  170. package/dist/redux/reducers/conditions/updateDocumentConditions.test.d.ts +0 -1
  171. package/dist/redux/reducers/conditions/updateDocumentConditions.test.js +0 -35
  172. package/dist/redux/reducers/conditions/updateOptionValidatorCondition.test.d.ts +0 -1
  173. package/dist/redux/reducers/conditions/updateOptionValidatorCondition.test.js +0 -35
  174. package/dist/redux/reducers/conditions/updateVariableValidatorCondition.test.d.ts +0 -1
  175. package/dist/redux/reducers/conditions/updateVariableValidatorCondition.test.js +0 -35
  176. package/dist/redux/reducers/conditions.test.d.ts +0 -1
  177. package/dist/redux/reducers/conditions.test.js +0 -196
  178. package/dist/redux/reducers/inputs/addMultipleOccurency.test.d.ts +0 -1
  179. package/dist/redux/reducers/inputs/addMultipleOccurency.test.js +0 -101
  180. package/dist/redux/reducers/inputs/deleteMultipleOccurency.test.d.ts +0 -1
  181. package/dist/redux/reducers/inputs/deleteMultipleOccurency.test.js +0 -56
  182. package/dist/redux/reducers/inputs.test.d.ts +0 -1
  183. package/dist/redux/reducers/inputs.test.js +0 -171
  184. package/dist/redux/reducers/user.test.d.ts +0 -1
  185. package/dist/redux/reducers/user.test.js +0 -42
  186. package/dist/redux/routerHistore.test.d.ts +0 -1
  187. package/dist/redux/routerHistore.test.js +0 -15
  188. package/dist/redux/sagas/fetchModel.test.d.ts +0 -1
  189. package/dist/redux/sagas/fetchModel.test.js +0 -127
  190. package/dist/redux/sagas/runner.test.d.ts +0 -1
  191. package/dist/redux/sagas/runner.test.js +0 -10
  192. package/dist/redux/sagas/saveData.test.d.ts +0 -1
  193. package/dist/redux/sagas/saveData.test.js +0 -74
  194. package/dist/redux/sagas/setDefaults.test.d.ts +0 -1
  195. package/dist/redux/sagas/setDefaults.test.js +0 -73
  196. package/dist/redux/selectors/app.test.d.ts +0 -1
  197. package/dist/redux/selectors/app.test.js +0 -99
  198. package/dist/redux/selectors/conditions.test.d.ts +0 -1
  199. package/dist/redux/selectors/conditions.test.js +0 -70
  200. package/dist/redux/selectors/inputs.test.d.ts +0 -1
  201. package/dist/redux/selectors/inputs.test.js +0 -44
  202. package/dist/redux/selectors/references.test.d.ts +0 -1
  203. package/dist/redux/selectors/references.test.js +0 -471
  204. package/dist/redux/selectors/selectors.test.d.ts +0 -1
  205. package/dist/redux/selectors/selectors.test.js +0 -16
  206. package/dist/redux/selectors/user.test.d.ts +0 -1
  207. package/dist/redux/selectors/user.test.js +0 -29
  208. package/dist/redux/store.test.d.ts +0 -1
  209. package/dist/redux/store.test.js +0 -16
  210. /package/dist/{App.test.d.ts → routing/types.js} +0 -0
package/dist/App.test.js DELETED
@@ -1,37 +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 { jsx as _jsx } from "react/jsx-runtime";
11
- import ReactDOM from 'react-dom';
12
- import App from './App';
13
- import { testModel } from './misc/test_model';
14
- jest.mock('react', () => {
15
- const rect = jest.requireActual('react');
16
- const Loadable = jest.requireActual('@loadable/component');
17
- rect.lazy = Loadable.lazy;
18
- return rect;
19
- });
20
- jest.mock('./config', () => ({
21
- getConfig: () => ({
22
- apiEndpoint: 'https://api.legalplace.eu/api/v1',
23
- pluginsDir: 'plugins/',
24
- router: {
25
- wizardPath: '/:permalink/questionnaire/:page',
26
- termsheetPath: '/:permalink/questionnaire/resume',
27
- },
28
- plugins: {},
29
- theme: 'social',
30
- appState: ['wizard', 'termsheet'],
31
- }),
32
- }));
33
- it('renders without crashing', () => {
34
- const div = document.createElement('div');
35
- ReactDOM.render(_jsx(App, { historyType: "browser", model: testModel.model, meta: testModel.meta, loadPlugin: () => __awaiter(void 0, void 0, void 0, function* () { }), loadTheme: () => __awaiter(void 0, void 0, void 0, function* () { }) }, void 0), div);
36
- ReactDOM.unmountComponentAtNode(div);
37
- });
@@ -1 +0,0 @@
1
- import '@testing-library/jest-dom/extend-expect';
@@ -1,52 +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 { jsx as _jsx } from "react/jsx-runtime";
11
- import '@testing-library/jest-dom/extend-expect';
12
- import { render, waitFor } from '@testing-library/react';
13
- import { replaceComponent } from './PluginLoader';
14
- jest.mock('react', () => {
15
- const rct = jest.requireActual('react');
16
- const Loadable = jest.requireActual('@loadable/component');
17
- rct.lazy = Loadable.lazy;
18
- return rct;
19
- });
20
- jest.mock('./config', () => ({
21
- getConfig: () => ({
22
- plugins: {
23
- jestTestPlugin: '1.0.0',
24
- },
25
- }),
26
- }));
27
- jest.mock('./Globals', () => ({
28
- loadPlugin: (plugin) => import(`./tests-misc/plugins/${plugin}`),
29
- }));
30
- const { loadPlugins, PluginLoader } = require('./PluginLoader');
31
- loadPlugins();
32
- describe('<PluginLoader />', () => {
33
- it('Loads "after" hook', () => __awaiter(void 0, void 0, void 0, function* () {
34
- const { container } = render(_jsx(PluginLoader, { anchor: ['after'] }, void 0));
35
- yield waitFor(() => expect(container).toContainHTML('<div><div class="title">Hello world - AFTER</div></div>'));
36
- }));
37
- it('Loads "before" hook', () => __awaiter(void 0, void 0, void 0, function* () {
38
- const { container } = render(_jsx(PluginLoader, { anchor: ['before'] }, void 0));
39
- yield waitFor(() => expect(container).toContainHTML('<div><h1>Hello<b>world</b>!!!</h1></div>'));
40
- }));
41
- it('Tries to load non existing plugin', () => __awaiter(void 0, void 0, void 0, function* () {
42
- const { container } = render(_jsx(PluginLoader, { anchor: ['myNonExistingPlugin'] }, void 0));
43
- yield waitFor(() => expect(container).toContainHTML('<div></div>'));
44
- }));
45
- it('Loads replacement module', () => __awaiter(void 0, void 0, void 0, function* () {
46
- const Component = replaceComponent('TitleComponent', () => {
47
- return _jsx("span", { children: "Original" }, void 0);
48
- });
49
- const { container } = render(_jsx(Component, { children: "Replaced" }, void 0));
50
- yield waitFor(() => expect(container).toContainHTML('<div><h1 style="color: red;">Replaced</h1></div>'));
51
- }));
52
- });
@@ -1,2 +0,0 @@
1
- import 'regenerator-runtime/runtime';
2
- import '@testing-library/jest-dom/extend-expect';
@@ -1,65 +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 { jsx as _jsx } from "react/jsx-runtime";
11
- import 'regenerator-runtime/runtime';
12
- import '@testing-library/jest-dom/extend-expect';
13
- import { render, cleanup, waitFor } from '@testing-library/react';
14
- afterEach(cleanup);
15
- jest.mock('./config', () => ({
16
- __esModule: true,
17
- getConfig: () => ({
18
- theme: { name: 'jestTestTheme' },
19
- plugins: {},
20
- }),
21
- loadConfig: () => __awaiter(void 0, void 0, void 0, function* () {
22
- return ({
23
- theme: { name: 'jestTestTheme' },
24
- plugins: {},
25
- });
26
- }),
27
- isConfigReady: () => true,
28
- }));
29
- jest.mock('./Globals', () => ({
30
- loadTheme: (theme) => import(`./tests-misc/themes/${theme}`),
31
- }));
32
- let loadThemeComponent;
33
- let loadTheme;
34
- describe('<ThemeLoader />', () => {
35
- beforeEach(() => {
36
- loadThemeComponent = require('./ThemeLoader').loadThemeComponent;
37
- loadTheme = require('./ThemeLoader').loadTheme;
38
- jest.spyOn(console, 'error').mockImplementation(() => { });
39
- });
40
- it('Loads WizardComponent properly', () => __awaiter(void 0, void 0, void 0, function* () {
41
- yield loadTheme();
42
- const WizardComponent = loadThemeComponent('WizardComponent');
43
- const { container } = render(_jsx(WizardComponent, {}, void 0));
44
- yield waitFor(() => expect(container).toContainHTML('<div><h1>Wizard test theme, WizardComponent</h1></div>'));
45
- }));
46
- it('Loads TermsheetComponent properly', () => __awaiter(void 0, void 0, void 0, function* () {
47
- const TermsheetComponent = loadThemeComponent('TermsheetComponent');
48
- const { container } = render(_jsx(TermsheetComponent, {}, void 0));
49
- yield waitFor(() => expect(container).toContainHTML('<div><h1>Wizard test theme, TermsheetComponent</h1></div>'));
50
- }));
51
- });
52
- describe('loadTheme', () => {
53
- it("loadTheme reloads theme properly if it's not yet loaded", () => __awaiter(void 0, void 0, void 0, function* () {
54
- expect(loadTheme(undefined, true)).resolves.toEqual(undefined);
55
- }));
56
- it('loadTheme throws an error if theme param is invalid', () => __awaiter(void 0, void 0, void 0, function* () {
57
- expect(loadTheme('madeUpTheme')).rejects.toEqual(new Error("We are unable to load the theme, please make sure the theme param is valid"));
58
- }));
59
- it('loadTheme throws an error if theme param is invalid', () => __awaiter(void 0, void 0, void 0, function* () {
60
- expect(loadTheme('jestTestTheme/faltyIndexLoader')).rejects.toEqual(new Error("Unable to retrieve theme index"));
61
- }));
62
- it('loadTheme throws an error if loader result is invalid', () => __awaiter(void 0, void 0, void 0, function* () {
63
- expect(loadTheme('jestTestTheme/faltyIndex')).rejects.toEqual(new Error("Unable to retrieve theme index"));
64
- }));
65
- });
@@ -1,2 +0,0 @@
1
- import 'regenerator-runtime/runtime';
2
- import '@testing-library/jest-dom/extend-expect';
@@ -1,84 +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 { jsx as _jsx } from "react/jsx-runtime";
11
- import 'regenerator-runtime/runtime';
12
- import '@testing-library/jest-dom/extend-expect';
13
- import { render, cleanup, waitFor } from '@testing-library/react';
14
- import { Provider } from 'react-redux';
15
- import { createAppStore, getStore } from '../redux/store';
16
- import { initPaginationAction, initMetaAction, fetchModelSucceededAction, goPageAction, } from '../redux/actions/app';
17
- import View from './View';
18
- import { loadTheme } from '../ThemeLoader';
19
- afterEach(cleanup);
20
- jest.mock('../config', () => ({
21
- __esModule: true,
22
- getConfig: () => ({
23
- theme: { name: 'jestTestTheme' },
24
- plugins: {},
25
- apiEndpoint: 'https://api.legalplace.fr/api/v1/',
26
- router: {
27
- wizardPath: '/:permalink/:modelId([0-9]+)?/questionnaire/:page([0-9]+|sommaire)',
28
- wizardInstancePath: '/:permalink/:modelId([0-9]+)?/questionnaire/:uniqid([0-9a-zA-Z]+)/:page([0-9]+|sommaire)',
29
- },
30
- appStates: ['wizard', 'termsheet'],
31
- }),
32
- isConfigReady: () => true,
33
- loadConfig: () => __awaiter(void 0, void 0, void 0, function* () {
34
- return ({
35
- theme: { name: 'jestTestTheme' },
36
- plugins: {},
37
- apiEndpoint: 'https://api.legalplace.fr/api/v1/',
38
- router: {
39
- wizardPath: '/:permalink/:modelId([0-9]+)?/questionnaire/:page([0-9]+|sommaire)',
40
- wizardInstancePath: '/:permalink/:modelId([0-9]+)?/questionnaire/:uniqid([0-9a-zA-Z]+)/:page([0-9]+|sommaire)',
41
- },
42
- appStates: ['wizard', 'termsheet'],
43
- });
44
- }),
45
- }));
46
- jest.mock('../Globals', () => ({
47
- loadTheme: (plugin) => import(`../tests-misc/themes/${plugin}`),
48
- }));
49
- describe('<View />', () => {
50
- let store;
51
- beforeEach(() => {
52
- createAppStore('memory');
53
- store = getStore();
54
- store.dispatch(initPaginationAction({
55
- currentPage: 1,
56
- greatestPage: 1,
57
- currentSectionId: 1,
58
- availableSections: [1],
59
- currentAppState: 'wizard',
60
- availableAppStates: ['wizard', 'termsheet'],
61
- }));
62
- store.dispatch(initMetaAction({
63
- title: 'My Test Document',
64
- id: 132,
65
- prefix: '',
66
- permalink: 'my-test-document',
67
- modelVersion: 1,
68
- productType: 'demarche',
69
- }));
70
- store.dispatch(fetchModelSucceededAction());
71
- jest.spyOn(console, 'error').mockImplementation(() => { });
72
- });
73
- it('Loads WizardComponent properly', () => __awaiter(void 0, void 0, void 0, function* () {
74
- yield loadTheme();
75
- const { container } = render(_jsx(Provider, Object.assign({ store: store }, { children: _jsx(View, {}, void 0) }), void 0));
76
- yield waitFor(() => expect(container).toContainHTML('<div><h1>Wizard test theme, WizardComponent</h1></div>'));
77
- }));
78
- it('Loads TermsheetComponent properly', () => __awaiter(void 0, void 0, void 0, function* () {
79
- store.dispatch(goPageAction(2));
80
- yield loadTheme();
81
- const { container } = render(_jsx(Provider, Object.assign({ store: store }, { children: _jsx(View, {}, void 0) }), void 0));
82
- yield waitFor(() => expect(container).toContainHTML('<div><h1>Wizard test theme, TermsheetComponent</h1></div>'));
83
- }));
84
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,218 +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 { jsx as _jsx } from "react/jsx-runtime";
11
- import renderer, { act } from 'react-test-renderer';
12
- import { initOptionAction, initVariableAction } from '../redux/actions/inputs';
13
- import { getStore, createAppStore } from '../redux/store';
14
- import { initReferencesAction } from '../redux/actions/references';
15
- import { initConditionsAction, updateOptionConditionsAction, } from '../redux/actions/conditions';
16
- const references = {
17
- options: {
18
- 1: {
19
- meta: {
20
- id: 1,
21
- label: 'textbox',
22
- type: 'box',
23
- step: '*',
24
- box: {
25
- content: 'This content should be parsed with [var:1] value',
26
- collapsable: true,
27
- aggregatable: false,
28
- type: 'error',
29
- title: 'My Test Box',
30
- },
31
- tags: ['ivann'],
32
- },
33
- options: [],
34
- variables: [],
35
- },
36
- 2: {
37
- meta: {
38
- id: 2,
39
- label: 'My test question',
40
- step: '*',
41
- type: 'static',
42
- },
43
- options: [],
44
- variables: [1],
45
- },
46
- },
47
- variables: {
48
- 1: {
49
- id: 1,
50
- label: 'My Test Variable',
51
- step: '*',
52
- type: 'text',
53
- },
54
- },
55
- relations: {
56
- options: {
57
- 1: {
58
- options: [],
59
- variables: [],
60
- validators: {
61
- options: [],
62
- variables: [],
63
- },
64
- sections: {},
65
- prefillers: [],
66
- documents: [],
67
- parents: [],
68
- children: {
69
- options: [],
70
- variables: [],
71
- },
72
- dependants: [],
73
- },
74
- 2: {
75
- options: [],
76
- variables: [],
77
- validators: {
78
- options: [],
79
- variables: [],
80
- },
81
- sections: {},
82
- prefillers: [],
83
- documents: [],
84
- parents: [],
85
- children: {
86
- options: [],
87
- variables: [2],
88
- },
89
- dependants: [],
90
- },
91
- },
92
- variables: {
93
- 1: {
94
- options: [],
95
- variables: [],
96
- validators: {
97
- options: [],
98
- variables: [],
99
- },
100
- sections: {},
101
- prefillers: [],
102
- prefillingsContents: [],
103
- documents: [],
104
- parents: [2],
105
- },
106
- },
107
- sections: {},
108
- },
109
- conditions: {
110
- options: {},
111
- variables: {},
112
- prefillers: {},
113
- validators: {
114
- options: {},
115
- variables: {},
116
- },
117
- sections: {},
118
- documents: {},
119
- },
120
- sections: {},
121
- documents: {},
122
- defaults: {},
123
- outputs: {},
124
- evaluations: {},
125
- boxes: {
126
- 1: {
127
- variables: [1],
128
- raw: 'This content should be parsed with [var:1] value',
129
- },
130
- },
131
- optionTags: {},
132
- variableTags: {}
133
- };
134
- const conditions = {
135
- options: {
136
- 1: [true],
137
- },
138
- variables: {},
139
- prefillers: {},
140
- sections: {
141
- main: {},
142
- },
143
- documents: {},
144
- validators: {
145
- options: {},
146
- variables: {},
147
- },
148
- };
149
- describe('connectBox test suit', () => {
150
- let store;
151
- let connectBox;
152
- beforeEach(() => __awaiter(void 0, void 0, void 0, function* () {
153
- act(() => {
154
- createAppStore('memory');
155
- store = getStore();
156
- store.dispatch(initReferencesAction(references));
157
- store.dispatch(initVariableAction(1, ['My Test Variable']));
158
- store.dispatch(initConditionsAction(conditions));
159
- store.dispatch(initOptionAction(1, [true]));
160
- connectBox = require('./connectBox').connectBox;
161
- });
162
- }));
163
- it('Should parse variables', () => __awaiter(void 0, void 0, void 0, function* () {
164
- let component;
165
- act(() => {
166
- const ConnectedBox = connectBox((props) => {
167
- return _jsx("h1", { children: props.content }, void 0);
168
- });
169
- component = renderer.create(_jsx(ConnectedBox, { store: store, id: 1, index: 0 }, void 0));
170
- });
171
- expect(component.toTree().rendered.props.content).toEqual('This content should be parsed with My Test Variable value');
172
- }));
173
- it('Should not parse on false condition', () => {
174
- let component;
175
- act(() => {
176
- store.dispatch(updateOptionConditionsAction(1, 0, false));
177
- const ConnectedBox = connectBox((props) => {
178
- return _jsx("h1", { children: props.content }, void 0);
179
- });
180
- component = renderer.create(_jsx(ConnectedBox, { store: store, id: 1, index: 0 }, void 0));
181
- });
182
- expect(component.toTree().rendered.props.content).toEqual('');
183
- });
184
- it('Should retrun props properly', () => {
185
- store.dispatch(updateOptionConditionsAction(1, 0, true));
186
- const ConnectedBox = connectBox((props) => {
187
- return _jsx("h1", { children: props.content }, void 0);
188
- });
189
- const component = renderer.create(_jsx(ConnectedBox, { store: store, id: 1, index: 0 }, void 0));
190
- const { props } = component.toTree().rendered;
191
- const { id, index, type, content, condition, box, tags, options } = props;
192
- expect({
193
- id,
194
- index,
195
- type,
196
- content,
197
- condition,
198
- box,
199
- tags,
200
- options,
201
- }).toEqual({
202
- id: 1,
203
- index: 0,
204
- type: 'box',
205
- content: 'This content should be parsed with My Test Variable value',
206
- condition: true,
207
- box: {
208
- type: 'error',
209
- title: 'My Test Box',
210
- content: 'This content should be parsed with [var:1] value',
211
- aggregatable: false,
212
- collapsable: true,
213
- },
214
- tags: ['ivann'],
215
- options: [],
216
- });
217
- });
218
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,95 +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 { jsx as _jsx } from "react/jsx-runtime";
11
- import * as fs from "fs";
12
- import renderer, { act } from "react-test-renderer";
13
- import { ReferencesParser } from "@legalplace/referencesparser";
14
- import { runSaga } from "redux-saga";
15
- import { call } from "redux-saga/effects";
16
- import { getStore, createAppStore } from "../redux/store";
17
- import { initReferencesAction } from "../redux/actions/references";
18
- import { IntputsInitiator } from "../libs/InputsInitiator";
19
- import { initInputsAction } from "../redux/actions/inputs";
20
- import { initInputsDecorator } from "../redux/sagas/initInputs";
21
- const ovc = {
22
- options: { 1: [true], 2: [true, true], 3: [true, false], 4: [false, true] },
23
- variables: {
24
- 1: ["My VAR1"],
25
- 2: ["My VAR 2 1st", "My VAR 2 2nd"],
26
- 3: ["My VAR 3 1st", "My VAR 3 2nd"],
27
- },
28
- };
29
- describe("connectDocument test suit", () => {
30
- let store;
31
- let connectDocument;
32
- beforeEach(() => __awaiter(void 0, void 0, void 0, function* () {
33
- yield act(() => __awaiter(void 0, void 0, void 0, function* () {
34
- createAppStore("memory");
35
- const model = JSON.parse(fs.readFileSync("./src/misc/test_models/connectDocument.testmodel.json", "utf8"));
36
- connectDocument = (yield import("./connectDocument")).connectDocument;
37
- const references = new ReferencesParser(model).getReferences();
38
- const inputs = new IntputsInitiator(references, ovc).getInputs();
39
- store = getStore();
40
- store.dispatch(initReferencesAction(references));
41
- yield runSaga({
42
- dispatch: (action) => store.dispatch(action),
43
- getState: () => store.getState(),
44
- }, function* initInputs() {
45
- yield call(initInputsDecorator, initInputsAction(inputs, references));
46
- }).toPromise();
47
- }));
48
- }));
49
- it("Should retrun props properly", () => __awaiter(void 0, void 0, void 0, function* () {
50
- let component;
51
- yield act(() => __awaiter(void 0, void 0, void 0, function* () {
52
- const ConnectDocument = connectDocument((props) => (_jsx("h1", { children: props.document }, void 0)));
53
- component = renderer.create(_jsx(ConnectDocument, { store: store, document: "main" }, void 0));
54
- }));
55
- const tree = component === null || component === void 0 ? void 0 : component.toTree();
56
- if (!(tree === null || tree === void 0 ? void 0 : tree.rendered)) {
57
- throw Error("Component not rendered while testing");
58
- }
59
- const { props } = Array.isArray(tree.rendered)
60
- ? tree.rendered[0]
61
- : tree.rendered;
62
- const { document, outputs } = props;
63
- expect({ document, outputs }).toStrictEqual({
64
- document: "main",
65
- outputs: {
66
- "output-5-0": "<p>Should output <strong>Variable 1</strong>&nbsp;My VAR1</p>\n",
67
- "output-7-0": "<p>Output for Option 1, Should display Variable 2 &amp; 3 when Option 1 is selected, My VAR 2 1st My VAR 3 1st</p>\n",
68
- "output-8-1": "<p>Output for Option 2, Should display Variable 2 &amp; 3 when Option 2 is selected, My VAR 2 2nd My VAR 3 2nd</p>\n",
69
- },
70
- });
71
- }));
72
- it("Should use main as default", () => __awaiter(void 0, void 0, void 0, function* () {
73
- let component;
74
- yield act(() => __awaiter(void 0, void 0, void 0, function* () {
75
- const ConnectDocument = connectDocument((props) => (_jsx("h1", { children: props.document }, void 0)));
76
- component = renderer.create(_jsx(ConnectDocument, { store: store, document: "default" }, void 0));
77
- }));
78
- const tree = component === null || component === void 0 ? void 0 : component.toTree();
79
- if (!(tree === null || tree === void 0 ? void 0 : tree.rendered)) {
80
- throw Error("Component not rendered while testing");
81
- }
82
- const { props } = Array.isArray(tree.rendered)
83
- ? tree.rendered[0]
84
- : tree.rendered;
85
- const { document, outputs } = props;
86
- expect({ document, outputs }).toStrictEqual({
87
- document: "main",
88
- outputs: {
89
- "output-5-0": "<p>Should output <strong>Variable 1</strong>&nbsp;My VAR1</p>\n",
90
- "output-7-0": "<p>Output for Option 1, Should display Variable 2 &amp; 3 when Option 1 is selected, My VAR 2 1st My VAR 3 1st</p>\n",
91
- "output-8-1": "<p>Output for Option 2, Should display Variable 2 &amp; 3 when Option 2 is selected, My VAR 2 2nd My VAR 3 2nd</p>\n",
92
- },
93
- });
94
- }));
95
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,32 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import renderer from 'react-test-renderer';
3
- import { getStore, createAppStore } from '../redux/store';
4
- import { initMetaAction } from '../redux/actions/app';
5
- const meta = {
6
- title: 'My Test Document',
7
- id: 132,
8
- prefix: '',
9
- permalink: 'my-test-document',
10
- fetchStatus: 'succeeded',
11
- modelVersion: 1,
12
- productType: 'demarche',
13
- };
14
- describe('connectMetaTitle test suit', () => {
15
- let store;
16
- let connectMetaTitle;
17
- beforeEach(() => {
18
- createAppStore('memory');
19
- store = getStore();
20
- store.dispatch(initMetaAction(meta));
21
- connectMetaTitle = require('./connectMetaTitle').connectMetaTitle;
22
- });
23
- it('Should retrun props properly', () => {
24
- const ConnectMetaTitle = connectMetaTitle((props) => {
25
- return _jsx("h1", { children: props.title }, void 0);
26
- });
27
- const component = renderer.create(_jsx(ConnectMetaTitle, { store: store }, void 0));
28
- const { props } = component.toTree().rendered;
29
- const { title } = props;
30
- expect({ title }).toStrictEqual({ title: 'My Test Document' });
31
- });
32
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,54 +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 { getConfig, updateConfig } from './config';
11
- describe('Config loader', () => {
12
- it('Updates config properly', () => __awaiter(void 0, void 0, void 0, function* () {
13
- const config = {
14
- apiEndpoint: process.env.REACT_APP_API_ENDPOINT || '',
15
- enableShadowInstance: false,
16
- router: {
17
- wizardPath: '/contrats/:prefix?/:permalink/creer/:page?',
18
- wizardInstancePath: '/contrats/:prefix?/:permalink/continuer/:uniqid([0-9a-zA-Z]+)/:page?',
19
- notFoundPath: '/contrats/conditions-generales-de-vente/creer',
20
- appStatesPages: {
21
- termsheet: 'resume',
22
- email: 'email',
23
- },
24
- smartscriptPath: '/contrats/:permalink/smartscript/:uniqid?',
25
- },
26
- plugins: {
27
- b2c_actions: '1.0.0',
28
- datalayer: '1.0.0',
29
- checkoutX: '1.0.0',
30
- authentication: '1.0.0',
31
- },
32
- theme: {
33
- name: 'legacy',
34
- params: {
35
- ui: {
36
- topbar: {
37
- previewBtn: false,
38
- },
39
- },
40
- sidebar: {
41
- default: 'preview',
42
- states: {
43
- wizard: 'summary',
44
- email: 'summary',
45
- },
46
- },
47
- },
48
- },
49
- appStates: ['wizard', 'email'],
50
- };
51
- updateConfig(config);
52
- expect(getConfig()).toStrictEqual(config);
53
- }));
54
- });
@@ -1 +0,0 @@
1
- export {};