@reltio/dashboard 1.4.1584 → 1.4.1586-mui5

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 (263) hide show
  1. package/.DS_Store +0 -0
  2. package/index.ts +12 -0
  3. package/package.json +42 -25
  4. package/public/bundle.js +205 -0
  5. package/public/bundle.js.LICENSE.txt +59 -0
  6. package/public/package.json +26 -0
  7. package/public/types/components/DashboardConfigItem/styles.d.ts +1 -0
  8. package/{types → public/types}/components/DashboardError/styles.d.ts +1 -1
  9. package/public/types/components/DashboardLayout/styles.d.ts +1 -0
  10. package/public/types/components/DashboardLayoutItem/styles.d.ts +1 -0
  11. package/public/types/components/DashboardLayoutPanel/styles.d.ts +1 -0
  12. package/public/types/components/DashboardLinearLoader/styles.d.ts +1 -0
  13. package/{types → public/types}/components/DashboardNoData/styles.d.ts +1 -1
  14. package/public/types/components/DashboardPerspectiveHeader/styles.d.ts +2 -0
  15. package/{types → public/types}/components/DashboardPopupMenu/DashboardPopupMenu.d.ts +1 -1
  16. package/public/types/components/DashboardPopupMenu/styles.d.ts +1 -0
  17. package/public/types/components/EntityTable/cell-renderers/styles.d.ts +1 -0
  18. package/{types → public/types}/components/EntityTable/styles.d.ts +1 -1
  19. package/public/types/components/LayoutItemContent/styles.d.ts +1 -0
  20. package/public/types/components/LayoutItemHeader/styles.d.ts +1 -0
  21. package/public/types/components/LayoutItemView/styles.d.ts +1 -0
  22. package/public/types/components/StatsChart/customized/styles.d.ts +1 -0
  23. package/public/types/components/WorkflowTaskItem/styles.d.ts +1 -0
  24. package/public/types/perspective/styles.d.ts +1 -0
  25. package/public/types/views/chartBased/styles.d.ts +1 -0
  26. package/public/types/views/custom/styles.d.ts +1 -0
  27. package/public/types/views/tableBased/styles.d.ts +1 -0
  28. package/scripts/build/index.js +21 -0
  29. package/src/HOCs/withPagination.tsx +39 -0
  30. package/src/components/DashboardConfigItem/DashboardConfigItem.tsx +101 -0
  31. package/src/components/DashboardConfigItem/__tests__/DashboardConfigItem.specs.tsx +81 -0
  32. package/src/components/DashboardConfigItem/icons/barChart.svg +12 -0
  33. package/src/components/DashboardConfigItem/icons/bubbleChart.svg +18 -0
  34. package/src/components/DashboardConfigItem/icons/customChart.svg +66 -0
  35. package/src/components/DashboardConfigItem/icons/donutChart.svg +33 -0
  36. package/src/components/DashboardConfigItem/icons/geomap.svg +23 -0
  37. package/src/components/DashboardConfigItem/icons/lineChart.svg +16 -0
  38. package/src/components/DashboardConfigItem/icons/pieChart.svg +27 -0
  39. package/src/components/DashboardConfigItem/icons/tableWithBars.svg +27 -0
  40. package/src/components/DashboardConfigItem/icons/treemap.svg +15 -0
  41. package/src/components/DashboardConfigItem/icons/wordCloud.svg +27 -0
  42. package/src/components/DashboardConfigItem/styles.ts +56 -0
  43. package/src/components/DashboardError/DashboardError.tsx +34 -0
  44. package/src/components/DashboardError/__tests__/DashboardError.test.js +34 -0
  45. package/src/components/DashboardError/icons/error.svg +113 -0
  46. package/src/components/DashboardError/styles.ts +30 -0
  47. package/src/components/DashboardLayout/DashboardLayout.tsx +59 -0
  48. package/src/components/DashboardLayout/__tests__/DashboardLayout.specs.tsx +56 -0
  49. package/src/components/DashboardLayout/styles.ts +30 -0
  50. package/src/components/DashboardLayoutItem/DashboardLayoutItem.tsx +59 -0
  51. package/src/components/DashboardLayoutItem/__tests__/DashboardLayoutItem.specs.tsx +145 -0
  52. package/src/components/DashboardLayoutItem/styles.ts +10 -0
  53. package/src/components/DashboardLayoutPanel/DashboardLayoutPanel.tsx +59 -0
  54. package/src/components/DashboardLayoutPanel/__tests__/DashboardLayoutPanel.specs.tsx +58 -0
  55. package/src/components/DashboardLayoutPanel/styles.ts +43 -0
  56. package/src/components/DashboardLinearLoader/DashboardLinearLoader.tsx +10 -0
  57. package/src/components/DashboardLinearLoader/__tests__/DashboardLinearLoader.test.js +12 -0
  58. package/src/components/DashboardLinearLoader/styles.ts +11 -0
  59. package/src/components/DashboardNoData/.DS_Store +0 -0
  60. package/src/components/DashboardNoData/DashboardNoData.tsx +21 -0
  61. package/src/components/DashboardNoData/__tests__/DashboardNoData.test.js +15 -0
  62. package/src/components/DashboardNoData/icons/noData.svg +68 -0
  63. package/src/components/DashboardNoData/styles.ts +21 -0
  64. package/src/components/DashboardPerspectiveHeader/DashboardPerspectiveHeader.tsx +43 -0
  65. package/src/components/DashboardPerspectiveHeader/__tests__/DashboardPerspectiveHeader.specs.tsx +41 -0
  66. package/src/components/DashboardPerspectiveHeader/styles.ts +24 -0
  67. package/src/components/DashboardPopupMenu/DashboardPopupMenu.tsx +75 -0
  68. package/src/components/DashboardPopupMenu/__tests__/DashboardPopupMenu.test.tsx +51 -0
  69. package/src/components/DashboardPopupMenu/styles.ts +20 -0
  70. package/src/components/EntityTable/EntityTable.tsx +49 -0
  71. package/src/components/EntityTable/__tests__/EntityTable.test.tsx +33 -0
  72. package/src/components/EntityTable/cell-renderers/EntityLabelRenderer.tsx +24 -0
  73. package/src/components/EntityTable/cell-renderers/HeadCellRenderer.tsx +34 -0
  74. package/src/components/EntityTable/cell-renderers/__tests__/EntityLabelRenderer.test.tsx +25 -0
  75. package/src/components/EntityTable/cell-renderers/styles.ts +46 -0
  76. package/src/components/EntityTable/styles.ts +19 -0
  77. package/src/components/LayoutItemContent/LayoutItemContent.tsx +63 -0
  78. package/src/components/LayoutItemContent/__tests__/LayoutItemContent.test.tsx +71 -0
  79. package/src/components/LayoutItemContent/styles.ts +36 -0
  80. package/src/components/LayoutItemHeader/LayoutItemHeader.tsx +86 -0
  81. package/src/components/LayoutItemHeader/__tests__/LayoutItemHeader.specs.tsx +48 -0
  82. package/src/components/LayoutItemHeader/styles.ts +44 -0
  83. package/src/components/LayoutItemView/LayoutItemView.tsx +24 -0
  84. package/src/components/LayoutItemView/styles.ts +11 -0
  85. package/src/components/StatsChart/StatsChart.tsx +77 -0
  86. package/src/components/StatsChart/__tests__/StatsChart.test.tsx +106 -0
  87. package/src/components/StatsChart/customized/CustomAxisTick.tsx +28 -0
  88. package/src/components/StatsChart/customized/CustomLegend.tsx +37 -0
  89. package/src/components/StatsChart/customized/CustomTooltip.tsx +41 -0
  90. package/src/components/StatsChart/customized/styles.ts +53 -0
  91. package/src/components/StatsChart/getStatsChartSettings.ts +65 -0
  92. package/src/components/WorkflowTaskItem/WorkflowTaskItem.tsx +67 -0
  93. package/src/components/WorkflowTaskItem/WorkflowTaskObject.tsx +54 -0
  94. package/src/components/WorkflowTaskItem/__tests__/WorkflowTaskItem.test.tsx +73 -0
  95. package/src/components/WorkflowTaskItem/__tests__/WorkflowTaskObject.test.tsx +95 -0
  96. package/src/components/WorkflowTaskItem/styles.ts +74 -0
  97. package/src/components/WorkflowTasksList/WorkflowTasksList.tsx +34 -0
  98. package/src/components/WorkflowTasksList/__tests__/WorkflowTasksList.test.tsx +98 -0
  99. package/src/components/index.ts +8 -0
  100. package/src/contexts/DashboardViewIdContext/index.ts +5 -0
  101. package/src/hooks/__tests__/useActivititesRequest.specs.tsx +106 -0
  102. package/src/hooks/__tests__/useEntityByTypeRequest.specs.tsx +280 -0
  103. package/src/hooks/__tests__/useFacetRequest.specs.tsx +437 -0
  104. package/src/hooks/__tests__/useFilteredEntitiesRequest.specs.tsx +103 -0
  105. package/src/hooks/__tests__/useSavedSearchesRequest.specs.tsx +201 -0
  106. package/src/hooks/__tests__/useStatsRequest.specs.tsx +212 -0
  107. package/src/hooks/__tests__/useWorkflowTasksRequest.specs.tsx +388 -0
  108. package/src/hooks/useActivitiesRequest.ts +50 -0
  109. package/src/hooks/useEntityByTypeRequest.ts +67 -0
  110. package/src/hooks/useFacetRequest.ts +117 -0
  111. package/src/hooks/useFilteredEntitiesRequest.ts +57 -0
  112. package/src/hooks/useSavedSearchesRequest.ts +82 -0
  113. package/src/hooks/useStatsRequest.ts +47 -0
  114. package/src/hooks/useWorkflowTasksRequest.ts +66 -0
  115. package/src/index.ts +25 -0
  116. package/src/perspective/DashboardPerspectiveView.tsx +132 -0
  117. package/src/perspective/__tests__/DashboardPerspectiveView.specs.tsx +276 -0
  118. package/src/perspective/__tests__/data/metadata.data.ts +33 -0
  119. package/src/perspective/__tests__/data/store.data.ts +15 -0
  120. package/src/perspective/__tests__/helpers.specs.ts +33 -0
  121. package/src/perspective/helpers.ts +19 -0
  122. package/src/perspective/index.tsx +65 -0
  123. package/src/perspective/styles.ts +16 -0
  124. package/src/services/__tests__/facets.specs.ts +42 -0
  125. package/src/services/__tests__/filters.specs.ts +60 -0
  126. package/src/services/__tests__/period.test.ts +33 -0
  127. package/src/services/__tests__/stats.test.ts +319 -0
  128. package/src/services/entityTypes.ts +66 -0
  129. package/src/services/facets.ts +178 -0
  130. package/src/services/filters.ts +87 -0
  131. package/src/services/period.ts +33 -0
  132. package/src/services/savedSearches.ts +20 -0
  133. package/src/services/stats.ts +191 -0
  134. package/src/services/workflowTasks.ts +116 -0
  135. package/src/types/ActivitiesViewFacetConfig.ts +5 -0
  136. package/src/types/CustomActionViewFacetConfig.ts +5 -0
  137. package/src/types/DashboardPerspectiveConfig.ts +18 -0
  138. package/src/types/DashboardSavedState.ts +7 -0
  139. package/src/types/EntityByTypeViewFacetConfig.ts +7 -0
  140. package/src/types/EntityData.ts +4 -0
  141. package/src/types/FilteredEntitiesFacetConfig.ts +6 -0
  142. package/src/types/FilteredSavedSearchesFacetConfig.ts +6 -0
  143. package/src/types/PeriodStep.ts +4 -0
  144. package/src/types/SavedSearchData.ts +6 -0
  145. package/src/types/SearchOptions.ts +10 -0
  146. package/src/types/StatsData.ts +14 -0
  147. package/src/types/WorkflowTasks.ts +26 -0
  148. package/src/types/index.ts +14 -0
  149. package/src/views/ViewsFactory.tsx +79 -0
  150. package/src/views/__tests__/ViewsFactory.specs.tsx +70 -0
  151. package/src/views/chartBased/DashboardFacet.tsx +71 -0
  152. package/src/views/chartBased/EntitiesByTypeViewFacet.tsx +60 -0
  153. package/src/views/chartBased/ProfileStatsFacet.tsx +54 -0
  154. package/src/views/chartBased/__tests__/DashboardFacet.specs.tsx +358 -0
  155. package/src/views/chartBased/__tests__/EntitiesByTypeViewFacet.specs.tsx +101 -0
  156. package/src/views/chartBased/__tests__/ProfileStatsFacet.specs.tsx +106 -0
  157. package/src/views/chartBased/styles.ts +13 -0
  158. package/src/views/custom/CustomActionViewFacet.tsx +36 -0
  159. package/src/views/custom/NotificationInboxFacet.tsx +86 -0
  160. package/src/views/custom/__tests__/CustomActionViewFacet.specs.tsx +35 -0
  161. package/src/views/custom/__tests__/NotificationInboxFacet.specs.tsx +144 -0
  162. package/src/views/custom/styles.ts +31 -0
  163. package/src/views/tableBased/ActivitiesViewFacet.tsx +79 -0
  164. package/src/views/tableBased/FilteredEntitiesViewFacet.tsx +67 -0
  165. package/src/views/tableBased/FilteredSavedSearchesFacet.tsx +85 -0
  166. package/src/views/tableBased/__tests__/ActivitiesViewFacet.specs.tsx +113 -0
  167. package/src/views/tableBased/__tests__/FIlteredEntitiesViewFacet.specs.tsx +90 -0
  168. package/src/views/tableBased/__tests__/FilteredSavedSearchesFacet.specs.tsx +133 -0
  169. package/src/views/tableBased/helpers.ts +8 -0
  170. package/src/views/tableBased/styles.ts +7 -0
  171. package/stories/Dashboards.stories.js +118 -0
  172. package/stories/utils/dashboardPerspectiveConfig.js +78 -0
  173. package/stories/utils/dashboardsViewConfig.js +17 -0
  174. package/stories/utils/mdmStore.js +73 -0
  175. package/stories/utils/responses.js +10 -0
  176. package/tsconfig.json +14 -0
  177. package/webpack.config.js +10 -0
  178. package/bundle.js +0 -2
  179. package/bundle.js.LICENSE.txt +0 -22
  180. package/types/components/DashboardConfigItem/styles.d.ts +0 -1
  181. package/types/components/DashboardLayout/styles.d.ts +0 -1
  182. package/types/components/DashboardLayoutItem/styles.d.ts +0 -1
  183. package/types/components/DashboardLayoutPanel/styles.d.ts +0 -1
  184. package/types/components/DashboardLinearLoader/styles.d.ts +0 -1
  185. package/types/components/DashboardPerspectiveHeader/styles.d.ts +0 -2
  186. package/types/components/DashboardPopupMenu/styles.d.ts +0 -1
  187. package/types/components/EntityTable/cell-renderers/styles.d.ts +0 -1
  188. package/types/components/LayoutItemContent/styles.d.ts +0 -1
  189. package/types/components/LayoutItemHeader/styles.d.ts +0 -1
  190. package/types/components/LayoutItemView/styles.d.ts +0 -1
  191. package/types/components/StatsChart/customized/styles.d.ts +0 -1
  192. package/types/components/WorkflowTaskItem/styles.d.ts +0 -1
  193. package/types/perspective/styles.d.ts +0 -1
  194. package/types/views/chartBased/styles.d.ts +0 -1
  195. package/types/views/custom/styles.d.ts +0 -1
  196. package/types/views/tableBased/styles.d.ts +0 -1
  197. /package/{types → public/types}/HOCs/withPagination.d.ts +0 -0
  198. /package/{types → public/types}/components/DashboardConfigItem/DashboardConfigItem.d.ts +0 -0
  199. /package/{types → public/types}/components/DashboardError/DashboardError.d.ts +0 -0
  200. /package/{types → public/types}/components/DashboardLayout/DashboardLayout.d.ts +0 -0
  201. /package/{types → public/types}/components/DashboardLayoutItem/DashboardLayoutItem.d.ts +0 -0
  202. /package/{types → public/types}/components/DashboardLayoutPanel/DashboardLayoutPanel.d.ts +0 -0
  203. /package/{types → public/types}/components/DashboardLinearLoader/DashboardLinearLoader.d.ts +0 -0
  204. /package/{types → public/types}/components/DashboardNoData/DashboardNoData.d.ts +0 -0
  205. /package/{types → public/types}/components/DashboardPerspectiveHeader/DashboardPerspectiveHeader.d.ts +0 -0
  206. /package/{types → public/types}/components/EntityTable/EntityTable.d.ts +0 -0
  207. /package/{types → public/types}/components/EntityTable/cell-renderers/EntityLabelRenderer.d.ts +0 -0
  208. /package/{types → public/types}/components/EntityTable/cell-renderers/HeadCellRenderer.d.ts +0 -0
  209. /package/{types → public/types}/components/LayoutItemContent/LayoutItemContent.d.ts +0 -0
  210. /package/{types → public/types}/components/LayoutItemHeader/LayoutItemHeader.d.ts +0 -0
  211. /package/{types → public/types}/components/LayoutItemView/LayoutItemView.d.ts +0 -0
  212. /package/{types → public/types}/components/StatsChart/StatsChart.d.ts +0 -0
  213. /package/{types → public/types}/components/StatsChart/customized/CustomAxisTick.d.ts +0 -0
  214. /package/{types → public/types}/components/StatsChart/customized/CustomLegend.d.ts +0 -0
  215. /package/{types → public/types}/components/StatsChart/customized/CustomTooltip.d.ts +0 -0
  216. /package/{types → public/types}/components/StatsChart/getStatsChartSettings.d.ts +0 -0
  217. /package/{types → public/types}/components/WorkflowTaskItem/WorkflowTaskItem.d.ts +0 -0
  218. /package/{types → public/types}/components/WorkflowTaskItem/WorkflowTaskObject.d.ts +0 -0
  219. /package/{types → public/types}/components/WorkflowTasksList/WorkflowTasksList.d.ts +0 -0
  220. /package/{types → public/types}/components/index.d.ts +0 -0
  221. /package/{types → public/types}/contexts/DashboardViewIdContext/index.d.ts +0 -0
  222. /package/{types → public/types}/hooks/useActivitiesRequest.d.ts +0 -0
  223. /package/{types → public/types}/hooks/useEntityByTypeRequest.d.ts +0 -0
  224. /package/{types → public/types}/hooks/useFacetRequest.d.ts +0 -0
  225. /package/{types → public/types}/hooks/useFilteredEntitiesRequest.d.ts +0 -0
  226. /package/{types → public/types}/hooks/useSavedSearchesRequest.d.ts +0 -0
  227. /package/{types → public/types}/hooks/useStatsRequest.d.ts +0 -0
  228. /package/{types → public/types}/hooks/useWorkflowTasksRequest.d.ts +0 -0
  229. /package/{types → public/types}/index.d.ts +0 -0
  230. /package/{types → public/types}/perspective/DashboardPerspectiveView.d.ts +0 -0
  231. /package/{types → public/types}/perspective/helpers.d.ts +0 -0
  232. /package/{types → public/types}/perspective/index.d.ts +0 -0
  233. /package/{types → public/types}/services/entityTypes.d.ts +0 -0
  234. /package/{types → public/types}/services/facets.d.ts +0 -0
  235. /package/{types → public/types}/services/filters.d.ts +0 -0
  236. /package/{types → public/types}/services/period.d.ts +0 -0
  237. /package/{types → public/types}/services/savedSearches.d.ts +0 -0
  238. /package/{types → public/types}/services/stats.d.ts +0 -0
  239. /package/{types → public/types}/services/workflowTasks.d.ts +0 -0
  240. /package/{types → public/types}/types/ActivitiesViewFacetConfig.d.ts +0 -0
  241. /package/{types → public/types}/types/CustomActionViewFacetConfig.d.ts +0 -0
  242. /package/{types → public/types}/types/DashboardPerspectiveConfig.d.ts +0 -0
  243. /package/{types → public/types}/types/DashboardSavedState.d.ts +0 -0
  244. /package/{types → public/types}/types/EntityByTypeViewFacetConfig.d.ts +0 -0
  245. /package/{types → public/types}/types/EntityData.d.ts +0 -0
  246. /package/{types → public/types}/types/FilteredEntitiesFacetConfig.d.ts +0 -0
  247. /package/{types → public/types}/types/FilteredSavedSearchesFacetConfig.d.ts +0 -0
  248. /package/{types → public/types}/types/PeriodStep.d.ts +0 -0
  249. /package/{types → public/types}/types/SavedSearchData.d.ts +0 -0
  250. /package/{types → public/types}/types/SearchOptions.d.ts +0 -0
  251. /package/{types → public/types}/types/StatsData.d.ts +0 -0
  252. /package/{types → public/types}/types/WorkflowTasks.d.ts +0 -0
  253. /package/{types → public/types}/types/index.d.ts +0 -0
  254. /package/{types → public/types}/views/ViewsFactory.d.ts +0 -0
  255. /package/{types → public/types}/views/chartBased/DashboardFacet.d.ts +0 -0
  256. /package/{types → public/types}/views/chartBased/EntitiesByTypeViewFacet.d.ts +0 -0
  257. /package/{types → public/types}/views/chartBased/ProfileStatsFacet.d.ts +0 -0
  258. /package/{types → public/types}/views/custom/CustomActionViewFacet.d.ts +0 -0
  259. /package/{types → public/types}/views/custom/NotificationInboxFacet.d.ts +0 -0
  260. /package/{types → public/types}/views/tableBased/ActivitiesViewFacet.d.ts +0 -0
  261. /package/{types → public/types}/views/tableBased/FilteredEntitiesViewFacet.d.ts +0 -0
  262. /package/{types → public/types}/views/tableBased/FilteredSavedSearchesFacet.d.ts +0 -0
  263. /package/{types → public/types}/views/tableBased/helpers.d.ts +0 -0
@@ -0,0 +1,358 @@
1
+ import React from 'react';
2
+ import {mount, shallow} from 'enzyme';
3
+ import * as reactRedux from 'react-redux';
4
+
5
+ import {BarChart, BasicView, BasicViewContent, BasicViewHeader, RequestStates} from '@reltio/components';
6
+ import * as ReltioComponents from '@reltio/components';
7
+ import {ChartTypes, DashboardViewTypes} from '@reltio/mdm-sdk';
8
+ import * as useFacetRequestHook from '../../../hooks/useFacetRequest';
9
+ import {DashboardPopupMenu, DashboardLayoutItemHeader} from '../../../components';
10
+ import DashboardFacet from '../DashboardFacet';
11
+ import mdmModule, {ui} from '@reltio/mdm-module';
12
+
13
+ jest.mock('@reltio/components', () => ({
14
+ ...(jest.requireActual('@reltio/components') as Record<string, unknown>),
15
+ useReloadAllFacets: jest.fn()
16
+ }));
17
+
18
+ describe('DashboardFacet tests', () => {
19
+ const options = {
20
+ isLabelRotated: true
21
+ };
22
+ const config = {
23
+ id: 'MyDashboard',
24
+ component: DashboardViewTypes.DashboardFacet,
25
+ attributeUri: 'configuration/entityTypes/HCP/attributes/CountryCode',
26
+ chartType: 'bar',
27
+ title: 'Country codes',
28
+ filters: [],
29
+ count: 1,
30
+ orderType: 'ASC',
31
+ ...options
32
+ };
33
+ const props = {
34
+ config,
35
+ onToggleFullscreen: jest.fn(),
36
+ isUpdated: false,
37
+ isFullscreen: false,
38
+ onRemove: jest.fn()
39
+ };
40
+ const dispatch = jest.fn();
41
+ const reload = jest.fn();
42
+ const metadata = {
43
+ entityTypes: [
44
+ {
45
+ uri: 'configuration/entityTypes/HCP',
46
+ attributes: [
47
+ {
48
+ uri: 'configuration/entityTypes/HCP/attributes/CountryCode',
49
+ type: 'String',
50
+ lookupCode: 'COUNTRY_CD'
51
+ },
52
+ {
53
+ uri: 'configuration/entityTypes/HCP/attributes/Enumeration',
54
+ type: 'Enum'
55
+ },
56
+ {
57
+ uri: 'configuration/entityTypes/HCP/attributes/Date',
58
+ type: 'Date'
59
+ },
60
+ {
61
+ uri: 'configuration/entityTypes/HCP/attributes/Timestamp',
62
+ type: 'Timestamp'
63
+ }
64
+ ]
65
+ }
66
+ ]
67
+ };
68
+
69
+ beforeAll(() => {
70
+ jest.spyOn(mdmModule.selectors, 'getMetadata').mockReturnValue(metadata);
71
+ jest.spyOn(reactRedux, 'useSelector').mockImplementation((selector) => selector({}));
72
+ jest.spyOn(ReltioComponents, 'useReloadFacet').mockImplementation(() => {});
73
+ jest.spyOn(reactRedux, 'useDispatch').mockReturnValue(dispatch);
74
+ });
75
+
76
+ afterEach(() => {
77
+ jest.clearAllMocks();
78
+ });
79
+
80
+ it('should render dashboard facet', () => {
81
+ jest.spyOn(useFacetRequestHook, 'useFacetRequest').mockImplementation(() => {
82
+ return {
83
+ state: RequestStates.LOADED,
84
+ data: [{label: 'USA', group: 'US', value: 30}],
85
+ reload
86
+ };
87
+ });
88
+ const wrapper = mount(<DashboardFacet {...props} />);
89
+ expect(wrapper.find(DashboardLayoutItemHeader).props()).toEqual({
90
+ title: config.title,
91
+ onToggleFullscreen: props.onToggleFullscreen,
92
+ isUpdated: props.isUpdated,
93
+ isFullscreen: props.isFullscreen,
94
+ onRefresh: reload,
95
+ onRemove: props.onRemove
96
+ });
97
+ expect(wrapper.find(BasicView).length).toBe(1);
98
+ expect(wrapper.find(BasicViewHeader).length).toBe(1);
99
+ expect(wrapper.find(BasicViewHeader).prop('title')).toEqual(props.config.title);
100
+ expect(wrapper.find(DashboardPopupMenu).length).toBe(1);
101
+ expect(wrapper.find(BasicViewContent).length).toBe(1);
102
+ const chart = wrapper.find(BarChart);
103
+ expect(chart.length).toBe(1);
104
+ expect(chart.prop('options')).toMatchObject(options);
105
+ });
106
+
107
+ it('should render dashboard facet with special attribute', () => {
108
+ jest.spyOn(useFacetRequestHook, 'useFacetRequest').mockImplementation((props) => {
109
+ expect(props.attributeUri).toBe('tags');
110
+ return {
111
+ state: RequestStates.LOADED,
112
+ data: [{label: 'test1', group: 'test1', value: 30}],
113
+ reload
114
+ };
115
+ });
116
+ const specialConfig = {
117
+ id: 'Test',
118
+ chartType: 'bar',
119
+ title: 'Profile tags',
120
+ component: 'DashboardFacet',
121
+ attributeUri: 'tags'
122
+ };
123
+ const wrapper = mount(<DashboardFacet {...props} config={specialConfig} />);
124
+ expect(wrapper.find(BasicView).length).toBe(1);
125
+ expect(wrapper.find(BasicViewHeader).length).toBe(1);
126
+ expect(wrapper.find(BasicViewHeader).prop('title')).toEqual(specialConfig.title);
127
+ const chart = wrapper.find(BarChart);
128
+ expect(chart.length).toBe(1);
129
+ });
130
+
131
+ it('should open search on facet item click correctly', () => {
132
+ jest.spyOn(useFacetRequestHook, 'useFacetRequest').mockImplementation(() => {
133
+ return {
134
+ state: RequestStates.LOADED,
135
+ data: [{label: 'USA', group: 'US', value: 30}],
136
+ reload
137
+ };
138
+ });
139
+ const wrapper = mount(<DashboardFacet {...props} />);
140
+ wrapper.find(BarChart).prop('onItemClick')('US');
141
+ expect(dispatch).toBeCalledWith(
142
+ ui.actions.openSearch({
143
+ facets: [
144
+ {
145
+ fieldName: 'type',
146
+ filter: 'equals',
147
+ values: ['configuration/entityTypes/HCP']
148
+ },
149
+ {
150
+ fieldName: 'attributes.CountryCode',
151
+ filter: 'equals',
152
+ values: ['US'],
153
+ entityType: 'configuration/entityTypes/HCP'
154
+ }
155
+ ]
156
+ })
157
+ );
158
+ });
159
+
160
+ it('should open search on date facet item click correctly', () => {
161
+ jest.spyOn(useFacetRequestHook, 'useFacetRequest').mockImplementation(() => {
162
+ return {
163
+ state: RequestStates.LOADED,
164
+ data: [{label: '07-01-2021', group: '1625119557484', value: 30}],
165
+ reload: () => {}
166
+ };
167
+ });
168
+ const configWithDate = {
169
+ ...config,
170
+ attributeUri: 'configuration/entityTypes/HCP/attributes/Date',
171
+ title: 'Dates'
172
+ };
173
+ const wrapper = mount(<DashboardFacet {...props} config={configWithDate} />);
174
+ wrapper.find(BarChart).prop('onItemClick')('1625119557484');
175
+ expect(dispatch).toBeCalledWith(
176
+ ui.actions.openSearch({
177
+ facets: [
178
+ {
179
+ fieldName: 'type',
180
+ filter: 'equals',
181
+ values: ['configuration/entityTypes/HCP']
182
+ },
183
+ {
184
+ fieldName: 'attributes.Date',
185
+ filter: 'equals',
186
+ values: [1625119557484],
187
+ entityType: 'configuration/entityTypes/HCP'
188
+ }
189
+ ]
190
+ })
191
+ );
192
+ });
193
+
194
+ it('should open search on other facet item click correctly', () => {
195
+ jest.spyOn(useFacetRequestHook, 'useFacetRequest').mockImplementation(() => {
196
+ return {
197
+ state: RequestStates.LOADED,
198
+ data: [
199
+ {label: 'USA', group: 'US', value: 30},
200
+ {label: 'Russia', group: 'RU', value: 20},
201
+ {label: 'Other', group: 'Other', value: 12}
202
+ ],
203
+ reload
204
+ };
205
+ });
206
+ const configWithShowOthers = {
207
+ ...config,
208
+ showOthers: true
209
+ };
210
+ const wrapper = mount(<DashboardFacet {...props} config={configWithShowOthers} />);
211
+ wrapper.find(BarChart).prop('onItemClick')('Other');
212
+ expect(dispatch).toBeCalledWith(
213
+ ui.actions.openSearch({
214
+ facets: [
215
+ {
216
+ fieldName: 'type',
217
+ filter: 'equals',
218
+ values: ['configuration/entityTypes/HCP']
219
+ },
220
+ {
221
+ fieldName: 'attributes.CountryCode',
222
+ filter: 'not equals',
223
+ values: ['US'],
224
+ entityType: 'configuration/entityTypes/HCP'
225
+ },
226
+ {
227
+ fieldName: 'attributes.CountryCode',
228
+ filter: 'not equals',
229
+ values: ['RU'],
230
+ entityType: 'configuration/entityTypes/HCP'
231
+ }
232
+ ]
233
+ })
234
+ );
235
+ });
236
+
237
+ it('should open search on facet item click correctly (config with filters)', () => {
238
+ jest.spyOn(useFacetRequestHook, 'useFacetRequest').mockImplementation(() => {
239
+ return {
240
+ state: RequestStates.LOADED,
241
+ data: [{label: 'USA', group: 'US', value: 30}],
242
+ reload
243
+ };
244
+ });
245
+ const configWithFilters = {
246
+ ...config,
247
+ filters: [
248
+ {
249
+ filter: 'equals',
250
+ fieldName: 'attributes.Enumeration',
251
+ values: ['Test1']
252
+ },
253
+ {
254
+ fieldName: 'roles',
255
+ filter: 'equals',
256
+ values: ['configuration/roles/PracticeManager']
257
+ },
258
+ {
259
+ fieldName: 'attributes.Date',
260
+ filter: 'range',
261
+ values: ['1525737600000', '1525737700000']
262
+ },
263
+ {
264
+ filter: 'gte',
265
+ fieldName: 'attributes.Timestamp',
266
+ values: ['1620414000000']
267
+ },
268
+ {
269
+ filter: 'lte',
270
+ fieldName: 'attributes.Timestamp',
271
+ values: ['1620586799999']
272
+ }
273
+ ]
274
+ };
275
+ const wrapper = mount(<DashboardFacet {...props} config={configWithFilters} />);
276
+ wrapper.find(BarChart).prop('onItemClick')('US');
277
+ expect(dispatch).toBeCalledWith(
278
+ ui.actions.openSearch({
279
+ facets: [
280
+ {
281
+ fieldName: 'type',
282
+ filter: 'equals',
283
+ values: ['configuration/entityTypes/HCP']
284
+ },
285
+ {
286
+ fieldName: 'attributes.Enumeration',
287
+ filter: 'equals',
288
+ values: ['Test1'],
289
+ entityType: 'configuration/entityTypes/HCP'
290
+ },
291
+ {
292
+ fieldName: 'roles',
293
+ filter: 'equals',
294
+ values: ['configuration/roles/PracticeManager']
295
+ },
296
+ {
297
+ fieldName: 'attributes.Date',
298
+ filter: 'range',
299
+ values: [[1525737600000, 1525737700000]],
300
+ entityType: 'configuration/entityTypes/HCP'
301
+ },
302
+ {
303
+ fieldName: 'attributes.Timestamp',
304
+ filter: 'gte',
305
+ values: [1620414000000],
306
+ entityType: 'configuration/entityTypes/HCP'
307
+ },
308
+ {
309
+ fieldName: 'attributes.Timestamp',
310
+ filter: 'lte',
311
+ values: [1620586799999],
312
+ entityType: 'configuration/entityTypes/HCP'
313
+ },
314
+ {
315
+ filter: 'equals',
316
+ fieldName: 'attributes.CountryCode',
317
+ entityType: 'configuration/entityTypes/HCP',
318
+ values: ['US']
319
+ }
320
+ ]
321
+ })
322
+ );
323
+ });
324
+
325
+ it('should correctly choose count', () => {
326
+ const facetRequest = jest.spyOn(useFacetRequestHook, 'useFacetRequest').mockImplementation(() => {
327
+ return {
328
+ state: RequestStates.LOADED,
329
+ data: [{label: 'USA', group: 'US', value: 30}],
330
+ reload
331
+ };
332
+ });
333
+ const wrapper = shallow(<DashboardFacet {...props} />);
334
+ expect(facetRequest).lastCalledWith({
335
+ attributeUri: 'configuration/entityTypes/HCP/attributes/CountryCode',
336
+ pageSize: 1,
337
+ filters: [],
338
+ options: {showOthers: undefined},
339
+ orderType: 'ASC'
340
+ });
341
+ wrapper.setProps({config: {...config, count: undefined}});
342
+ expect(facetRequest).lastCalledWith({
343
+ attributeUri: 'configuration/entityTypes/HCP/attributes/CountryCode',
344
+ pageSize: 8,
345
+ filters: [],
346
+ options: {showOthers: undefined},
347
+ orderType: 'ASC'
348
+ });
349
+ wrapper.setProps({config: {...config, chartType: ChartTypes.MAP, count: undefined}});
350
+ expect(facetRequest).lastCalledWith({
351
+ attributeUri: 'configuration/entityTypes/HCP/attributes/CountryCode',
352
+ pageSize: 100,
353
+ filters: [],
354
+ options: {showOthers: undefined},
355
+ orderType: 'ASC'
356
+ });
357
+ });
358
+ });
@@ -0,0 +1,101 @@
1
+ import React from 'react';
2
+ import {mount} from 'enzyme';
3
+ import * as reactRedux from 'react-redux';
4
+ import {BasicView, BasicViewContent, BasicViewHeader, TreeChart, RequestStates} from '@reltio/components';
5
+ import {ui} from '@reltio/mdm-module';
6
+ import * as useEntityByTypeRequestHook from '../../../hooks/useEntityByTypeRequest';
7
+ import {DashboardPopupMenu, DashboardLayoutItemHeader} from '../../../components';
8
+ import EntitiesByTypeViewFacet from '../EntitiesByTypeViewFacet';
9
+ import * as ReltioComponents from '@reltio/components';
10
+ import {DashboardViewTypes} from '@reltio/mdm-sdk';
11
+
12
+ jest.mock('@reltio/components', () => ({
13
+ ...jest.requireActual<Record<string, unknown>>('@reltio/components'),
14
+ TreeChart: () => null
15
+ }));
16
+
17
+ describe('EntitiesByTypeViewFacet tests', () => {
18
+ const props = {
19
+ config: {
20
+ id: 'id',
21
+ title: 'title',
22
+ component: DashboardViewTypes.EntitiesByTypeViewFacet,
23
+ hideEmpty: false,
24
+ inheritChildren: false
25
+ },
26
+ onToggleFullscreen: jest.fn(),
27
+ isUpdated: false,
28
+ isFullscreen: false,
29
+ onRemove: jest.fn()
30
+ };
31
+
32
+ const dispatch = jest.fn();
33
+ const reload = jest.fn();
34
+
35
+ beforeAll(() => {
36
+ jest.spyOn(reactRedux, 'useSelector').mockImplementation(() => ({}));
37
+ jest.spyOn(useEntityByTypeRequestHook, 'useEntityByTypeRequest').mockImplementation(() => {
38
+ return {
39
+ state: RequestStates.LOADED,
40
+ data: [
41
+ {group: 'Party', label: 'Сторона', value: 1761537},
42
+ {group: 'REGISTRY', label: 'РЕЕСТР', value: 515},
43
+ {group: 'Location', label: 'Address', value: 54},
44
+ {group: 'ETLLOV', label: 'ETLLOV', value: 11},
45
+ {group: 'OMG', label: 'OMG', value: 5},
46
+ {group: 'HCPLongName', label: 'HCP Long Name', value: 4},
47
+ {group: 'ForRDM', label: 'ForRDM', value: 1}
48
+ ],
49
+ reload,
50
+ total: 2
51
+ };
52
+ });
53
+ jest.spyOn(reactRedux, 'useDispatch').mockReturnValue(dispatch);
54
+ jest.spyOn(ReltioComponents, 'useReloadFacet').mockImplementation(() => {});
55
+ });
56
+
57
+ afterEach(() => {
58
+ jest.clearAllMocks();
59
+ });
60
+
61
+ it('should render tree chart', () => {
62
+ const wrapper = mount(<EntitiesByTypeViewFacet {...props} />);
63
+ expect(wrapper.find(DashboardLayoutItemHeader).props()).toEqual({
64
+ title: props.config.title,
65
+ onToggleFullscreen: props.onToggleFullscreen,
66
+ isUpdated: props.isUpdated,
67
+ isFullscreen: props.isFullscreen,
68
+ onRefresh: reload,
69
+ onRemove: props.onRemove
70
+ });
71
+ expect(wrapper.find(BasicView).length).toBe(1);
72
+ expect(wrapper.find(BasicViewHeader).length).toBe(1);
73
+ expect(wrapper.find(BasicViewHeader).prop('title')).toEqual(props.config.title);
74
+ expect(wrapper.find(DashboardPopupMenu).length).toBe(1);
75
+ expect(wrapper.find(BasicViewContent).find(TreeChart).prop('data')).toEqual([
76
+ {group: 'Party', label: 'Сторона', value: 1761537},
77
+ {group: 'REGISTRY', label: 'РЕЕСТР', value: 515},
78
+ {group: 'Location', label: 'Address', value: 54},
79
+ {group: 'ETLLOV', label: 'ETLLOV', value: 11},
80
+ {group: 'OMG', label: 'OMG', value: 5},
81
+ {group: 'HCPLongName', label: 'HCP Long Name', value: 4},
82
+ {group: 'ForRDM', label: 'ForRDM', value: 1}
83
+ ]);
84
+ });
85
+
86
+ it('should open search on new type click correctly', () => {
87
+ const wrapper = mount(<EntitiesByTypeViewFacet {...props} />);
88
+ wrapper.find(TreeChart).prop('onItemClick')('Party');
89
+ expect(dispatch).toBeCalledWith(
90
+ ui.actions.openSearch({
91
+ facets: [
92
+ {
93
+ fieldName: 'type',
94
+ filter: 'equals',
95
+ values: ['configuration/entityTypes/Party']
96
+ }
97
+ ]
98
+ })
99
+ );
100
+ });
101
+ });
@@ -0,0 +1,106 @@
1
+ import React from 'react';
2
+ import {act} from 'react-dom/test-utils';
3
+ import {mount} from 'enzyme';
4
+
5
+ import ProfileStatsFacet from '../ProfileStatsFacet';
6
+ import * as useStatsRequest from '../../../hooks/useStatsRequest';
7
+ import {PeriodStep} from '../../../types/PeriodStep';
8
+ import * as StatsChartImport from '../../../components/StatsChart/StatsChart';
9
+ import StatsChart from '../../../components/StatsChart/StatsChart';
10
+ import {
11
+ BasicView,
12
+ BasicViewContent,
13
+ BasicViewHeader,
14
+ DateRangeEditor,
15
+ EmptyStub,
16
+ RequestStates,
17
+ ReloadFacetProvider
18
+ } from '@reltio/components';
19
+ import {DashboardPopupMenu, DashboardLayoutItemHeader} from '../../../components';
20
+ import {DashboardViewTypes, DateRangeValue} from '@reltio/mdm-sdk';
21
+
22
+ jest.mock('@reltio/mdm-sdk', () => ({
23
+ ...jest.requireActual<Record<string, unknown>>('@reltio/mdm-sdk'),
24
+ DateRangeEditor: jest.fn().mockImplementation(() => null)
25
+ }));
26
+
27
+ describe('ProfileStatsFacet tests', () => {
28
+ const props = {
29
+ config: {
30
+ id: 'id',
31
+ component: DashboardViewTypes.ProfileStatsFacet,
32
+ title: 'ProfileStats'
33
+ },
34
+ onRemove: jest.fn(),
35
+ onToggleFullscreen: jest.fn(),
36
+ isUpdated: false,
37
+ isFullscreen: false
38
+ };
39
+ const statsData = [{event: 'created', total: 1234, data: []}];
40
+ const reload = jest.fn();
41
+
42
+ beforeAll(() => {
43
+ jest.spyOn(Date, 'now').mockImplementation(() => new Date(1667214303338).getTime());
44
+ jest.spyOn(useStatsRequest, 'useStatsRequest').mockImplementation((_) => {
45
+ return {
46
+ state: RequestStates.LOADED,
47
+ data: statsData,
48
+ step: PeriodStep.DAY,
49
+ reload
50
+ };
51
+ });
52
+ jest.spyOn(StatsChartImport, 'default').mockImplementation(EmptyStub);
53
+ });
54
+
55
+ afterAll(() => {
56
+ jest.clearAllMocks();
57
+ });
58
+
59
+ it('should render correct default state', () => {
60
+ const wrapper = mount(
61
+ <ReloadFacetProvider>
62
+ <ProfileStatsFacet {...props} />
63
+ </ReloadFacetProvider>
64
+ );
65
+ expect(wrapper.find(DashboardLayoutItemHeader).props()).toMatchObject({
66
+ title: props.config.title,
67
+ onToggleFullscreen: props.onToggleFullscreen,
68
+ isUpdated: props.isUpdated,
69
+ isFullscreen: props.isFullscreen,
70
+ onRefresh: reload,
71
+ onRemove: props.onRemove
72
+ });
73
+ expect(wrapper.find(BasicView).length).toBe(1);
74
+ expect(wrapper.find(BasicViewHeader).length).toBe(1);
75
+ expect(wrapper.find(BasicViewHeader).prop('title')).toEqual(props.config.title);
76
+ expect(wrapper.find(DashboardPopupMenu).length).toBe(1);
77
+ expect(wrapper.find(BasicViewContent).length).toBe(1);
78
+ expect(wrapper.find(DateRangeEditor).prop('values')).toEqual(DateRangeValue.LAST_WEEK);
79
+ expect(wrapper.find(StatsChart).props()).toMatchObject({
80
+ step: PeriodStep.DAY,
81
+ data: statsData
82
+ });
83
+ expect(useStatsRequest.useStatsRequest).toBeCalledWith(DateRangeValue.LAST_WEEK);
84
+ });
85
+
86
+ it('should apply changed period correctly', () => {
87
+ const wrapper = mount(
88
+ <ReloadFacetProvider>
89
+ <ProfileStatsFacet {...props} />
90
+ </ReloadFacetProvider>
91
+ );
92
+ jest.spyOn(useStatsRequest, 'useStatsRequest').mockReturnValueOnce({
93
+ state: RequestStates.LOADED,
94
+ data: statsData,
95
+ step: PeriodStep.HOUR,
96
+ reload
97
+ });
98
+ act(() => {
99
+ wrapper.find(DateRangeEditor).prop('onChange')(DateRangeValue.LAST_DAY);
100
+ });
101
+ wrapper.update();
102
+ expect(wrapper.find(DateRangeEditor).prop('values')).toEqual(DateRangeValue.LAST_DAY);
103
+ expect(wrapper.find(StatsChart).prop('step')).toBe(PeriodStep.HOUR);
104
+ expect(useStatsRequest.useStatsRequest).toBeCalledWith(DateRangeValue.LAST_DAY);
105
+ });
106
+ });
@@ -0,0 +1,13 @@
1
+ import {makeStyles} from '@mui/styles';
2
+
3
+ export const useStyles = makeStyles({
4
+ periodSelector: {
5
+ position: 'relative',
6
+ margin: '0 6px 0 0',
7
+ flexBasis: '220px',
8
+ flexShrink: 1,
9
+ '& input[type="text"]': {
10
+ padding: '0 0 0 8px'
11
+ }
12
+ }
13
+ });
@@ -0,0 +1,36 @@
1
+ import React, {memo} from 'react';
2
+ import {CustomActionViewFacetConfig} from '../../types/CustomActionViewFacetConfig';
3
+ import LayoutItemView from '../../components/LayoutItemView/LayoutItemView';
4
+ import LayoutItemHeader from '../../components/LayoutItemHeader/LayoutItemHeader';
5
+ import {BasicViewContent} from '@reltio/components';
6
+ import {useStyles} from './styles';
7
+
8
+ type Props = {
9
+ config: CustomActionViewFacetConfig;
10
+ onToggleFullscreen: (id: string) => void;
11
+ isUpdated?: boolean;
12
+ isFullscreen: boolean;
13
+ onRemove?: (id: string) => void;
14
+ };
15
+
16
+ const CustomActionViewFacet = ({config, onToggleFullscreen, isUpdated, isFullscreen, onRemove}: Props) => {
17
+ const {id, title, url} = config;
18
+ const styles = useStyles();
19
+
20
+ return (
21
+ <LayoutItemView id={id}>
22
+ <LayoutItemHeader
23
+ title={title}
24
+ onToggleFullscreen={onToggleFullscreen}
25
+ isUpdated={isUpdated}
26
+ isFullscreen={isFullscreen}
27
+ onRemove={onRemove}
28
+ />
29
+ <BasicViewContent className={styles.viewContent}>
30
+ <iframe src={url} frameBorder="0" className={styles.iframe} />
31
+ </BasicViewContent>
32
+ </LayoutItemView>
33
+ );
34
+ };
35
+
36
+ export default memo(CustomActionViewFacet);