@itwin/reports-config-widget-react 0.3.0 → 0.5.0

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/CHANGELOG.json +41 -0
  2. package/CHANGELOG.md +25 -2
  3. package/coverage/clover.xml +867 -0
  4. package/coverage/coverage-final.json +33 -0
  5. package/coverage/lcov-report/base.css +224 -0
  6. package/coverage/lcov-report/block-navigation.js +87 -0
  7. package/coverage/lcov-report/favicon.png +0 -0
  8. package/coverage/lcov-report/index.html +206 -0
  9. package/coverage/lcov-report/prettify.css +1 -0
  10. package/coverage/lcov-report/prettify.js +2 -0
  11. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  12. package/coverage/lcov-report/sorter.js +196 -0
  13. package/coverage/lcov-report/src/ReportsConfigWidget.ts.html +193 -0
  14. package/coverage/lcov-report/src/index.html +116 -0
  15. package/coverage/lcov-report/src/test/index.html +116 -0
  16. package/coverage/lcov-report/src/test/test-utils.tsx.html +379 -0
  17. package/coverage/lcov-report/src/widget/ReportsConfigUiProvider.tsx.html +265 -0
  18. package/coverage/lcov-report/src/widget/components/ActionPanel.tsx.html +247 -0
  19. package/coverage/lcov-report/src/widget/components/AddMappingsModal.tsx.html +589 -0
  20. package/coverage/lcov-report/src/widget/components/BulkExtractor.ts.html +664 -0
  21. package/coverage/lcov-report/src/widget/components/Constants.ts.html +112 -0
  22. package/coverage/lcov-report/src/widget/components/DeleteModal.tsx.html +367 -0
  23. package/coverage/lcov-report/src/widget/components/ExtractionStates/FailedExtractionState.tsx.html +187 -0
  24. package/coverage/lcov-report/src/widget/components/ExtractionStates/QueuedExtractionState.tsx.html +145 -0
  25. package/coverage/lcov-report/src/widget/components/ExtractionStates/RunningExtractionState.tsx.html +139 -0
  26. package/coverage/lcov-report/src/widget/components/ExtractionStates/StartingExtractionState.tsx.html +151 -0
  27. package/coverage/lcov-report/src/widget/components/ExtractionStates/SucceededExtractionState.tsx.html +190 -0
  28. package/coverage/lcov-report/src/widget/components/ExtractionStates/index.html +176 -0
  29. package/coverage/lcov-report/src/widget/components/ExtractionStatus.tsx.html +295 -0
  30. package/coverage/lcov-report/src/widget/components/ExtractionToast.tsx.html +208 -0
  31. package/coverage/lcov-report/src/widget/components/HorizontalTile.tsx.html +289 -0
  32. package/coverage/lcov-report/src/widget/components/LocalizedTablePaginator.tsx.html +262 -0
  33. package/coverage/lcov-report/src/widget/components/ReportAction.tsx.html +472 -0
  34. package/coverage/lcov-report/src/widget/components/ReportHorizontalTile.tsx.html +472 -0
  35. package/coverage/lcov-report/src/widget/components/ReportMappingHorizontalTile.tsx.html +469 -0
  36. package/coverage/lcov-report/src/widget/components/ReportMappings.tsx.html +1063 -0
  37. package/coverage/lcov-report/src/widget/components/Reports.tsx.html +754 -0
  38. package/coverage/lcov-report/src/widget/components/ReportsConfigContext.tsx.html +373 -0
  39. package/coverage/lcov-report/src/widget/components/ReportsContainer.tsx.html +301 -0
  40. package/coverage/lcov-report/src/widget/components/ReportsHeader.tsx.html +166 -0
  41. package/coverage/lcov-report/src/widget/components/ReportsRouter.tsx.html +274 -0
  42. package/coverage/lcov-report/src/widget/components/SearchBar.tsx.html +286 -0
  43. package/coverage/lcov-report/src/widget/components/SelectIModel.tsx.html +337 -0
  44. package/coverage/lcov-report/src/widget/components/index.html +416 -0
  45. package/coverage/lcov-report/src/widget/components/utils.tsx.html +565 -0
  46. package/coverage/lcov-report/src/widget/context/BulkExtractorContext.tsx.html +163 -0
  47. package/coverage/lcov-report/src/widget/context/ReportsConfigApiContext.tsx.html +202 -0
  48. package/coverage/lcov-report/src/widget/context/index.html +131 -0
  49. package/coverage/lcov-report/src/widget/hooks/index.html +116 -0
  50. package/coverage/lcov-report/src/widget/hooks/useValidator.ts.html +295 -0
  51. package/coverage/lcov-report/src/widget/index.html +116 -0
  52. package/coverage/lcov.info +1609 -0
  53. package/jest.config.js +1 -0
  54. package/lib/cjs/ReportsConfigWidget.js +1 -1
  55. package/lib/cjs/ReportsConfigWidget.js.map +1 -1
  56. package/lib/cjs/reports-config-widget-react.js +5 -1
  57. package/lib/cjs/reports-config-widget-react.js.map +1 -1
  58. package/lib/cjs/test/AddMappingModal.test.js +20 -70
  59. package/lib/cjs/test/AddMappingModal.test.js.map +1 -1
  60. package/lib/cjs/test/BulkExtractor.test.js +5 -1
  61. package/lib/cjs/test/BulkExtractor.test.js.map +1 -1
  62. package/lib/cjs/test/DeleteModal.test.js +2 -2
  63. package/lib/cjs/test/DeleteModal.test.js.map +1 -1
  64. package/lib/cjs/test/ReportAction.test.js +7 -7
  65. package/lib/cjs/test/ReportAction.test.js.map +1 -1
  66. package/lib/cjs/test/ReportMappingHorizontalTile.test.js +31 -81
  67. package/lib/cjs/test/ReportMappingHorizontalTile.test.js.map +1 -1
  68. package/lib/cjs/test/ReportMappings.test.js +38 -88
  69. package/lib/cjs/test/ReportMappings.test.js.map +1 -1
  70. package/lib/cjs/test/Reports.test.js +68 -66
  71. package/lib/cjs/test/Reports.test.js.map +1 -1
  72. package/lib/cjs/test/WidgetHeader.test.js +9 -3
  73. package/lib/cjs/test/WidgetHeader.test.js.map +1 -1
  74. package/lib/cjs/test/test-utils.d.ts +30 -0
  75. package/lib/cjs/test/test-utils.d.ts.map +1 -1
  76. package/lib/cjs/test/test-utils.js +66 -7
  77. package/lib/cjs/test/test-utils.js.map +1 -1
  78. package/lib/cjs/tsconfig.tsbuildinfo +1 -1
  79. package/lib/cjs/widget/ReportsConfigUiProvider.d.ts +3 -3
  80. package/lib/cjs/widget/ReportsConfigUiProvider.d.ts.map +1 -1
  81. package/lib/cjs/widget/ReportsConfigUiProvider.js +10 -8
  82. package/lib/cjs/widget/ReportsConfigUiProvider.js.map +1 -1
  83. package/lib/cjs/widget/components/ActionPanel.d.ts +2 -2
  84. package/lib/cjs/widget/components/ActionPanel.d.ts.map +1 -1
  85. package/lib/cjs/widget/components/ActionPanel.js +5 -1
  86. package/lib/cjs/widget/components/ActionPanel.js.map +1 -1
  87. package/lib/cjs/widget/components/ActionPanel.scss +2 -3
  88. package/lib/cjs/widget/components/AddMappingsModal.d.ts.map +1 -1
  89. package/lib/cjs/widget/components/AddMappingsModal.js +27 -28
  90. package/lib/cjs/widget/components/AddMappingsModal.js.map +1 -1
  91. package/lib/cjs/widget/components/AddMappingsModal.scss +1 -2
  92. package/lib/cjs/widget/components/BulkExtractor.js +2 -2
  93. package/lib/cjs/widget/components/BulkExtractor.js.map +1 -1
  94. package/lib/cjs/widget/components/Constants.d.ts +1 -0
  95. package/lib/cjs/widget/components/Constants.d.ts.map +1 -1
  96. package/lib/cjs/widget/components/Constants.js +2 -1
  97. package/lib/cjs/widget/components/Constants.js.map +1 -1
  98. package/lib/cjs/widget/components/DeleteModal.js +8 -4
  99. package/lib/cjs/widget/components/DeleteModal.js.map +1 -1
  100. package/lib/cjs/widget/components/DeleteModal.scss +2 -3
  101. package/lib/cjs/widget/components/ExtractionStatus.js +7 -3
  102. package/lib/cjs/widget/components/ExtractionStatus.js.map +1 -1
  103. package/lib/cjs/widget/components/ExtractionStatus.scss +6 -7
  104. package/lib/cjs/widget/components/HorizontalTile.js +2 -2
  105. package/lib/cjs/widget/components/HorizontalTile.js.map +1 -1
  106. package/lib/cjs/widget/components/HorizontalTile.scss +10 -16
  107. package/lib/cjs/widget/components/LocalizedTablePaginator.js +7 -3
  108. package/lib/cjs/widget/components/LocalizedTablePaginator.js.map +1 -1
  109. package/lib/cjs/widget/components/ReportAction.js +19 -17
  110. package/lib/cjs/widget/components/ReportAction.js.map +1 -1
  111. package/lib/cjs/widget/components/ReportAction.scss +1 -2
  112. package/lib/cjs/widget/components/ReportHorizontalTile.js +14 -12
  113. package/lib/cjs/widget/components/ReportHorizontalTile.js.map +1 -1
  114. package/lib/cjs/widget/components/ReportMappingHorizontalTile.d.ts.map +1 -1
  115. package/lib/cjs/widget/components/ReportMappingHorizontalTile.js +22 -18
  116. package/lib/cjs/widget/components/ReportMappingHorizontalTile.js.map +1 -1
  117. package/lib/cjs/widget/components/ReportMappings.d.ts.map +1 -1
  118. package/lib/cjs/widget/components/ReportMappings.js +28 -27
  119. package/lib/cjs/widget/components/ReportMappings.js.map +1 -1
  120. package/lib/cjs/widget/components/ReportMappings.scss +9 -10
  121. package/lib/cjs/widget/components/Reports.d.ts.map +1 -1
  122. package/lib/cjs/widget/components/Reports.js +26 -22
  123. package/lib/cjs/widget/components/Reports.js.map +1 -1
  124. package/lib/cjs/widget/components/Reports.scss +15 -15
  125. package/lib/cjs/widget/components/ReportsConfigContext.d.ts.map +1 -1
  126. package/lib/cjs/widget/components/ReportsConfigContext.js +29 -32
  127. package/lib/cjs/widget/components/ReportsConfigContext.js.map +1 -1
  128. package/lib/cjs/widget/components/ReportsContainer.js +9 -6
  129. package/lib/cjs/widget/components/ReportsContainer.js.map +1 -1
  130. package/lib/cjs/widget/components/ReportsContainer.scss +1 -3
  131. package/lib/cjs/widget/components/ReportsRouter.js +1 -2
  132. package/lib/cjs/widget/components/ReportsRouter.js.map +1 -1
  133. package/lib/cjs/widget/components/SearchBar.d.ts.map +1 -1
  134. package/lib/cjs/widget/components/SearchBar.js +9 -5
  135. package/lib/cjs/widget/components/SearchBar.js.map +1 -1
  136. package/lib/cjs/widget/components/SearchBar.scss +0 -1
  137. package/lib/cjs/widget/components/SelectIModel.js +11 -7
  138. package/lib/cjs/widget/components/SelectIModel.js.map +1 -1
  139. package/lib/cjs/widget/components/SelectIModel.scss +2 -3
  140. package/lib/cjs/widget/components/utils.d.ts.map +1 -1
  141. package/lib/cjs/widget/components/utils.js +1 -1
  142. package/lib/cjs/widget/components/utils.js.map +1 -1
  143. package/lib/cjs/widget/components/utils.scss +16 -8
  144. package/lib/cjs/widget/context/BulkExtractorContext.js +6 -2
  145. package/lib/cjs/widget/context/BulkExtractorContext.js.map +1 -1
  146. package/lib/cjs/widget/context/ReportsConfigApiContext.js +6 -2
  147. package/lib/cjs/widget/context/ReportsConfigApiContext.js.map +1 -1
  148. package/lib/cjs/widget/hooks/useValidator.js +1 -1
  149. package/lib/cjs/widget/hooks/useValidator.js.map +1 -1
  150. package/lib/esm/ReportsConfigWidget.js +1 -1
  151. package/lib/esm/ReportsConfigWidget.js.map +1 -1
  152. package/lib/esm/test/AddMappingModal.test.js +2 -56
  153. package/lib/esm/test/AddMappingModal.test.js.map +1 -1
  154. package/lib/esm/test/ReportMappingHorizontalTile.test.js +3 -57
  155. package/lib/esm/test/ReportMappingHorizontalTile.test.js.map +1 -1
  156. package/lib/esm/test/ReportMappings.test.js +8 -62
  157. package/lib/esm/test/ReportMappings.test.js.map +1 -1
  158. package/lib/esm/test/Reports.test.js +32 -53
  159. package/lib/esm/test/Reports.test.js.map +1 -1
  160. package/lib/esm/test/WidgetHeader.test.js +8 -2
  161. package/lib/esm/test/WidgetHeader.test.js.map +1 -1
  162. package/lib/esm/test/test-utils.d.ts +30 -0
  163. package/lib/esm/test/test-utils.d.ts.map +1 -1
  164. package/lib/esm/test/test-utils.js +59 -4
  165. package/lib/esm/test/test-utils.js.map +1 -1
  166. package/lib/esm/tsconfig.tsbuildinfo +1 -1
  167. package/lib/esm/widget/ReportsConfigUiProvider.d.ts +3 -3
  168. package/lib/esm/widget/ReportsConfigUiProvider.d.ts.map +1 -1
  169. package/lib/esm/widget/ReportsConfigUiProvider.js +2 -4
  170. package/lib/esm/widget/ReportsConfigUiProvider.js.map +1 -1
  171. package/lib/esm/widget/components/ActionPanel.d.ts +2 -2
  172. package/lib/esm/widget/components/ActionPanel.d.ts.map +1 -1
  173. package/lib/esm/widget/components/ActionPanel.js.map +1 -1
  174. package/lib/esm/widget/components/ActionPanel.scss +2 -3
  175. package/lib/esm/widget/components/AddMappingsModal.d.ts.map +1 -1
  176. package/lib/esm/widget/components/AddMappingsModal.js +10 -15
  177. package/lib/esm/widget/components/AddMappingsModal.js.map +1 -1
  178. package/lib/esm/widget/components/AddMappingsModal.scss +1 -2
  179. package/lib/esm/widget/components/Constants.d.ts +1 -0
  180. package/lib/esm/widget/components/Constants.d.ts.map +1 -1
  181. package/lib/esm/widget/components/Constants.js +1 -0
  182. package/lib/esm/widget/components/Constants.js.map +1 -1
  183. package/lib/esm/widget/components/DeleteModal.js +2 -2
  184. package/lib/esm/widget/components/DeleteModal.js.map +1 -1
  185. package/lib/esm/widget/components/DeleteModal.scss +2 -3
  186. package/lib/esm/widget/components/ExtractionStatus.scss +6 -7
  187. package/lib/esm/widget/components/HorizontalTile.scss +10 -16
  188. package/lib/esm/widget/components/ReportAction.js +7 -9
  189. package/lib/esm/widget/components/ReportAction.js.map +1 -1
  190. package/lib/esm/widget/components/ReportAction.scss +1 -2
  191. package/lib/esm/widget/components/ReportHorizontalTile.js +4 -6
  192. package/lib/esm/widget/components/ReportHorizontalTile.js.map +1 -1
  193. package/lib/esm/widget/components/ReportMappingHorizontalTile.d.ts.map +1 -1
  194. package/lib/esm/widget/components/ReportMappingHorizontalTile.js +11 -11
  195. package/lib/esm/widget/components/ReportMappingHorizontalTile.js.map +1 -1
  196. package/lib/esm/widget/components/ReportMappings.d.ts.map +1 -1
  197. package/lib/esm/widget/components/ReportMappings.js +7 -10
  198. package/lib/esm/widget/components/ReportMappings.js.map +1 -1
  199. package/lib/esm/widget/components/ReportMappings.scss +9 -10
  200. package/lib/esm/widget/components/Reports.d.ts.map +1 -1
  201. package/lib/esm/widget/components/Reports.js +9 -9
  202. package/lib/esm/widget/components/Reports.js.map +1 -1
  203. package/lib/esm/widget/components/Reports.scss +15 -15
  204. package/lib/esm/widget/components/ReportsConfigContext.d.ts.map +1 -1
  205. package/lib/esm/widget/components/ReportsConfigContext.js +21 -28
  206. package/lib/esm/widget/components/ReportsConfigContext.js.map +1 -1
  207. package/lib/esm/widget/components/ReportsContainer.js +1 -2
  208. package/lib/esm/widget/components/ReportsContainer.js.map +1 -1
  209. package/lib/esm/widget/components/ReportsContainer.scss +1 -3
  210. package/lib/esm/widget/components/ReportsRouter.js +1 -2
  211. package/lib/esm/widget/components/ReportsRouter.js.map +1 -1
  212. package/lib/esm/widget/components/SearchBar.d.ts.map +1 -1
  213. package/lib/esm/widget/components/SearchBar.js +2 -2
  214. package/lib/esm/widget/components/SearchBar.js.map +1 -1
  215. package/lib/esm/widget/components/SearchBar.scss +0 -1
  216. package/lib/esm/widget/components/SelectIModel.js +1 -1
  217. package/lib/esm/widget/components/SelectIModel.js.map +1 -1
  218. package/lib/esm/widget/components/SelectIModel.scss +2 -3
  219. package/lib/esm/widget/components/utils.d.ts.map +1 -1
  220. package/lib/esm/widget/components/utils.js +2 -2
  221. package/lib/esm/widget/components/utils.js.map +1 -1
  222. package/lib/esm/widget/components/utils.scss +16 -8
  223. package/lib/public/locales/en/ReportsConfigWidget.json +4 -0
  224. package/package.json +56 -55
  225. package/public/locales/en/ReportsConfigWidget.json +4 -0
  226. package/src/test/AddMappingModal.test.tsx +7 -57
  227. package/src/test/ReportMappingHorizontalTile.test.tsx +6 -58
  228. package/src/test/ReportMappings.test.tsx +7 -58
  229. package/src/test/Reports.test.tsx +32 -110
  230. package/src/test/WidgetHeader.test.tsx +9 -2
  231. package/src/test/test-utils.tsx +62 -1
  232. package/src/widget/ReportsConfigUiProvider.tsx +7 -14
  233. package/src/widget/components/ActionPanel.scss +2 -3
  234. package/src/widget/components/ActionPanel.tsx +1 -1
  235. package/src/widget/components/AddMappingsModal.scss +1 -2
  236. package/src/widget/components/AddMappingsModal.tsx +16 -21
  237. package/src/widget/components/Constants.ts +2 -0
  238. package/src/widget/components/DeleteModal.scss +2 -3
  239. package/src/widget/components/DeleteModal.tsx +3 -3
  240. package/src/widget/components/ExtractionStatus.scss +6 -7
  241. package/src/widget/components/HorizontalTile.scss +10 -16
  242. package/src/widget/components/ReportAction.scss +1 -2
  243. package/src/widget/components/ReportAction.tsx +3 -3
  244. package/src/widget/components/ReportHorizontalTile.tsx +1 -1
  245. package/src/widget/components/ReportMappingHorizontalTile.tsx +28 -27
  246. package/src/widget/components/ReportMappings.scss +9 -10
  247. package/src/widget/components/ReportMappings.tsx +2 -4
  248. package/src/widget/components/Reports.scss +15 -15
  249. package/src/widget/components/Reports.tsx +25 -22
  250. package/src/widget/components/ReportsConfigContext.tsx +3 -2
  251. package/src/widget/components/ReportsContainer.scss +1 -3
  252. package/src/widget/components/SearchBar.scss +0 -1
  253. package/src/widget/components/SearchBar.tsx +6 -1
  254. package/src/widget/components/SelectIModel.scss +2 -3
  255. package/src/widget/components/SelectIModel.tsx +1 -1
  256. package/src/widget/components/utils.scss +16 -8
  257. package/src/widget/components/utils.tsx +7 -6
  258. package/.rush/temp/operation/rebuild/all.log +0 -9
  259. package/.rush/temp/operation/rebuild/state.json +0 -3
  260. package/.rush/temp/package-deps_rebuild.json +0 -68
  261. package/.rush/temp/shrinkwrap-deps.json +0 -931
  262. package/reports-config-widget-react.build.error.log +0 -1
  263. package/reports-config-widget-react.build.log +0 -2
@@ -7,6 +7,11 @@ import faker from "@faker-js/faker";
7
7
  import "@testing-library/jest-dom";
8
8
  import { ReportsConfigWidget } from "../ReportsConfigWidget";
9
9
  import {
10
+ mockIModelId1,
11
+ mockIModelId2,
12
+ mockIModelsResponse,
13
+ mockITwinId,
14
+ mockReportId,
10
15
  render,
11
16
  screen,
12
17
  waitFor,
@@ -20,65 +25,10 @@ import type {
20
25
  ReportsClient,
21
26
  } from "@itwin/insights-client";
22
27
  import type { ReportMappingAndMapping } from "../widget/components/ReportMappings";
23
- import type { GetSingleIModelParams, IModelOperations, IModelsClient, OperationOptions } from "@itwin/imodels-client-management";
24
- import { IModelState } from "@itwin/imodels-client-management";
28
+ import type { GetSingleIModelParams, IModelsClient } from "@itwin/imodels-client-management";
25
29
  import { AddMappingsModal } from "../widget/components/AddMappingsModal";
26
30
  import { EmptyLocalization } from "@itwin/core-common";
27
-
28
- const mockITwinId = faker.datatype.uuid();
29
- const mockIModelId1 = faker.datatype.uuid();
30
- const mockIModelId2 = faker.datatype.uuid();
31
-
32
- const mockReportId = faker.datatype.uuid();
33
-
34
- const mockIModelsResponse = [
35
- {
36
- iModel: {
37
- id: mockIModelId1,
38
- displayName: "rAnDoMdIsPlAynAmE1",
39
- name: "rAnDomName1",
40
- description: "rAnDoMDeScRiPtIoN1",
41
- createdDateTime: "2021-10-04T22:13:50.397Z",
42
- state: IModelState.Initialized,
43
- projectId: mockITwinId,
44
- extent: null,
45
- _links: {
46
- creator: {
47
- href: "",
48
- },
49
- namedVersions: {
50
- href: "",
51
- },
52
- changesets: {
53
- href: "",
54
- },
55
- },
56
- },
57
- },
58
- {
59
- iModel: {
60
- id: mockIModelId2,
61
- displayName: "rAnDoMdIsPlAynAmE2",
62
- name: "rAnDomName2",
63
- description: "rAnDoMDeScRiPtIoN2",
64
- createdDateTime: "2021-10-04T22:13:50.397Z",
65
- state: IModelState.Initialized,
66
- projectId: mockITwinId,
67
- extent: null,
68
- _links: {
69
- creator: {
70
- href: "",
71
- },
72
- namedVersions: {
73
- href: "",
74
- },
75
- changesets: {
76
- href: "",
77
- },
78
- },
79
- },
80
- },
81
- ];
31
+ import type { IModelOperations, OperationOptions } from "@itwin/imodels-client-management/lib/operations";
82
32
 
83
33
  const mockProjectIModels = {
84
34
  iModels: mockIModelsResponse.map((iModel) => ({
@@ -8,6 +8,9 @@ import "@testing-library/jest-dom";
8
8
  import { ReportsConfigWidget } from "../ReportsConfigWidget";
9
9
  import {
10
10
  fireEvent,
11
+ mockIModelId1,
12
+ mockIModelsResponse,
13
+ mockReportId,
11
14
  render,
12
15
  screen,
13
16
  waitFor,
@@ -19,69 +22,13 @@ import type {
19
22
  ReportMappingCollection,
20
23
  } from "@itwin/insights-client";
21
24
  import type { ReportMappingAndMapping } from "../widget/components/ReportMappings";
22
- import type { GetSingleIModelParams, IModelOperations, OperationOptions } from "@itwin/imodels-client-management";
23
- import { IModelState } from "@itwin/imodels-client-management";
25
+ import type { GetSingleIModelParams } from "@itwin/imodels-client-management";
24
26
  import { BeEvent } from "@itwin/core-bentley";
25
27
  import { ExtractionStates } from "../widget/components/ExtractionStatus";
26
28
  import { ReportMappingHorizontalTile } from "../widget/components/ReportMappingHorizontalTile";
27
29
  import { EmptyLocalization } from "@itwin/core-common";
28
30
  import type { BulkExtractor } from "../widget/components/BulkExtractor";
29
-
30
- const mockITwinId = faker.datatype.uuid();
31
- // Lets work with two iModels for now.
32
- const mockIModelId1 = faker.datatype.uuid();
33
- const mockIModelId2 = faker.datatype.uuid();
34
-
35
- const mockReportId = faker.datatype.uuid();
36
-
37
- const mockIModelsResponse = [
38
- {
39
- iModel: {
40
- id: mockIModelId1,
41
- displayName: "rAnDoMdIsPlAynAmE1",
42
- name: "rAnDomName1",
43
- description: "rAnDoMDeScRiPtIoN1",
44
- createdDateTime: "2021-10-04T22:13:50.397Z",
45
- state: IModelState.Initialized,
46
- projectId: mockITwinId,
47
- extent: null,
48
- _links: {
49
- creator: {
50
- href: "",
51
- },
52
- namedVersions: {
53
- href: "",
54
- },
55
- changesets: {
56
- href: "",
57
- },
58
- },
59
- },
60
- },
61
- {
62
- iModel: {
63
- id: mockIModelId2,
64
- displayName: "rAnDoMdIsPlAynAmE2",
65
- name: "rAnDomName2",
66
- description: "rAnDoMDeScRiPtIoN2",
67
- createdDateTime: "2021-10-04T22:13:50.397Z",
68
- state: IModelState.Initialized,
69
- projectId: mockITwinId,
70
- extent: null,
71
- _links: {
72
- creator: {
73
- href: "",
74
- },
75
- namedVersions: {
76
- href: "",
77
- },
78
- changesets: {
79
- href: "",
80
- },
81
- },
82
- },
83
- },
84
- ];
31
+ import type { IModelOperations, OperationOptions } from "@itwin/imodels-client-management/lib/operations";
85
32
 
86
33
  const mockProjectIModels = {
87
34
  iModels: mockIModelsResponse.map((iModel) => ({
@@ -191,6 +138,7 @@ const mockBulkExtractor = moq.Mock.ofType<BulkExtractor>();
191
138
  const mockIModelsClient = moq.Mock.ofType<IModelOperations<OperationOptions>>();
192
139
 
193
140
  jest.mock("../widget/components/Constants.ts", () => ({
141
+ ...jest.requireActual("../widget/components/Constants.ts"),
194
142
  STATUS_CHECK_INTERVAL: 10,
195
143
  }));
196
144
 
@@ -7,7 +7,10 @@ import "@testing-library/jest-dom";
7
7
  import { ReportsConfigWidget } from "../ReportsConfigWidget";
8
8
  import {
9
9
  act,
10
- mockITwinId,
10
+ mockIModelId1,
11
+ mockIModelId2,
12
+ mockIModelsResponse,
13
+ mockReportId,
11
14
  render,
12
15
  screen,
13
16
  waitFor,
@@ -26,68 +29,13 @@ import {
26
29
  ReportsClient,
27
30
  } from "@itwin/insights-client";
28
31
  import { ReportMappings } from "../widget/components/ReportMappings";
29
- import type { GetSingleIModelParams, IModelOperations, IModelsClient, OperationOptions } from "@itwin/imodels-client-management";
30
- import { IModelState } from "@itwin/imodels-client-management";
32
+ import type { GetSingleIModelParams, IModelsClient } from "@itwin/imodels-client-management";
31
33
  import { BulkExtractor } from "../widget/components/BulkExtractor";
32
34
  import type { ReportMappingHorizontalTileProps } from "../widget/components/ReportMappingHorizontalTile";
33
35
  import { Text } from "@itwin/itwinui-react";
34
36
  import { EmptyLocalization } from "@itwin/core-common";
35
37
  import type { AddMappingsModalProps } from "../widget/components/AddMappingsModal";
36
-
37
- // Lets work with two iModels for now.
38
- const mockIModelId1 = "mockIModelId1";
39
- const mockIModelId2 = "mockIModelId2";
40
-
41
- const mockReportId = "mockReportId";
42
-
43
- const mockIModelsResponse = [
44
- {
45
- iModel: {
46
- id: mockIModelId1,
47
- displayName: "rAnDoMdIsPlAynAmE1",
48
- name: "rAnDomName1",
49
- description: "rAnDoMDeScRiPtIoN1",
50
- createdDateTime: "2021-10-04T22:13:50.397Z",
51
- state: IModelState.Initialized,
52
- projectId: mockITwinId,
53
- extent: null,
54
- _links: {
55
- creator: {
56
- href: "",
57
- },
58
- namedVersions: {
59
- href: "",
60
- },
61
- changesets: {
62
- href: "",
63
- },
64
- },
65
- },
66
- },
67
- {
68
- iModel: {
69
- id: mockIModelId2,
70
- displayName: "rAnDoMdIsPlAynAmE2",
71
- name: "rAnDomName2",
72
- description: "rAnDoMDeScRiPtIoN2",
73
- createdDateTime: "2021-10-04T22:13:50.397Z",
74
- state: IModelState.Initialized,
75
- projectId: mockITwinId,
76
- extent: null,
77
- _links: {
78
- creator: {
79
- href: "",
80
- },
81
- namedVersions: {
82
- href: "",
83
- },
84
- changesets: {
85
- href: "",
86
- },
87
- },
88
- },
89
- },
90
- ];
38
+ import type { IModelOperations, OperationOptions } from "@itwin/imodels-client-management/lib/operations";
91
39
 
92
40
  const mockProjectIModels = {
93
41
  iModels: mockIModelsResponse.map((iModel) => ({
@@ -188,6 +136,7 @@ const mockMappingsFactory = (
188
136
  };
189
137
 
190
138
  jest.mock("../widget/components/Constants.ts", () => ({
139
+ ...jest.requireActual("../widget/components/Constants.ts"),
191
140
  STATUS_CHECK_INTERVAL: 10,
192
141
  }));
193
142
 
@@ -12,13 +12,11 @@ import {
12
12
  } from "../test/test-utils";
13
13
  import { Reports } from "../widget/components/Reports";
14
14
  import { ReportsConfigWidget } from "../ReportsConfigWidget";
15
- import { rest } from "msw";
16
- import { setupServer } from "msw/node";
17
15
  import faker from "@faker-js/faker";
18
- import type { ReportCollection } from "@itwin/insights-client";
16
+ import type { ReportCollection, ReportsClient } from "@itwin/insights-client";
19
17
  import userEvent from "@testing-library/user-event";
20
- import { REPORTS_CONFIG_BASE_URL } from "../widget/ReportsConfigUiProvider";
21
18
  import { EmptyLocalization } from "@itwin/core-common";
19
+ import * as moq from "typemoq";
22
20
 
23
21
  const reportsFactory = (): ReportCollection => ({
24
22
  reports: Array.from(
@@ -43,38 +41,30 @@ const reportsFactory = (): ReportCollection => ({
43
41
  },
44
42
  });
45
43
 
46
- const server = setupServer();
44
+ const mockGetReports = jest.fn();
45
+ const mockDeleteReport = jest.fn();
46
+
47
+ const mockReportsClient = moq.Mock.ofType<ReportsClient>();
47
48
 
48
49
  beforeAll(async () => {
49
50
  const localization = new EmptyLocalization();
50
51
  await ReportsConfigWidget.initialize(localization);
51
- server.listen();
52
- });
53
52
 
54
- afterAll(() => {
55
- server.close();
53
+ mockReportsClient.setup(async (x) => x.getReports(moq.It.isAny(), moq.It.isAny())).returns(mockGetReports);
54
+ mockReportsClient.setup(async (x) => x.deleteReport(moq.It.isAny(), moq.It.isAny())).returns(mockDeleteReport);
56
55
  });
57
56
 
58
- afterEach(() => server.resetHandlers());
57
+ afterEach(() => {
58
+ mockGetReports.mockReset();
59
+ mockDeleteReport.mockReset();
60
+ });
59
61
 
60
62
  describe("Reports View", () => {
61
63
  it("call to action button should be clickable with no reports", async () => {
62
- server.use(
63
- rest.get(
64
- `${REPORTS_CONFIG_BASE_URL}/insights/reporting/reports`,
65
- async (_req, res, ctx) => {
66
- return res(
67
- ctx.delay(500),
68
- ctx.status(200),
69
- ctx.json({ reports: [] })
70
- );
71
- }
72
- )
73
- );
74
-
64
+ mockGetReports.mockReturnValueOnce([]);
75
65
  const onClickAddMock = jest.fn();
76
66
 
77
- const { user } = render(<Reports onClickAddReport={onClickAddMock} />);
67
+ const { user } = render(<Reports onClickAddReport={onClickAddMock} />, { reportsClient: mockReportsClient.object });
78
68
 
79
69
  await waitForElementToBeRemoved(() => screen.getByText(/loading/i));
80
70
  const ctaButton = screen.getByRole("button", {
@@ -85,21 +75,10 @@ describe("Reports View", () => {
85
75
  });
86
76
 
87
77
  it("be able to add new report", async () => {
88
- server.use(
89
- rest.get(
90
- `${REPORTS_CONFIG_BASE_URL}/insights/reporting/reports`,
91
- async (_req, res, ctx) => {
92
- return res(
93
- ctx.delay(500),
94
- ctx.status(200),
95
- ctx.json({ reports: [] })
96
- );
97
- }
98
- )
99
- );
78
+ mockGetReports.mockReturnValueOnce([]);
100
79
 
101
80
  const onClickAddMock = jest.fn();
102
- const { user } = render(<Reports onClickAddReport={onClickAddMock} />);
81
+ const { user } = render(<Reports onClickAddReport={onClickAddMock} />, { reportsClient: mockReportsClient.object });
103
82
 
104
83
  await waitForElementToBeRemoved(() => screen.getByText(/loading/i));
105
84
  const newButton = screen.getByRole("button", {
@@ -111,16 +90,9 @@ describe("Reports View", () => {
111
90
 
112
91
  it("list all reports", async () => {
113
92
  const mockedReports: ReportCollection = reportsFactory();
114
- server.use(
115
- rest.get(
116
- `${REPORTS_CONFIG_BASE_URL}/insights/reporting/reports`,
117
- async (_req, res, ctx) => {
118
- return res(ctx.delay(500), ctx.status(200), ctx.json(mockedReports));
119
- }
120
- )
121
- );
93
+ mockGetReports.mockReturnValueOnce(mockedReports.reports);
122
94
 
123
- render(<Reports />);
95
+ render(<Reports />, { reportsClient: mockReportsClient.object });
124
96
 
125
97
  await waitForElementToBeRemoved(() => screen.getByText(/loading/i));
126
98
  const horizontalTiles = screen.getAllByTestId("horizontal-tile");
@@ -144,16 +116,9 @@ describe("Reports View", () => {
144
116
 
145
117
  it("able to modify a report", async () => {
146
118
  const mockedReports: ReportCollection = reportsFactory();
147
- server.use(
148
- rest.get(
149
- `${REPORTS_CONFIG_BASE_URL}/insights/reporting/reports`,
150
- async (_req, res, ctx) => {
151
- return res(ctx.delay(500), ctx.status(200), ctx.json(mockedReports));
152
- }
153
- )
154
- );
119
+ mockGetReports.mockReturnValueOnce(mockedReports.reports);
155
120
  const onClickModifyMock = jest.fn();
156
- const { user } = render(<Reports onClickReportModify={onClickModifyMock} />);
121
+ const { user } = render(<Reports onClickReportModify={onClickModifyMock} />, { reportsClient: mockReportsClient.object });
157
122
 
158
123
  await waitForElementToBeRemoved(() => screen.getByText(/loading/i));
159
124
 
@@ -169,27 +134,10 @@ describe("Reports View", () => {
169
134
 
170
135
  it("remove a report", async () => {
171
136
  const mockedReports: ReportCollection = reportsFactory();
172
- const mockedReportsOriginalLength = mockedReports.reports.length;
173
- server.use(
174
- rest.get(
175
- `${REPORTS_CONFIG_BASE_URL}/insights/reporting/reports`,
176
- async (_req, res, ctx) => {
177
- return res(ctx.delay(200), ctx.status(200), ctx.json(mockedReports));
178
- }
179
- ),
180
- rest.delete(
181
- `${REPORTS_CONFIG_BASE_URL}/insights/reporting/reports/${mockedReports.reports[0].id
182
- }`,
183
- async (_req, res, ctx) => {
184
- mockedReports.reports = mockedReports.reports.filter(
185
- (report) => report.id !== mockedReports.reports[0].id
186
- );
187
- return res(ctx.delay(100), ctx.status(204));
188
- }
189
- )
190
- );
191
137
 
192
- const { user } = render(<Reports />);
138
+ mockGetReports.mockReturnValue(mockedReports.reports);
139
+
140
+ const { user } = render(<Reports />, { reportsClient: mockReportsClient.object });
193
141
 
194
142
  await waitForElementToBeRemoved(() => screen.getByText(/loading/i));
195
143
 
@@ -208,29 +156,17 @@ describe("Reports View", () => {
208
156
 
209
157
  await user.click(deleteButton);
210
158
 
211
- await waitForElementToBeRemoved(() =>
212
- screen.getByTestId(/rcw-loading-delete/i)
213
- );
214
159
  await waitForElementToBeRemoved(() => screen.getByRole("dialog"));
215
160
 
216
- // Should be one less report
217
- expect(screen.getAllByTestId("horizontal-tile")).toHaveLength(
218
- mockedReportsOriginalLength - 1
219
- );
161
+ expect(mockDeleteReport).toBeCalled();
162
+ // Two calls, when it is first rendered and when it is refreshed.
163
+ expect(mockGetReports).toBeCalledTimes(2);
220
164
  });
221
165
 
222
166
  it("search for a report", async () => {
223
167
  const mockedReports: ReportCollection = reportsFactory();
224
- server.use(
225
- rest.get(
226
- `${REPORTS_CONFIG_BASE_URL}/insights/reporting/reports`,
227
- async (_req, res, ctx) => {
228
- return res(ctx.delay(200), ctx.status(200), ctx.json(mockedReports));
229
- }
230
- )
231
- );
232
-
233
- const { user } = render(<Reports />);
168
+ mockGetReports.mockReturnValueOnce(mockedReports.reports);
169
+ const { user } = render(<Reports />, { reportsClient: mockReportsClient.object });
234
170
 
235
171
  await waitForElementToBeRemoved(() => screen.getByText(/loading/i));
236
172
 
@@ -265,16 +201,9 @@ describe("Reports View", () => {
265
201
 
266
202
  it("modify a report", async () => {
267
203
  const mockedReports: ReportCollection = reportsFactory();
268
- server.use(
269
- rest.get(
270
- `${REPORTS_CONFIG_BASE_URL}/insights/reporting/reports`,
271
- async (_req, res, ctx) => {
272
- return res(ctx.delay(200), ctx.status(200), ctx.json(mockedReports));
273
- }
274
- )
275
- );
204
+ mockGetReports.mockReturnValueOnce(mockedReports.reports);
276
205
  const onClickModifyMock = jest.fn();
277
- const { user } = render(<Reports onClickReportModify={onClickModifyMock} />);
206
+ const { user } = render(<Reports onClickReportModify={onClickModifyMock} />, { reportsClient: mockReportsClient.object });
278
207
 
279
208
  await waitForElementToBeRemoved(() => screen.getByText(/loading/i));
280
209
 
@@ -289,16 +218,9 @@ describe("Reports View", () => {
289
218
 
290
219
  it("click a report", async () => {
291
220
  const mockedReports: ReportCollection = reportsFactory();
292
- server.use(
293
- rest.get(
294
- `${REPORTS_CONFIG_BASE_URL}/insights/reporting/reports`,
295
- async (_req, res, ctx) => {
296
- return res(ctx.delay(200), ctx.status(200), ctx.json(mockedReports));
297
- }
298
- )
299
- );
221
+ mockGetReports.mockReturnValueOnce(mockedReports.reports);
300
222
  const onClickTitleMock = jest.fn();
301
- const { user } = render(<Reports onClickReportTitle={onClickTitleMock} />);
223
+ const { user } = render(<Reports onClickReportTitle={onClickTitleMock} />, { reportsClient: mockReportsClient.object });
302
224
 
303
225
  await waitForElementToBeRemoved(() => screen.getByText(/loading/i));
304
226
 
@@ -7,8 +7,15 @@ import "@testing-library/jest-dom";
7
7
  import { render, screen } from "../test/test-utils";
8
8
  import { WidgetHeader } from "../widget/components/utils";
9
9
  import { faker } from "@faker-js/faker";
10
+ import { EmptyLocalization } from "@itwin/core-common";
11
+ import { ReportsConfigWidget } from "../ReportsConfigWidget";
10
12
 
11
13
  describe("Widget Header Component", () => {
14
+ beforeAll(async () => {
15
+ const localization = new EmptyLocalization();
16
+ await ReportsConfigWidget.initialize(localization);
17
+ });
18
+
12
19
  it("title renders", async () => {
13
20
  const fakeTitle = faker.word.interjection();
14
21
  render(<WidgetHeader title={fakeTitle} />);
@@ -20,9 +27,9 @@ describe("Widget Header Component", () => {
20
27
 
21
28
  it("header allows return callback", async () => {
22
29
  const mockReturnFn = jest.fn();
23
- const { user } = render(<WidgetHeader title="" returnFn={mockReturnFn} />);
30
+ const { user, container } = render(<WidgetHeader title="" returnFn={mockReturnFn} />);
24
31
 
25
- const returnBtn = screen.getByRole("button");
32
+ const returnBtn = container.getElementsByClassName("rcw-chevron")[0];
26
33
  await user.click(returnBtn);
27
34
  expect(mockReturnFn).toHaveBeenCalledTimes(1);
28
35
  });
@@ -7,13 +7,74 @@ import { render as rtlRender } from "@testing-library/react";
7
7
  import userEvent from "@testing-library/user-event";
8
8
  import type { ReportsConfigContextProps } from "../widget/components/ReportsConfigContext";
9
9
  import { ReportsConfigContext } from "../widget/components/ReportsConfigContext";
10
+ import { IModelState } from "@itwin/imodels-client-management";
10
11
 
11
12
  export const mockAccessToken = async () => "Bearer eyJhbGci";
12
13
 
14
+ export const mockIModelId1 = "mockIModelId1";
15
+ export const mockIModelId2 = "mockIModelId2";
16
+
17
+ export const mockReportId = "mockReportId";
18
+ export const mockITwinId: string = "mockiTwinId";
19
+
20
+ export const mockIModelsResponse = [
21
+ {
22
+ iModel: {
23
+ id: mockIModelId1,
24
+ displayName: "rAnDoMdIsPlAynAmE1",
25
+ name: "rAnDomName1",
26
+ description: "rAnDoMDeScRiPtIoN1",
27
+ createdDateTime: "2021-10-04T22:13:50.397Z",
28
+ state: IModelState.Initialized,
29
+ iTwinId: mockITwinId,
30
+ extent: null,
31
+ getCreator: async () => undefined,
32
+ _links: {
33
+ creator: {
34
+ href: "",
35
+ },
36
+ namedVersions: {
37
+ href: "",
38
+ },
39
+ changesets: {
40
+ href: "",
41
+ },
42
+ upload: undefined,
43
+ complete: undefined,
44
+ },
45
+ },
46
+ },
47
+ {
48
+ iModel: {
49
+ id: mockIModelId2,
50
+ displayName: "rAnDoMdIsPlAynAmE2",
51
+ name: "rAnDomName2",
52
+ description: "rAnDoMDeScRiPtIoN2",
53
+ createdDateTime: "2021-10-04T22:13:50.397Z",
54
+ state: IModelState.Initialized,
55
+ iTwinId: mockITwinId,
56
+ extent: null,
57
+ getCreator: async () => undefined,
58
+ _links: {
59
+ creator: {
60
+ href: "",
61
+ },
62
+ namedVersions: {
63
+ href: "",
64
+ },
65
+ changesets: {
66
+ href: "",
67
+ },
68
+ upload: undefined,
69
+ complete: undefined,
70
+ },
71
+ },
72
+ },
73
+ ];
74
+
13
75
  interface WrapperProps {
14
76
  children?: React.ReactNode;
15
77
  }
16
- export const mockITwinId: string = "mockiTwinId";
17
78
 
18
79
  function render(ui: React.ReactElement, contextProps?: Partial<ReportsConfigContextProps>, { ...options } = {}) {
19
80
  const Wrapper = ({ children }: WrapperProps) => (
@@ -3,14 +3,14 @@
3
3
  * See LICENSE.md in the project root for license terms and full copyright notice.
4
4
  *--------------------------------------------------------------------------------------------*/
5
5
  import type {
6
- AbstractWidgetProps,
7
6
  UiItemsProvider,
8
- } from "@itwin/appui-abstract";
7
+ Widget,
8
+ } from "@itwin/appui-react";
9
9
  import {
10
10
  StagePanelLocation,
11
11
  StagePanelSection,
12
12
  StageUsage,
13
- } from "@itwin/appui-abstract";
13
+ } from "@itwin/appui-react";
14
14
  import type { AccessToken } from "@itwin/core-bentley";
15
15
 
16
16
  import * as React from "react";
@@ -37,26 +37,19 @@ export class ReportsConfigProvider implements UiItemsProvider {
37
37
  stageUsage: string,
38
38
  location: StagePanelLocation,
39
39
  section?: StagePanelSection
40
- ): ReadonlyArray<AbstractWidgetProps> {
41
- const widgets: AbstractWidgetProps[] = [];
40
+ ): ReadonlyArray<Widget> {
41
+ const widgets: Widget[] = [];
42
42
  if (
43
43
  location === StagePanelLocation.Left &&
44
44
  section === StagePanelSection.Start &&
45
45
  stageUsage === StageUsage.General
46
46
  ) {
47
- const ReportsWidget: AbstractWidgetProps = {
47
+ const ReportsWidget: Widget = {
48
48
  id: "reports-config-widget",
49
49
  label: ReportsConfigWidget.localization.getLocalizedString(
50
50
  "ReportsConfigWidget:ReportsConfig"
51
51
  ),
52
- getWidgetContent: () => {
53
- return (
54
- <ReportsContainer
55
- getAccessToken={this._getAccessToken}
56
- baseUrl={this._baseUrl}
57
- />
58
- );
59
- },
52
+ content: <ReportsContainer getAccessToken={this._getAccessToken} baseUrl={this._baseUrl} />,
60
53
  };
61
54
 
62
55
  widgets.push(ReportsWidget);
@@ -2,11 +2,10 @@
2
2
  * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
3
  * See LICENSE.md in the project root for license terms and full copyright notice.
4
4
  *--------------------------------------------------------------------------------------------*/
5
- @import "~@itwin/itwinui-css/scss/variables";
6
5
 
7
6
  .rcw-action-panel {
8
7
  display: flex;
9
8
  justify-content: right;
10
- padding: $iui-baseline * 2 $iui-m $iui-baseline;
11
- gap: $iui-s;
9
+ padding: calc(var(--iui-size-s) * 2) var(--iui-size-m) var(--iui-size-s);
10
+ gap: var(--iui-size-xs);
12
11
  }
@@ -24,7 +24,7 @@ const ActionPanel = ({
24
24
  isCancelDisabled = false,
25
25
  isSavingDisabled = false,
26
26
  isLoading = false,
27
- }: ActionPanelProps): JSX.Element => {
27
+ }: ActionPanelProps): React.ReactElement => {
28
28
  return (
29
29
  <div className="rcw-action-panel">
30
30
  {isLoading && <LoadingSpinner />}
@@ -2,12 +2,11 @@
2
2
  * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
3
  * See LICENSE.md in the project root for license terms and full copyright notice.
4
4
  *--------------------------------------------------------------------------------------------*/
5
- @import "~@itwin/itwinui-css/scss/variables";
6
5
 
7
6
  .rcw-add-mappings-container {
8
7
  display: flex;
9
8
  flex-direction: column;
10
- gap: $iui-baseline;
9
+ gap: var(--iui-size-s);
11
10
  width: 45vw;
12
11
  min-width: 100%;
13
12
  overflow: auto;