@itwin/reports-config-widget-react 0.0.1

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 (294) hide show
  1. package/.rush/temp/package-deps_rebuild.json +48 -0
  2. package/.rush/temp/shrinkwrap-deps.json +868 -0
  3. package/CHANGELOG.json +17 -0
  4. package/CHANGELOG.md +11 -0
  5. package/LICENSE.md +9 -0
  6. package/README.md +38 -0
  7. package/__mocks__/fileMock.js +5 -0
  8. package/coverage/clover.xml +612 -0
  9. package/coverage/coverage-final.json +19 -0
  10. package/coverage/lcov-report/base.css +224 -0
  11. package/coverage/lcov-report/block-navigation.js +87 -0
  12. package/coverage/lcov-report/favicon.png +0 -0
  13. package/coverage/lcov-report/index.html +191 -0
  14. package/coverage/lcov-report/prettify.css +1 -0
  15. package/coverage/lcov-report/prettify.js +2 -0
  16. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  17. package/coverage/lcov-report/sorter.js +196 -0
  18. package/coverage/lcov-report/src/ReportsConfigWidget.ts.html +193 -0
  19. package/coverage/lcov-report/src/index.html +116 -0
  20. package/coverage/lcov-report/src/test/index.html +116 -0
  21. package/coverage/lcov-report/src/test/test-utils.tsx.html +316 -0
  22. package/coverage/lcov-report/src/widget/ReportsConfigUiProvider.tsx.html +286 -0
  23. package/coverage/lcov-report/src/widget/components/ActionPanel.tsx.html +253 -0
  24. package/coverage/lcov-report/src/widget/components/AddMappingsModal.tsx.html +610 -0
  25. package/coverage/lcov-report/src/widget/components/DeleteModal.tsx.html +385 -0
  26. package/coverage/lcov-report/src/widget/components/Extraction.tsx.html +1030 -0
  27. package/coverage/lcov-report/src/widget/components/HorizontalTile.tsx.html +256 -0
  28. package/coverage/lcov-report/src/widget/components/LocalizedTablePaginator.tsx.html +262 -0
  29. package/coverage/lcov-report/src/widget/components/ReportAction.tsx.html +523 -0
  30. package/coverage/lcov-report/src/widget/components/ReportMappings.tsx.html +1135 -0
  31. package/coverage/lcov-report/src/widget/components/Reports.tsx.html +829 -0
  32. package/coverage/lcov-report/src/widget/components/ReportsContainer.tsx.html +193 -0
  33. package/coverage/lcov-report/src/widget/components/SearchBar.tsx.html +271 -0
  34. package/coverage/lcov-report/src/widget/components/SelectIModel.tsx.html +391 -0
  35. package/coverage/lcov-report/src/widget/components/index.html +296 -0
  36. package/coverage/lcov-report/src/widget/components/utils.tsx.html +562 -0
  37. package/coverage/lcov-report/src/widget/context/ReportsApiConfigContext.tsx.html +166 -0
  38. package/coverage/lcov-report/src/widget/context/index.html +116 -0
  39. package/coverage/lcov-report/src/widget/hooks/index.html +116 -0
  40. package/coverage/lcov-report/src/widget/hooks/useValidator.ts.html +295 -0
  41. package/coverage/lcov-report/src/widget/index.html +116 -0
  42. package/coverage/lcov.info +1260 -0
  43. package/jest.config.js +19 -0
  44. package/lib/cjs/ReportsConfigWidget.d.ts +10 -0
  45. package/lib/cjs/ReportsConfigWidget.d.ts.map +1 -0
  46. package/lib/cjs/ReportsConfigWidget.js +24 -0
  47. package/lib/cjs/ReportsConfigWidget.js.map +1 -0
  48. package/lib/cjs/reports-config-widget-react.d.ts +4 -0
  49. package/lib/cjs/reports-config-widget-react.d.ts.map +1 -0
  50. package/lib/cjs/reports-config-widget-react.js +20 -0
  51. package/lib/cjs/reports-config-widget-react.js.map +1 -0
  52. package/lib/cjs/test/ReportAction.test.d.ts +2 -0
  53. package/lib/cjs/test/ReportAction.test.d.ts.map +1 -0
  54. package/lib/cjs/test/ReportAction.test.js +194 -0
  55. package/lib/cjs/test/ReportAction.test.js.map +1 -0
  56. package/lib/cjs/test/ReportMappings.test.d.ts +2 -0
  57. package/lib/cjs/test/ReportMappings.test.d.ts.map +1 -0
  58. package/lib/cjs/test/ReportMappings.test.js +530 -0
  59. package/lib/cjs/test/ReportMappings.test.js.map +1 -0
  60. package/lib/cjs/test/Reports.test.d.ts +2 -0
  61. package/lib/cjs/test/Reports.test.d.ts.map +1 -0
  62. package/lib/cjs/test/Reports.test.js +232 -0
  63. package/lib/cjs/test/Reports.test.js.map +1 -0
  64. package/lib/cjs/test/WidgetHeader.test.d.ts +2 -0
  65. package/lib/cjs/test/WidgetHeader.test.d.ts.map +1 -0
  66. package/lib/cjs/test/WidgetHeader.test.js +30 -0
  67. package/lib/cjs/test/WidgetHeader.test.js.map +1 -0
  68. package/lib/cjs/test/test-utils.d.ts +69 -0
  69. package/lib/cjs/test/test-utils.d.ts.map +1 -0
  70. package/lib/cjs/test/test-utils.js +77 -0
  71. package/lib/cjs/test/test-utils.js.map +1 -0
  72. package/lib/cjs/tsconfig.tsbuildinfo +1 -0
  73. package/lib/cjs/widget/ReportsConfigUiProvider.d.ts +12 -0
  74. package/lib/cjs/widget/ReportsConfigUiProvider.d.ts.map +1 -0
  75. package/lib/cjs/widget/ReportsConfigUiProvider.js +55 -0
  76. package/lib/cjs/widget/ReportsConfigUiProvider.js.map +1 -0
  77. package/lib/cjs/widget/components/ActionPanel.d.ts +13 -0
  78. package/lib/cjs/widget/components/ActionPanel.d.ts.map +1 -0
  79. package/lib/cjs/widget/components/ActionPanel.js +39 -0
  80. package/lib/cjs/widget/components/ActionPanel.js.map +1 -0
  81. package/lib/cjs/widget/components/ActionPanel.scss +12 -0
  82. package/lib/cjs/widget/components/AddMappingsModal.d.ts +15 -0
  83. package/lib/cjs/widget/components/AddMappingsModal.d.ts.map +1 -0
  84. package/lib/cjs/widget/components/AddMappingsModal.js +118 -0
  85. package/lib/cjs/widget/components/AddMappingsModal.js.map +1 -0
  86. package/lib/cjs/widget/components/AddMappingsModal.scss +18 -0
  87. package/lib/cjs/widget/components/DeleteModal.d.ts +12 -0
  88. package/lib/cjs/widget/components/DeleteModal.d.ts.map +1 -0
  89. package/lib/cjs/widget/components/DeleteModal.js +65 -0
  90. package/lib/cjs/widget/components/DeleteModal.js.map +1 -0
  91. package/lib/cjs/widget/components/DeleteModal.scss +18 -0
  92. package/lib/cjs/widget/components/Extraction.d.ts +28 -0
  93. package/lib/cjs/widget/components/Extraction.d.ts.map +1 -0
  94. package/lib/cjs/widget/components/Extraction.js +193 -0
  95. package/lib/cjs/widget/components/Extraction.js.map +1 -0
  96. package/lib/cjs/widget/components/Extraction.scss +39 -0
  97. package/lib/cjs/widget/components/HorizontalTile.d.ts +13 -0
  98. package/lib/cjs/widget/components/HorizontalTile.d.ts.map +1 -0
  99. package/lib/cjs/widget/components/HorizontalTile.js +18 -0
  100. package/lib/cjs/widget/components/HorizontalTile.js.map +1 -0
  101. package/lib/cjs/widget/components/HorizontalTile.scss +32 -0
  102. package/lib/cjs/widget/components/LocalizedTablePaginator.d.ts +4 -0
  103. package/lib/cjs/widget/components/LocalizedTablePaginator.d.ts.map +1 -0
  104. package/lib/cjs/widget/components/LocalizedTablePaginator.js +41 -0
  105. package/lib/cjs/widget/components/LocalizedTablePaginator.js.map +1 -0
  106. package/lib/cjs/widget/components/ReportAction.d.ts +11 -0
  107. package/lib/cjs/widget/components/ReportAction.d.ts.map +1 -0
  108. package/lib/cjs/widget/components/ReportAction.js +101 -0
  109. package/lib/cjs/widget/components/ReportAction.js.map +1 -0
  110. package/lib/cjs/widget/components/ReportAction.scss +16 -0
  111. package/lib/cjs/widget/components/ReportMappings.d.ts +17 -0
  112. package/lib/cjs/widget/components/ReportMappings.d.ts.map +1 -0
  113. package/lib/cjs/widget/components/ReportMappings.js +174 -0
  114. package/lib/cjs/widget/components/ReportMappings.js.map +1 -0
  115. package/lib/cjs/widget/components/ReportMappings.scss +46 -0
  116. package/lib/cjs/widget/components/Reports.d.ts +7 -0
  117. package/lib/cjs/widget/components/Reports.d.ts.map +1 -0
  118. package/lib/cjs/widget/components/Reports.js +143 -0
  119. package/lib/cjs/widget/components/Reports.js.map +1 -0
  120. package/lib/cjs/widget/components/Reports.scss +36 -0
  121. package/lib/cjs/widget/components/ReportsContainer.d.ts +10 -0
  122. package/lib/cjs/widget/components/ReportsContainer.d.ts.map +1 -0
  123. package/lib/cjs/widget/components/ReportsContainer.js +34 -0
  124. package/lib/cjs/widget/components/ReportsContainer.js.map +1 -0
  125. package/lib/cjs/widget/components/ReportsContainer.scss +15 -0
  126. package/lib/cjs/widget/components/SearchBar.d.ts +10 -0
  127. package/lib/cjs/widget/components/SearchBar.d.ts.map +1 -0
  128. package/lib/cjs/widget/components/SearchBar.js +50 -0
  129. package/lib/cjs/widget/components/SearchBar.js.map +1 -0
  130. package/lib/cjs/widget/components/SearchBar.scss +27 -0
  131. package/lib/cjs/widget/components/SelectIModel.d.ts +9 -0
  132. package/lib/cjs/widget/components/SelectIModel.d.ts.map +1 -0
  133. package/lib/cjs/widget/components/SelectIModel.js +82 -0
  134. package/lib/cjs/widget/components/SelectIModel.js.map +1 -0
  135. package/lib/cjs/widget/components/SelectIModel.scss +15 -0
  136. package/lib/cjs/widget/components/utils.d.ts +23 -0
  137. package/lib/cjs/widget/components/utils.d.ts.map +1 -0
  138. package/lib/cjs/widget/components/utils.js +87 -0
  139. package/lib/cjs/widget/components/utils.js.map +1 -0
  140. package/lib/cjs/widget/components/utils.scss +39 -0
  141. package/lib/cjs/widget/context/ReportsApiConfigContext.d.ts +9 -0
  142. package/lib/cjs/widget/context/ReportsApiConfigContext.d.ts.map +1 -0
  143. package/lib/cjs/widget/context/ReportsApiConfigContext.js +37 -0
  144. package/lib/cjs/widget/context/ReportsApiConfigContext.js.map +1 -0
  145. package/lib/cjs/widget/hooks/useValidator.d.ts +8 -0
  146. package/lib/cjs/widget/hooks/useValidator.d.ts.map +1 -0
  147. package/lib/cjs/widget/hooks/useValidator.js +56 -0
  148. package/lib/cjs/widget/hooks/useValidator.js.map +1 -0
  149. package/lib/esm/ReportsConfigWidget.d.ts +10 -0
  150. package/lib/esm/ReportsConfigWidget.d.ts.map +1 -0
  151. package/lib/esm/ReportsConfigWidget.js +20 -0
  152. package/lib/esm/ReportsConfigWidget.js.map +1 -0
  153. package/lib/esm/reports-config-widget-react.d.ts +4 -0
  154. package/lib/esm/reports-config-widget-react.d.ts.map +1 -0
  155. package/lib/esm/reports-config-widget-react.js +8 -0
  156. package/lib/esm/reports-config-widget-react.js.map +1 -0
  157. package/lib/esm/test/ReportAction.test.d.ts +2 -0
  158. package/lib/esm/test/ReportAction.test.d.ts.map +1 -0
  159. package/lib/esm/test/ReportAction.test.js +170 -0
  160. package/lib/esm/test/ReportAction.test.js.map +1 -0
  161. package/lib/esm/test/ReportMappings.test.d.ts +2 -0
  162. package/lib/esm/test/ReportMappings.test.d.ts.map +1 -0
  163. package/lib/esm/test/ReportMappings.test.js +506 -0
  164. package/lib/esm/test/ReportMappings.test.js.map +1 -0
  165. package/lib/esm/test/Reports.test.d.ts +2 -0
  166. package/lib/esm/test/Reports.test.d.ts.map +1 -0
  167. package/lib/esm/test/Reports.test.js +208 -0
  168. package/lib/esm/test/Reports.test.js.map +1 -0
  169. package/lib/esm/test/WidgetHeader.test.d.ts +2 -0
  170. package/lib/esm/test/WidgetHeader.test.d.ts.map +1 -0
  171. package/lib/esm/test/WidgetHeader.test.js +25 -0
  172. package/lib/esm/test/WidgetHeader.test.js.map +1 -0
  173. package/lib/esm/test/test-utils.d.ts +69 -0
  174. package/lib/esm/test/test-utils.d.ts.map +1 -0
  175. package/lib/esm/test/test-utils.js +48 -0
  176. package/lib/esm/test/test-utils.js.map +1 -0
  177. package/lib/esm/tsconfig.tsbuildinfo +1 -0
  178. package/lib/esm/widget/ReportsConfigUiProvider.d.ts +12 -0
  179. package/lib/esm/widget/ReportsConfigUiProvider.d.ts.map +1 -0
  180. package/lib/esm/widget/ReportsConfigUiProvider.js +29 -0
  181. package/lib/esm/widget/ReportsConfigUiProvider.js.map +1 -0
  182. package/lib/esm/widget/components/ActionPanel.d.ts +13 -0
  183. package/lib/esm/widget/components/ActionPanel.d.ts.map +1 -0
  184. package/lib/esm/widget/components/ActionPanel.js +18 -0
  185. package/lib/esm/widget/components/ActionPanel.js.map +1 -0
  186. package/lib/esm/widget/components/ActionPanel.scss +12 -0
  187. package/lib/esm/widget/components/AddMappingsModal.d.ts +15 -0
  188. package/lib/esm/widget/components/AddMappingsModal.d.ts.map +1 -0
  189. package/lib/esm/widget/components/AddMappingsModal.js +94 -0
  190. package/lib/esm/widget/components/AddMappingsModal.js.map +1 -0
  191. package/lib/esm/widget/components/AddMappingsModal.scss +18 -0
  192. package/lib/esm/widget/components/DeleteModal.d.ts +12 -0
  193. package/lib/esm/widget/components/DeleteModal.d.ts.map +1 -0
  194. package/lib/esm/widget/components/DeleteModal.js +42 -0
  195. package/lib/esm/widget/components/DeleteModal.js.map +1 -0
  196. package/lib/esm/widget/components/DeleteModal.scss +18 -0
  197. package/lib/esm/widget/components/Extraction.d.ts +28 -0
  198. package/lib/esm/widget/components/Extraction.d.ts.map +1 -0
  199. package/lib/esm/widget/components/Extraction.js +169 -0
  200. package/lib/esm/widget/components/Extraction.js.map +1 -0
  201. package/lib/esm/widget/components/Extraction.scss +39 -0
  202. package/lib/esm/widget/components/HorizontalTile.d.ts +13 -0
  203. package/lib/esm/widget/components/HorizontalTile.d.ts.map +1 -0
  204. package/lib/esm/widget/components/HorizontalTile.js +11 -0
  205. package/lib/esm/widget/components/HorizontalTile.js.map +1 -0
  206. package/lib/esm/widget/components/HorizontalTile.scss +32 -0
  207. package/lib/esm/widget/components/LocalizedTablePaginator.d.ts +4 -0
  208. package/lib/esm/widget/components/LocalizedTablePaginator.d.ts.map +1 -0
  209. package/lib/esm/widget/components/LocalizedTablePaginator.js +18 -0
  210. package/lib/esm/widget/components/LocalizedTablePaginator.js.map +1 -0
  211. package/lib/esm/widget/components/ReportAction.d.ts +11 -0
  212. package/lib/esm/widget/components/ReportAction.d.ts.map +1 -0
  213. package/lib/esm/widget/components/ReportAction.js +77 -0
  214. package/lib/esm/widget/components/ReportAction.js.map +1 -0
  215. package/lib/esm/widget/components/ReportAction.scss +16 -0
  216. package/lib/esm/widget/components/ReportMappings.d.ts +17 -0
  217. package/lib/esm/widget/components/ReportMappings.d.ts.map +1 -0
  218. package/lib/esm/widget/components/ReportMappings.js +148 -0
  219. package/lib/esm/widget/components/ReportMappings.js.map +1 -0
  220. package/lib/esm/widget/components/ReportMappings.scss +46 -0
  221. package/lib/esm/widget/components/Reports.d.ts +7 -0
  222. package/lib/esm/widget/components/Reports.d.ts.map +1 -0
  223. package/lib/esm/widget/components/Reports.js +117 -0
  224. package/lib/esm/widget/components/Reports.js.map +1 -0
  225. package/lib/esm/widget/components/Reports.scss +36 -0
  226. package/lib/esm/widget/components/ReportsContainer.d.ts +10 -0
  227. package/lib/esm/widget/components/ReportsContainer.d.ts.map +1 -0
  228. package/lib/esm/widget/components/ReportsContainer.js +13 -0
  229. package/lib/esm/widget/components/ReportsContainer.js.map +1 -0
  230. package/lib/esm/widget/components/ReportsContainer.scss +15 -0
  231. package/lib/esm/widget/components/SearchBar.d.ts +10 -0
  232. package/lib/esm/widget/components/SearchBar.d.ts.map +1 -0
  233. package/lib/esm/widget/components/SearchBar.js +27 -0
  234. package/lib/esm/widget/components/SearchBar.js.map +1 -0
  235. package/lib/esm/widget/components/SearchBar.scss +27 -0
  236. package/lib/esm/widget/components/SelectIModel.d.ts +9 -0
  237. package/lib/esm/widget/components/SelectIModel.d.ts.map +1 -0
  238. package/lib/esm/widget/components/SelectIModel.js +59 -0
  239. package/lib/esm/widget/components/SelectIModel.js.map +1 -0
  240. package/lib/esm/widget/components/SelectIModel.scss +15 -0
  241. package/lib/esm/widget/components/utils.d.ts +23 -0
  242. package/lib/esm/widget/components/utils.d.ts.map +1 -0
  243. package/lib/esm/widget/components/utils.js +73 -0
  244. package/lib/esm/widget/components/utils.js.map +1 -0
  245. package/lib/esm/widget/components/utils.scss +39 -0
  246. package/lib/esm/widget/context/ReportsApiConfigContext.d.ts +9 -0
  247. package/lib/esm/widget/context/ReportsApiConfigContext.d.ts.map +1 -0
  248. package/lib/esm/widget/context/ReportsApiConfigContext.js +14 -0
  249. package/lib/esm/widget/context/ReportsApiConfigContext.js.map +1 -0
  250. package/lib/esm/widget/hooks/useValidator.d.ts +8 -0
  251. package/lib/esm/widget/hooks/useValidator.d.ts.map +1 -0
  252. package/lib/esm/widget/hooks/useValidator.js +50 -0
  253. package/lib/esm/widget/hooks/useValidator.js.map +1 -0
  254. package/lib/public/locales/en/ReportsConfigWidget.json +76 -0
  255. package/package.json +124 -0
  256. package/public/locales/en/ReportsConfigWidget.json +76 -0
  257. package/reports-config-widget-react.build.error.log +10 -0
  258. package/reports-config-widget-react.build.log +45 -0
  259. package/src/ReportsConfigWidget.ts +36 -0
  260. package/src/reports-config-widget-react.ts +7 -0
  261. package/src/test/ReportAction.test.tsx +258 -0
  262. package/src/test/ReportMappings.test.tsx +882 -0
  263. package/src/test/Reports.test.tsx +365 -0
  264. package/src/test/WidgetHeader.test.tsx +29 -0
  265. package/src/test/test-utils.tsx +77 -0
  266. package/src/widget/ReportsConfigUiProvider.tsx +67 -0
  267. package/src/widget/components/ActionPanel.scss +12 -0
  268. package/src/widget/components/ActionPanel.tsx +56 -0
  269. package/src/widget/components/AddMappingsModal.scss +18 -0
  270. package/src/widget/components/AddMappingsModal.tsx +175 -0
  271. package/src/widget/components/DeleteModal.scss +18 -0
  272. package/src/widget/components/DeleteModal.tsx +100 -0
  273. package/src/widget/components/Extraction.scss +39 -0
  274. package/src/widget/components/Extraction.tsx +315 -0
  275. package/src/widget/components/HorizontalTile.scss +32 -0
  276. package/src/widget/components/HorizontalTile.tsx +57 -0
  277. package/src/widget/components/LocalizedTablePaginator.tsx +59 -0
  278. package/src/widget/components/ReportAction.scss +16 -0
  279. package/src/widget/components/ReportAction.tsx +146 -0
  280. package/src/widget/components/ReportMappings.scss +46 -0
  281. package/src/widget/components/ReportMappings.tsx +350 -0
  282. package/src/widget/components/Reports.scss +36 -0
  283. package/src/widget/components/Reports.tsx +248 -0
  284. package/src/widget/components/ReportsContainer.scss +15 -0
  285. package/src/widget/components/ReportsContainer.tsx +36 -0
  286. package/src/widget/components/SearchBar.scss +27 -0
  287. package/src/widget/components/SearchBar.tsx +62 -0
  288. package/src/widget/components/SelectIModel.scss +15 -0
  289. package/src/widget/components/SelectIModel.tsx +102 -0
  290. package/src/widget/components/utils.scss +39 -0
  291. package/src/widget/components/utils.tsx +159 -0
  292. package/src/widget/context/ReportsApiConfigContext.tsx +27 -0
  293. package/src/widget/hooks/useValidator.ts +70 -0
  294. package/tsconfig.json +11 -0
@@ -0,0 +1,530 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ var __importDefault = (this && this.__importDefault) || function (mod) {
22
+ return (mod && mod.__esModule) ? mod : { "default": mod };
23
+ };
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ /*---------------------------------------------------------------------------------------------
26
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
27
+ * See LICENSE.md in the project root for license terms and full copyright notice.
28
+ *--------------------------------------------------------------------------------------------*/
29
+ const react_1 = __importDefault(require("react"));
30
+ const faker_1 = __importDefault(require("@faker-js/faker"));
31
+ require("@testing-library/jest-dom");
32
+ const core_frontend_1 = require("@itwin/core-frontend");
33
+ const ReportsConfigWidget_1 = require("../ReportsConfigWidget");
34
+ const node_1 = require("msw/node");
35
+ const test_utils_1 = require("./test-utils");
36
+ const user_event_1 = __importDefault(require("@testing-library/user-event"));
37
+ const moq = __importStar(require("typemoq"));
38
+ const msw_1 = require("msw");
39
+ const ReportMappings_1 = require("../widget/components/ReportMappings");
40
+ const imodels_client_management_1 = require("@itwin/imodels-client-management");
41
+ const ReportsConfigUiProvider_1 = require("../widget/ReportsConfigUiProvider");
42
+ const Extraction_1 = require("../widget/components/Extraction");
43
+ const presentation_frontend_1 = require("@itwin/presentation-frontend");
44
+ // For the extraction test
45
+ jest.setTimeout(20000);
46
+ const mockITwinId = faker_1.default.datatype.uuid();
47
+ // Lets work with two iModels for now.
48
+ const mockIModelId1 = faker_1.default.datatype.uuid();
49
+ const mockIModelId2 = faker_1.default.datatype.uuid();
50
+ const mockReportId = faker_1.default.datatype.uuid();
51
+ const mockIModelsResponse = [
52
+ {
53
+ iModel: {
54
+ id: mockIModelId1,
55
+ displayName: faker_1.default.random.alpha(10),
56
+ name: faker_1.default.random.alpha(10),
57
+ description: faker_1.default.random.words(10),
58
+ createdDateTime: "2021-10-04T22:13:50.397Z",
59
+ state: imodels_client_management_1.IModelState.Initialized,
60
+ projectId: mockITwinId,
61
+ extent: null,
62
+ _links: {
63
+ creator: {
64
+ href: "",
65
+ },
66
+ namedVersions: {
67
+ href: "",
68
+ },
69
+ changesets: {
70
+ href: "",
71
+ },
72
+ },
73
+ },
74
+ },
75
+ {
76
+ iModel: {
77
+ id: mockIModelId2,
78
+ displayName: faker_1.default.random.alpha(10),
79
+ name: faker_1.default.random.alpha(10),
80
+ description: faker_1.default.random.words(10),
81
+ createdDateTime: "2021-10-04T22:13:50.397Z",
82
+ state: imodels_client_management_1.IModelState.Initialized,
83
+ projectId: mockITwinId,
84
+ extent: null,
85
+ _links: {
86
+ creator: {
87
+ href: "",
88
+ },
89
+ namedVersions: {
90
+ href: "",
91
+ },
92
+ changesets: {
93
+ href: "",
94
+ },
95
+ },
96
+ },
97
+ },
98
+ ];
99
+ const mockProjectIModels = {
100
+ iModels: mockIModelsResponse.map((iModel) => ({
101
+ id: iModel.iModel.id,
102
+ displayName: iModel.iModel.displayName,
103
+ })),
104
+ _links: {
105
+ self: {
106
+ href: "",
107
+ },
108
+ prev: null,
109
+ next: null,
110
+ },
111
+ };
112
+ const mockReport = {
113
+ id: mockReportId,
114
+ displayName: faker_1.default.random.alpha(10),
115
+ description: faker_1.default.random.words(10),
116
+ deleted: false,
117
+ _links: {
118
+ project: {
119
+ href: "",
120
+ },
121
+ },
122
+ };
123
+ const mockReportMappingsFactory = () => {
124
+ return {
125
+ mappings: [
126
+ {
127
+ reportId: mockReportId,
128
+ mappingId: faker_1.default.datatype.uuid(),
129
+ imodelId: mockIModelId1,
130
+ _links: {
131
+ report: {
132
+ href: "",
133
+ },
134
+ mapping: {
135
+ href: "",
136
+ },
137
+ imodel: {
138
+ href: "",
139
+ },
140
+ },
141
+ },
142
+ {
143
+ reportId: mockReportId,
144
+ mappingId: faker_1.default.datatype.uuid(),
145
+ imodelId: mockIModelId2,
146
+ _links: {
147
+ report: {
148
+ href: "",
149
+ },
150
+ mapping: {
151
+ href: "",
152
+ },
153
+ imodel: {
154
+ href: "",
155
+ },
156
+ },
157
+ },
158
+ ],
159
+ _links: {
160
+ next: undefined,
161
+ self: {
162
+ href: "",
163
+ },
164
+ },
165
+ };
166
+ };
167
+ const mockMappingsFactory = (mockReportMappings) => {
168
+ const mockMappings = mockReportMappings.mappings.map((mapping) => ({
169
+ mapping: {
170
+ id: mapping.mappingId,
171
+ mappingName: faker_1.default.random.alpha(10),
172
+ description: faker_1.default.random.words(10),
173
+ extractionEnabled: false,
174
+ createdOn: "",
175
+ createdBy: "",
176
+ modifiedOn: "",
177
+ modifiedBy: "",
178
+ _links: {
179
+ imodel: {
180
+ // Tie the mapping to to the iModel Id
181
+ href: mapping.imodelId,
182
+ },
183
+ },
184
+ },
185
+ }));
186
+ const iModelHandlers = mockMappings.map((mapping) => {
187
+ var _a, _b, _c, _d, _e;
188
+ return msw_1.rest.get(`${ReportsConfigUiProvider_1.REPORTS_CONFIG_BASE_URL}/insights/reporting/datasources/imodels/${(_d = (_c = (_b = (_a = mapping.mapping) === null || _a === void 0 ? void 0 : _a._links) === null || _b === void 0 ? void 0 : _b.imodel) === null || _c === void 0 ? void 0 : _c.href) !== null && _d !== void 0 ? _d : ""}/mappings/${(_e = mapping.mapping) === null || _e === void 0 ? void 0 : _e.id}`, async (_req, res, ctx) => {
189
+ return res(ctx.delay(), ctx.status(200), ctx.json(mapping));
190
+ });
191
+ });
192
+ return [mockMappings, iModelHandlers];
193
+ };
194
+ const connectionMock = moq.Mock.ofType();
195
+ const selectionManagerMock = moq.Mock.ofType();
196
+ const selectionScopesManagerMock = moq.Mock.ofType();
197
+ jest.mock("@itwin/appui-react", () => ({
198
+ ...jest.requireActual("@itwin/appui-react"),
199
+ useActiveIModelConnection: () => connectionMock.object,
200
+ }));
201
+ const server = node_1.setupServer();
202
+ beforeAll(async () => {
203
+ // This is required by the i18n module within iTwin.js
204
+ global.XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest; // eslint-disable-line @typescript-eslint/no-var-requires
205
+ await core_frontend_1.NoRenderApp.startup();
206
+ await presentation_frontend_1.Presentation.initialize();
207
+ const selectionSet = moq.Mock.ofType();
208
+ const onChanged = moq.Mock.ofType();
209
+ selectionSet.setup((x) => x.elements).returns(() => new Set([]));
210
+ selectionSet.setup((x) => x.onChanged).returns(() => onChanged.object);
211
+ connectionMock
212
+ .setup((x) => x.selectionSet)
213
+ .returns(() => selectionSet.object);
214
+ connectionMock.setup((x) => x.iModelId).returns(() => mockIModelId1);
215
+ connectionMock.setup((x) => x.iTwinId).returns(() => mockITwinId);
216
+ selectionManagerMock
217
+ .setup((x) => x.selectionChange)
218
+ .returns(() => new presentation_frontend_1.SelectionChangeEvent());
219
+ selectionScopesManagerMock
220
+ .setup(async (x) => x.getSelectionScopes(connectionMock.object))
221
+ .returns(async () => []);
222
+ selectionManagerMock
223
+ .setup((x) => x.scopes)
224
+ .returns(() => selectionScopesManagerMock.object);
225
+ presentation_frontend_1.Presentation.setSelectionManager(selectionManagerMock.object);
226
+ await test_utils_1.TestUtils.initializeUiFramework(connectionMock.object);
227
+ await ReportsConfigWidget_1.ReportsConfigWidget.initialize();
228
+ server.listen();
229
+ });
230
+ afterAll(() => {
231
+ test_utils_1.TestUtils.terminateUiFramework();
232
+ server.close();
233
+ });
234
+ afterEach(() => {
235
+ server.resetHandlers();
236
+ });
237
+ describe("Report Mappings View", () => {
238
+ it("shows all report mappings", async () => {
239
+ var _a, _b, _c, _d, _e;
240
+ const mockReportMappings = mockReportMappingsFactory();
241
+ const [mockMappings, iModelHandlers] = mockMappingsFactory(mockReportMappings);
242
+ server.use(msw_1.rest.get(`${ReportsConfigUiProvider_1.REPORTS_CONFIG_BASE_URL}/insights/reporting/reports/${mockReportId}/datasources/imodelMappings`, async (_req, res, ctx) => {
243
+ return res(ctx.delay(), ctx.status(200), ctx.json(mockReportMappings));
244
+ }), msw_1.rest.get(`${imodels_client_management_1.Constants.api.baseUrl}/${mockIModelId1}`, async (_req, res, ctx) => {
245
+ return res(ctx.delay(), ctx.status(200), ctx.json(mockIModelsResponse[0]));
246
+ }), msw_1.rest.get(`${imodels_client_management_1.Constants.api.baseUrl}/${mockIModelId2}`, async (_req, res, ctx) => {
247
+ return res(ctx.delay(), ctx.status(200), ctx.json(mockIModelsResponse[1]));
248
+ }), ...iModelHandlers);
249
+ test_utils_1.render(react_1.default.createElement(ReportMappings_1.ReportMappings, { report: mockReport, goBack: jest.fn() }));
250
+ await test_utils_1.waitForElementToBeRemoved(() => test_utils_1.screen.getByText(/loading/i));
251
+ const horizontalTiles = test_utils_1.screen.getAllByTestId("horizontal-tile");
252
+ expect(horizontalTiles).toHaveLength(mockMappings.length);
253
+ for (const [index, horizontalTile] of horizontalTiles.entries()) {
254
+ const reportMappingTile = test_utils_1.within(horizontalTile);
255
+ const mockiModel = mockIModelsResponse.find((iModel) => { var _a, _b, _c; return iModel.iModel.id === ((_c = (_b = (_a = mockMappings[index].mapping) === null || _a === void 0 ? void 0 : _a._links) === null || _b === void 0 ? void 0 : _b.imodel) === null || _c === void 0 ? void 0 : _c.href); });
256
+ expect(reportMappingTile.getByText((_b = (_a = mockMappings[index].mapping) === null || _a === void 0 ? void 0 : _a.mappingName) !== null && _b !== void 0 ? _b : "")).toBeInTheDocument();
257
+ expect(reportMappingTile.getByTitle((_d = (_c = mockMappings[index].mapping) === null || _c === void 0 ? void 0 : _c.description) !== null && _d !== void 0 ? _d : "")).toBeInTheDocument();
258
+ expect(reportMappingTile.getByText((_e = mockiModel === null || mockiModel === void 0 ? void 0 : mockiModel.iModel.displayName) !== null && _e !== void 0 ? _e : "")).toBeInTheDocument();
259
+ }
260
+ });
261
+ it("search for a report mapping", async () => {
262
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
263
+ const mockReportMappings = mockReportMappingsFactory();
264
+ const [mockMappings, iModelHandlers] = mockMappingsFactory(mockReportMappings);
265
+ server.use(msw_1.rest.get(`${ReportsConfigUiProvider_1.REPORTS_CONFIG_BASE_URL}/insights/reporting/reports/${mockReportId}/datasources/imodelMappings`, async (_req, res, ctx) => {
266
+ return res(ctx.delay(), ctx.status(200), ctx.json(mockReportMappings));
267
+ }), msw_1.rest.get(`${imodels_client_management_1.Constants.api.baseUrl}/${mockIModelId1}`, async (_req, res, ctx) => {
268
+ return res(ctx.delay(), ctx.status(200), ctx.json(mockIModelsResponse[0]));
269
+ }), msw_1.rest.get(`${imodels_client_management_1.Constants.api.baseUrl}/${mockIModelId2}`, async (_req, res, ctx) => {
270
+ return res(ctx.delay(), ctx.status(200), ctx.json(mockIModelsResponse[1]));
271
+ }), ...iModelHandlers);
272
+ const { user } = test_utils_1.render(react_1.default.createElement(ReportMappings_1.ReportMappings, { report: mockReport, goBack: jest.fn() }));
273
+ await test_utils_1.waitForElementToBeRemoved(() => test_utils_1.screen.getByText(/loading/i));
274
+ const searchButton = test_utils_1.within(test_utils_1.screen.getByTestId(/search-bar/i)).getByRole("button");
275
+ await user.click(searchButton);
276
+ const searchInput = test_utils_1.screen.getByRole("textbox", {
277
+ name: /search\-textbox/i,
278
+ });
279
+ // Be an exact match on display name.
280
+ await user.type(searchInput, (_b = (_a = mockMappings[0].mapping) === null || _a === void 0 ? void 0 : _a.mappingName) !== null && _b !== void 0 ? _b : "");
281
+ expect(test_utils_1.screen.getAllByTestId("horizontal-tile")).toHaveLength(1);
282
+ expect(test_utils_1.screen.getByText((_d = (_c = mockMappings[0].mapping) === null || _c === void 0 ? void 0 : _c.mappingName) !== null && _d !== void 0 ? _d : "")).toBeInTheDocument();
283
+ // Be an exact match on description.
284
+ await user.clear(searchInput);
285
+ await user.type(searchInput, (_f = (_e = mockMappings[0].mapping) === null || _e === void 0 ? void 0 : _e.description) !== null && _f !== void 0 ? _f : "");
286
+ expect(test_utils_1.screen.getAllByTestId("horizontal-tile")).toHaveLength(1);
287
+ expect(test_utils_1.screen.getByTitle((_h = (_g = mockMappings[0].mapping) === null || _g === void 0 ? void 0 : _g.description) !== null && _h !== void 0 ? _h : "")).toBeInTheDocument();
288
+ // Be an exact match on iModel Name.
289
+ const iModel = mockIModelsResponse.find((mockIModel) => { var _a, _b, _c; return mockIModel.iModel.id === ((_c = (_b = (_a = mockMappings[0].mapping) === null || _a === void 0 ? void 0 : _a._links) === null || _b === void 0 ? void 0 : _b.imodel) === null || _c === void 0 ? void 0 : _c.href); });
290
+ await user.clear(searchInput);
291
+ await user.type(searchInput, (_j = iModel === null || iModel === void 0 ? void 0 : iModel.iModel.displayName) !== null && _j !== void 0 ? _j : "");
292
+ expect(test_utils_1.screen.getAllByTestId("horizontal-tile")).toHaveLength(1);
293
+ expect(test_utils_1.screen.getByText((_k = iModel === null || iModel === void 0 ? void 0 : iModel.iModel.displayName) !== null && _k !== void 0 ? _k : "")).toBeInTheDocument();
294
+ });
295
+ it("remove a report mapping", async () => {
296
+ var _a;
297
+ const mockReportMappings = mockReportMappingsFactory();
298
+ const [_, iModelHandlers] = mockMappingsFactory(mockReportMappings);
299
+ const mockReportMappingsOriginalSize = mockReportMappings.mappings.length;
300
+ server.use(msw_1.rest.get(`${ReportsConfigUiProvider_1.REPORTS_CONFIG_BASE_URL}/insights/reporting/reports/${mockReportId}/datasources/imodelMappings`, async (_req, res, ctx) => {
301
+ return res(ctx.delay(), ctx.status(200), ctx.json(mockReportMappings));
302
+ }), msw_1.rest.get(`${imodels_client_management_1.Constants.api.baseUrl}/${mockIModelId1}`, async (_req, res, ctx) => {
303
+ return res(ctx.delay(), ctx.status(200), ctx.json(mockIModelsResponse[0]));
304
+ }), msw_1.rest.get(`${imodels_client_management_1.Constants.api.baseUrl}/${mockIModelId2}`, async (_req, res, ctx) => {
305
+ return res(ctx.delay(), ctx.status(200), ctx.json(mockIModelsResponse[1]));
306
+ }), ...iModelHandlers, msw_1.rest.delete(`${ReportsConfigUiProvider_1.REPORTS_CONFIG_BASE_URL}/insights/reporting/reports/${mockReportId}/datasources/imodelMappings/${(_a = mockReportMappings.mappings[0].mappingId) !== null && _a !== void 0 ? _a : ""}`, async (_req, res, ctx) => {
307
+ mockReportMappings.mappings = mockReportMappings.mappings.filter((mapping) => {
308
+ var _a;
309
+ return (_a = mapping.mappingId !== mockReportMappings.mappings[0].mappingId) !== null && _a !== void 0 ? _a : "";
310
+ });
311
+ return res(ctx.delay(100), ctx.status(204));
312
+ }));
313
+ const { user } = test_utils_1.render(react_1.default.createElement(ReportMappings_1.ReportMappings, { report: mockReport, goBack: jest.fn() }));
314
+ await test_utils_1.waitForElementToBeRemoved(() => test_utils_1.screen.getByText(/loading/i));
315
+ const firstMenuDropdown = test_utils_1.within(test_utils_1.screen.getAllByTestId(/tile-action-button/i)[0]).getByRole("button");
316
+ await user.click(firstMenuDropdown);
317
+ const removeButton = test_utils_1.screen.getByRole("menuitem", { name: /remove/i });
318
+ await user.click(removeButton);
319
+ // Delete modal dialog should appear
320
+ expect(test_utils_1.screen.getByRole("dialog")).toBeInTheDocument();
321
+ const deleteButton = test_utils_1.screen.getByRole("button", {
322
+ name: /delete/i,
323
+ });
324
+ await user.click(deleteButton);
325
+ await test_utils_1.waitForElementToBeRemoved(() => test_utils_1.screen.getByTestId(/rcw-loading-delete/i));
326
+ await test_utils_1.waitForElementToBeRemoved(() => test_utils_1.screen.getByRole("dialog"));
327
+ // Should be one less mapping
328
+ expect(test_utils_1.screen.getAllByTestId("horizontal-tile")).toHaveLength(mockReportMappingsOriginalSize - 1);
329
+ });
330
+ it("add mapping", async () => {
331
+ var _a, _b, _c, _d;
332
+ const mockReportMappings = mockReportMappingsFactory();
333
+ const [mockMappings, iModelHandlers] = mockMappingsFactory(mockReportMappings);
334
+ // Adding an extra unmapped mapping.
335
+ const extraMappingId = faker_1.default.datatype.uuid();
336
+ const extraMappingName = faker_1.default.random.alpha(10);
337
+ mockMappings.push({
338
+ mapping: {
339
+ id: extraMappingId,
340
+ mappingName: extraMappingName,
341
+ description: faker_1.default.random.words(10),
342
+ extractionEnabled: false,
343
+ createdOn: "",
344
+ createdBy: "",
345
+ modifiedOn: "",
346
+ modifiedBy: "",
347
+ _links: {
348
+ imodel: {
349
+ href: "",
350
+ },
351
+ },
352
+ },
353
+ });
354
+ const mockMappingsResponse = {
355
+ // Type guarding
356
+ mappings: mockMappings
357
+ .map((mapping) => mapping.mapping)
358
+ .filter((mapping) => !!mapping),
359
+ _links: {
360
+ next: undefined,
361
+ self: {
362
+ href: "",
363
+ },
364
+ },
365
+ };
366
+ server.use(msw_1.rest.get(`${ReportsConfigUiProvider_1.REPORTS_CONFIG_BASE_URL}/insights/reporting/reports/${mockReportId}/datasources/imodelMappings`, async (_req, res, ctx) => {
367
+ return res(ctx.delay(), ctx.status(200), ctx.json(mockReportMappings));
368
+ }), msw_1.rest.get(`${imodels_client_management_1.Constants.api.baseUrl}`, async (_req, res, ctx) => {
369
+ return res(ctx.delay(), ctx.status(200), ctx.json(mockProjectIModels));
370
+ }), msw_1.rest.get(`${imodels_client_management_1.Constants.api.baseUrl}/${mockIModelId1}`, async (_req, res, ctx) => {
371
+ return res(ctx.delay(), ctx.status(200), ctx.json(mockIModelsResponse[0]));
372
+ }), msw_1.rest.get(`${imodels_client_management_1.Constants.api.baseUrl}/${mockIModelId2}`, async (_req, res, ctx) => {
373
+ return res(ctx.delay(), ctx.status(200), ctx.json(mockIModelsResponse[1]));
374
+ }), msw_1.rest.get(`${ReportsConfigUiProvider_1.REPORTS_CONFIG_BASE_URL}/insights/reporting/datasources/imodels/${mockProjectIModels.iModels[0].id}/mappings`, async (_req, res, ctx) => {
375
+ return res(ctx.delay(), ctx.status(200), ctx.json(mockMappingsResponse));
376
+ }), msw_1.rest.post(`${ReportsConfigUiProvider_1.REPORTS_CONFIG_BASE_URL}/insights/reporting/reports/${mockReportId}/datasources/imodelMappings`, async (_req, res, ctx) => {
377
+ return res(ctx.delay(), ctx.status(200), ctx.json(mockReportMappings));
378
+ }), ...iModelHandlers);
379
+ const { user } = test_utils_1.render(react_1.default.createElement(ReportMappings_1.ReportMappings, { report: mockReport, goBack: jest.fn() }));
380
+ await test_utils_1.waitForElementToBeRemoved(() => test_utils_1.screen.getByText(/loading/i));
381
+ const addMappingButton = test_utils_1.screen.getByRole("button", {
382
+ name: /addmapping/i,
383
+ });
384
+ await user.click(addMappingButton);
385
+ await test_utils_1.waitForElementToBeRemoved(() => test_utils_1.screen.getByTestId(/rcw-action-loading-spinner/i));
386
+ // Add modal dialog should appear
387
+ const modal = test_utils_1.screen.getByRole("dialog");
388
+ expect(test_utils_1.screen.getByRole("dialog")).toBeInTheDocument();
389
+ const withinModal = test_utils_1.within(modal);
390
+ expect(withinModal.getByText(/addmappings/i)).toBeInTheDocument();
391
+ const addButton = withinModal.getByRole("button", {
392
+ name: /add/i,
393
+ });
394
+ // Add button should be disabled
395
+ expect(addButton).toBeDisabled();
396
+ // Already mapped mappings are disabled
397
+ for (let i = 0; i < mockMappings.length - 1; i++) {
398
+ const row = test_utils_1.screen.getByRole("row", {
399
+ name: new RegExp(`toggle row selected ${(_a = mockMappings[i].mapping) === null || _a === void 0 ? void 0 : _a.mappingName} ${(_b = mockMappings[i].mapping) === null || _b === void 0 ? void 0 : _b.description}`, "i"),
400
+ });
401
+ const checkbox = test_utils_1.within(row).getByRole("checkbox", {
402
+ name: /toggle row selected/i,
403
+ });
404
+ expect(checkbox).toBeDisabled();
405
+ }
406
+ // Click on checkbox on new mapping
407
+ const unmappedRow = test_utils_1.screen.getByRole("row", {
408
+ name: new RegExp(`toggle row selected ${(_c = mockMappings[mockMappings.length - 1].mapping) === null || _c === void 0 ? void 0 : _c.mappingName} ${(_d = mockMappings[mockMappings.length - 1].mapping) === null || _d === void 0 ? void 0 : _d.description}`, "i"),
409
+ });
410
+ const enabledCheckbox = test_utils_1.within(unmappedRow).getByRole("checkbox", {
411
+ name: /toggle row selected/i,
412
+ });
413
+ await user.click(enabledCheckbox);
414
+ await user.click(addButton);
415
+ // Modal should go away
416
+ await test_utils_1.waitForElementToBeRemoved(() => test_utils_1.screen.getByTestId(/rcw-action-loading-spinner/i));
417
+ await test_utils_1.waitForElementToBeRemoved(() => test_utils_1.screen.getByRole("dialog"));
418
+ });
419
+ it("odata feed url", async () => {
420
+ const mockReportMappings = mockReportMappingsFactory();
421
+ const [_, iModelHandlers] = mockMappingsFactory(mockReportMappings);
422
+ server.use(msw_1.rest.get(`${ReportsConfigUiProvider_1.REPORTS_CONFIG_BASE_URL}/insights/reporting/reports/${mockReportId}/datasources/imodelMappings`, async (_req, res, ctx) => {
423
+ return res(ctx.delay(), ctx.status(200), ctx.json(mockReportMappings));
424
+ }), msw_1.rest.get(`${imodels_client_management_1.Constants.api.baseUrl}/${mockIModelId1}`, async (_req, res, ctx) => {
425
+ return res(ctx.delay(), ctx.status(200), ctx.json(mockIModelsResponse[0]));
426
+ }), msw_1.rest.get(`${imodels_client_management_1.Constants.api.baseUrl}/${mockIModelId2}`, async (_req, res, ctx) => {
427
+ return res(ctx.delay(), ctx.status(200), ctx.json(mockIModelsResponse[1]));
428
+ }), ...iModelHandlers);
429
+ const { user } = test_utils_1.render(react_1.default.createElement(ReportMappings_1.ReportMappings, { report: mockReport, goBack: jest.fn() }));
430
+ await test_utils_1.waitForElementToBeRemoved(() => test_utils_1.screen.getByText(/loading/i));
431
+ const urlTextbox = test_utils_1.screen.getByRole("textbox", {
432
+ name: /odatafeedurl/i,
433
+ });
434
+ expect(urlTextbox).toBeInTheDocument();
435
+ expect(test_utils_1.screen.getByDisplayValue(`https://api.bentley.com/insights/reporting/odata/${mockReport.id}`)).toBeInTheDocument();
436
+ const copyButton = test_utils_1.screen.getByRole("button", {
437
+ name: /copy/i,
438
+ });
439
+ await user.click(copyButton);
440
+ expect(test_utils_1.screen.getByText(/copiedtoclipboard/i)).toBeInTheDocument();
441
+ });
442
+ it("full extraction", async () => {
443
+ const mockReportMappings = mockReportMappingsFactory();
444
+ const [_, iModelHandlers] = mockMappingsFactory(mockReportMappings);
445
+ const delay = Extraction_1.REFRESH_DELAY;
446
+ // Faking timers currently makes all promise based queries from RTL become unpredictable.
447
+ // https://github.com/testing-library/dom-testing-library/issues/988
448
+ // Should come back to this later.
449
+ // Consequently, this test will be a bit slower.
450
+ // jest.useFakeTimers()
451
+ Element.prototype.scrollIntoView = jest.fn();
452
+ const mockIModel = mockIModelsResponse[0].iModel;
453
+ const mockRunId = faker_1.default.datatype.uuid();
454
+ const mockExtractionResponse = {
455
+ run: {
456
+ id: mockRunId,
457
+ _links: {
458
+ status: {
459
+ href: "",
460
+ },
461
+ },
462
+ },
463
+ };
464
+ let mockStatusResponse = {
465
+ status: {
466
+ state: "Queued",
467
+ reason: "",
468
+ },
469
+ };
470
+ server.use(msw_1.rest.get(`${ReportsConfigUiProvider_1.REPORTS_CONFIG_BASE_URL}/insights/reporting/reports/${mockReportId}/datasources/imodelMappings`, async (_req, res, ctx) => {
471
+ return res(ctx.delay(), ctx.status(200), ctx.json(mockReportMappings));
472
+ }), msw_1.rest.get(`${imodels_client_management_1.Constants.api.baseUrl}/${mockIModelId1}`, async (_req, res, ctx) => {
473
+ return res(ctx.delay(), ctx.status(200), ctx.json(mockIModelsResponse[0]));
474
+ }), msw_1.rest.get(`${imodels_client_management_1.Constants.api.baseUrl}/${mockIModelId2}`, async (_req, res, ctx) => {
475
+ return res(ctx.delay(), ctx.status(200), ctx.json(mockIModelsResponse[1]));
476
+ }), ...iModelHandlers, msw_1.rest.post(`${ReportsConfigUiProvider_1.REPORTS_CONFIG_BASE_URL}/insights/reporting/datasources/imodels/${mockIModel.id}/extraction/run`, async (_req, res, ctx) => {
477
+ return res(ctx.delay(), ctx.status(200), ctx.json(mockExtractionResponse));
478
+ }), msw_1.rest.get(`${ReportsConfigUiProvider_1.REPORTS_CONFIG_BASE_URL}/insights/reporting/datasources/extraction/status/${mockRunId}`, async (_req, res, ctx) => {
479
+ return res(ctx.delay(), ctx.status(200), ctx.json(mockStatusResponse));
480
+ }));
481
+ test_utils_1.render(react_1.default.createElement(ReportMappings_1.ReportMappings, { report: mockReport, goBack: jest.fn() }));
482
+ // https://github.com/testing-library/user-event/issues/833
483
+ const user = user_event_1.default.setup({ delay: null });
484
+ await test_utils_1.waitForElementToBeRemoved(() => test_utils_1.screen.getByText(/loading/i));
485
+ const comboBox = test_utils_1.screen.getByRole("combobox", {
486
+ name: /updatedataset/i,
487
+ });
488
+ await user.type(comboBox, mockIModel.displayName);
489
+ const option = test_utils_1.screen.getByRole("option", {
490
+ name: mockIModel.displayName,
491
+ });
492
+ await user.click(option);
493
+ // Combobox should have correct status
494
+ const extractionComponent = test_utils_1.screen.getByTestId("extraction-combo-box");
495
+ expect(test_utils_1.within(extractionComponent).getByDisplayValue(mockIModel.displayName)).toBeInTheDocument();
496
+ // Should be two in the document. One in the status and the other in the list.
497
+ // TODO Assert that it is in the correct HorizontalTile
498
+ expect(test_utils_1.screen.getAllByTitle(/starting/i)).toHaveLength(2);
499
+ const loadingStates = await test_utils_1.screen.findAllByTitle(/loading/i);
500
+ expect(loadingStates).toHaveLength(2);
501
+ // act(() => {
502
+ // jest.advanceTimersByTime(2000)
503
+ // });
504
+ const queuedStates = await test_utils_1.screen.findAllByTitle(/queued/i, undefined, {
505
+ timeout: delay,
506
+ });
507
+ expect(queuedStates).toHaveLength(2);
508
+ mockStatusResponse = {
509
+ status: {
510
+ state: "Running",
511
+ reason: "",
512
+ },
513
+ };
514
+ const runningStates = await test_utils_1.screen.findAllByTitle(/running/i, undefined, {
515
+ timeout: delay,
516
+ });
517
+ expect(runningStates).toHaveLength(2);
518
+ mockStatusResponse = {
519
+ status: {
520
+ state: "Succeeded",
521
+ reason: "",
522
+ },
523
+ };
524
+ const succeededStates = await test_utils_1.screen.findAllByTitle(/success/i, undefined, {
525
+ timeout: delay,
526
+ });
527
+ expect(succeededStates).toHaveLength(2);
528
+ });
529
+ });
530
+ //# sourceMappingURL=ReportMappings.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ReportMappings.test.js","sourceRoot":"","sources":["../../../src/test/ReportMappings.test.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F,kDAA0B;AAC1B,4DAAoC;AACpC,qCAAmC;AAMnC,wDAAmD;AACnD,gEAA6D;AAC7D,mCAAuC;AACvC,6CAMsB;AACtB,6EAAoD;AACpD,6CAA+B;AAE/B,6BAA2B;AAS3B,wEAAqE;AACrE,gFAA0E;AAC1E,+EAA4E;AAC5E,gEAAgE;AAKhE,wEAGsC;AAGtC,0BAA0B;AAC1B,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;AAEvB,MAAM,WAAW,GAAG,eAAK,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;AAC1C,sCAAsC;AACtC,MAAM,aAAa,GAAG,eAAK,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;AAC5C,MAAM,aAAa,GAAG,eAAK,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;AAE5C,MAAM,YAAY,GAAG,eAAK,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;AAE3C,MAAM,mBAAmB,GAAG;IAC1B;QACE,MAAM,EAAE;YACN,EAAE,E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AAY,CAAC,CAAC,CAAC,CAAC;QAErC,kBAAkB,GAAG;YACnB,MAAM,EAAE;gBACN,KAAK,EAAE,SAAS;gBAChB,MAAM,EAAE,EAAE;aACX;SACF,CAAC;QAEF,MAAM,aAAa,GAAG,MAAM,mBAAM,CAAC,cAAc,CAAC,UAAU,EAAE,SAAS,EAAE;YACvE,OAAO,EAAE,KAAK;SACf,CAAC,CAAC;QACH,MAAM,CAAC,aAAa,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;QAEtC,kBAAkB,GAAG;YACnB,MAAM,EAAE;gBACN,KAAK,EAAE,WAAW;gBAClB,MAAM,EAAE,EAAE;aACX;SACF,CAAC;QAEF,MAAM,eAAe,GAAG,MAAM,mBAAM,CAAC,cAAc,CAAC,UAAU,EAAE,SAAS,EAAE;YACzE,OAAO,EAAE,KAAK;SACf,CAAC,CAAC;QACH,MAAM,CAAC,eAAe,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IAC1C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport React from \"react\";\nimport faker from \"@faker-js/faker\";\nimport \"@testing-library/jest-dom\";\nimport type {\n IModelConnection,\n SelectionSet,\n SelectionSetEvent,\n} from \"@itwin/core-frontend\";\nimport { NoRenderApp } from \"@itwin/core-frontend\";\nimport { ReportsConfigWidget } from \"../ReportsConfigWidget\";\nimport { setupServer } from \"msw/node\";\nimport {\n render,\n screen,\n TestUtils,\n waitForElementToBeRemoved,\n within,\n} from \"./test-utils\";\nimport userEvent from \"@testing-library/user-event\";\nimport * as moq from \"typemoq\";\nimport type { RequestHandler } from \"msw\";\nimport { rest } from \"msw\";\nimport type {\n ExtractionStatus,\n Mapping,\n MappingCollection,\n MappingSingle,\n Report,\n ReportMappingCollection,\n} from \"@itwin/insights-client\";\nimport { ReportMappings } from \"../widget/components/ReportMappings\";\nimport { Constants, IModelState } from \"@itwin/imodels-client-management\";\nimport { REPORTS_CONFIG_BASE_URL } from \"../widget/ReportsConfigUiProvider\";\nimport { REFRESH_DELAY } from \"../widget/components/Extraction\";\nimport type {\n SelectionManager,\n SelectionScopesManager,\n} from \"@itwin/presentation-frontend\";\nimport {\n Presentation,\n SelectionChangeEvent,\n} from \"@itwin/presentation-frontend\";\nimport type { BeEvent } from \"@itwin/core-bentley\";\n\n// For the extraction test\njest.setTimeout(20000);\n\nconst mockITwinId = faker.datatype.uuid();\n// Lets work with two iModels for now.\nconst mockIModelId1 = faker.datatype.uuid();\nconst mockIModelId2 = faker.datatype.uuid();\n\nconst mockReportId = faker.datatype.uuid();\n\nconst mockIModelsResponse = [\n {\n iModel: {\n id: mockIModelId1,\n displayName: faker.random.alpha(10),\n name: faker.random.alpha(10),\n description: faker.random.words(10),\n createdDateTime: \"2021-10-04T22:13:50.397Z\",\n state: IModelState.Initialized,\n projectId: mockITwinId,\n extent: null,\n _links: {\n creator: {\n href: \"\",\n },\n namedVersions: {\n href: \"\",\n },\n changesets: {\n href: \"\",\n },\n },\n },\n },\n {\n iModel: {\n id: mockIModelId2,\n displayName: faker.random.alpha(10),\n name: faker.random.alpha(10),\n description: faker.random.words(10),\n createdDateTime: \"2021-10-04T22:13:50.397Z\",\n state: IModelState.Initialized,\n projectId: mockITwinId,\n extent: null,\n _links: {\n creator: {\n href: \"\",\n },\n namedVersions: {\n href: \"\",\n },\n changesets: {\n href: \"\",\n },\n },\n },\n },\n];\n\nconst mockProjectIModels = {\n iModels: mockIModelsResponse.map((iModel) => ({\n id: iModel.iModel.id,\n displayName: iModel.iModel.displayName,\n })),\n _links: {\n self: {\n href: \"\",\n },\n prev: null,\n next: null,\n },\n};\n\nconst mockReport: Report = {\n id: mockReportId,\n displayName: faker.random.alpha(10),\n description: faker.random.words(10),\n deleted: false,\n _links: {\n project: {\n href: \"\",\n },\n },\n};\n\nconst mockReportMappingsFactory = (): ReportMappingCollection => {\n return {\n mappings: [\n {\n reportId: mockReportId,\n mappingId: faker.datatype.uuid(),\n imodelId: mockIModelId1,\n _links: {\n report: {\n href: \"\",\n },\n mapping: {\n href: \"\",\n },\n imodel: {\n href: \"\",\n },\n },\n },\n {\n reportId: mockReportId,\n mappingId: faker.datatype.uuid(),\n imodelId: mockIModelId2,\n _links: {\n report: {\n href: \"\",\n },\n mapping: {\n href: \"\",\n },\n imodel: {\n href: \"\",\n },\n },\n },\n ],\n _links: {\n next: undefined,\n self: {\n href: \"\",\n },\n },\n };\n};\n\nconst mockMappingsFactory = (\n mockReportMappings: ReportMappingCollection\n): [MappingSingle[], RequestHandler[]] => {\n const mockMappings: MappingSingle[] = mockReportMappings.mappings!.map(\n (mapping) => ({\n mapping: {\n id: mapping.mappingId,\n mappingName: faker.random.alpha(10),\n description: faker.random.words(10),\n extractionEnabled: false,\n createdOn: \"\",\n createdBy: \"\",\n modifiedOn: \"\",\n modifiedBy: \"\",\n _links: {\n imodel: {\n // Tie the mapping to to the iModel Id\n href: mapping.imodelId,\n },\n },\n },\n })\n );\n\n const iModelHandlers: RequestHandler[] = mockMappings.map((mapping) =>\n rest.get(\n `${REPORTS_CONFIG_BASE_URL}/insights/reporting/datasources/imodels/${\n mapping.mapping?._links?.imodel?.href ?? \"\"\n }/mappings/${mapping.mapping?.id}`,\n async (_req, res, ctx) => {\n return res(ctx.delay(), ctx.status(200), ctx.json(mapping));\n }\n )\n );\n\n return [mockMappings, iModelHandlers];\n};\n\nconst connectionMock = moq.Mock.ofType<IModelConnection>();\nconst selectionManagerMock = moq.Mock.ofType<SelectionManager>();\nconst selectionScopesManagerMock = moq.Mock.ofType<SelectionScopesManager>();\n\njest.mock(\"@itwin/appui-react\", () => ({\n ...jest.requireActual(\"@itwin/appui-react\"),\n useActiveIModelConnection: () => connectionMock.object,\n}));\n\nconst server = setupServer();\n\nbeforeAll(async () => {\n // This is required by the i18n module within iTwin.js\n (global as any).XMLHttpRequest = require(\"xmlhttprequest\").XMLHttpRequest; // eslint-disable-line @typescript-eslint/no-var-requires\n await NoRenderApp.startup();\n await Presentation.initialize();\n const selectionSet = moq.Mock.ofType<SelectionSet>();\n const onChanged = moq.Mock.ofType<BeEvent<(ev: SelectionSetEvent) => void>>();\n selectionSet.setup((x) => x.elements).returns(() => new Set([]));\n selectionSet.setup((x) => x.onChanged).returns(() => onChanged.object);\n connectionMock\n .setup((x) => x.selectionSet)\n .returns(() => selectionSet.object);\n connectionMock.setup((x) => x.iModelId).returns(() => mockIModelId1);\n connectionMock.setup((x) => x.iTwinId).returns(() => mockITwinId);\n\n selectionManagerMock\n .setup((x) => x.selectionChange)\n .returns(() => new SelectionChangeEvent());\n\n selectionScopesManagerMock\n .setup(async (x) => x.getSelectionScopes(connectionMock.object))\n .returns(async () => []);\n selectionManagerMock\n .setup((x) => x.scopes)\n .returns(() => selectionScopesManagerMock.object);\n\n Presentation.setSelectionManager(selectionManagerMock.object);\n await TestUtils.initializeUiFramework(connectionMock.object);\n await ReportsConfigWidget.initialize();\n server.listen();\n});\n\nafterAll(() => {\n TestUtils.terminateUiFramework();\n server.close();\n});\n\nafterEach(() => {\n server.resetHandlers();\n});\n\ndescribe(\"Report Mappings View\", () => {\n it(\"shows all report mappings\", async () => {\n const mockReportMappings = mockReportMappingsFactory();\n const [mockMappings, iModelHandlers] =\n mockMappingsFactory(mockReportMappings);\n\n server.use(\n rest.get(\n `${REPORTS_CONFIG_BASE_URL}/insights/reporting/reports/${mockReportId}/datasources/imodelMappings`,\n async (_req, res, ctx) => {\n return res(\n ctx.delay(),\n ctx.status(200),\n ctx.json(mockReportMappings)\n );\n }\n ),\n rest.get(\n `${Constants.api.baseUrl}/${mockIModelId1}`,\n async (_req, res, ctx) => {\n return res(\n ctx.delay(),\n ctx.status(200),\n ctx.json(mockIModelsResponse[0])\n );\n }\n ),\n rest.get(\n `${Constants.api.baseUrl}/${mockIModelId2}`,\n async (_req, res, ctx) => {\n return res(\n ctx.delay(),\n ctx.status(200),\n ctx.json(mockIModelsResponse[1])\n );\n }\n ),\n ...iModelHandlers\n );\n\n render(<ReportMappings report={mockReport} goBack={jest.fn()} />);\n\n await waitForElementToBeRemoved(() => screen.getByText(/loading/i));\n\n const horizontalTiles = screen.getAllByTestId(\"horizontal-tile\");\n\n expect(horizontalTiles).toHaveLength(mockMappings.length);\n\n for (const [index, horizontalTile] of horizontalTiles.entries()) {\n const reportMappingTile = within(horizontalTile);\n const mockiModel = mockIModelsResponse.find(\n (iModel) =>\n iModel.iModel.id === mockMappings[index].mapping?._links?.imodel?.href\n );\n expect(\n reportMappingTile.getByText(\n mockMappings[index].mapping?.mappingName ?? \"\"\n )\n ).toBeInTheDocument();\n expect(\n reportMappingTile.getByTitle(\n mockMappings[index].mapping?.description ?? \"\"\n )\n ).toBeInTheDocument();\n expect(\n reportMappingTile.getByText(mockiModel?.iModel.displayName ?? \"\")\n ).toBeInTheDocument();\n }\n });\n\n it(\"search for a report mapping\", async () => {\n const mockReportMappings = mockReportMappingsFactory();\n const [mockMappings, iModelHandlers] =\n mockMappingsFactory(mockReportMappings);\n\n server.use(\n rest.get(\n `${REPORTS_CONFIG_BASE_URL}/insights/reporting/reports/${mockReportId}/datasources/imodelMappings`,\n async (_req, res, ctx) => {\n return res(\n ctx.delay(),\n ctx.status(200),\n ctx.json(mockReportMappings)\n );\n }\n ),\n rest.get(\n `${Constants.api.baseUrl}/${mockIModelId1}`,\n async (_req, res, ctx) => {\n return res(\n ctx.delay(),\n ctx.status(200),\n ctx.json(mockIModelsResponse[0])\n );\n }\n ),\n rest.get(\n `${Constants.api.baseUrl}/${mockIModelId2}`,\n async (_req, res, ctx) => {\n return res(\n ctx.delay(),\n ctx.status(200),\n ctx.json(mockIModelsResponse[1])\n );\n }\n ),\n ...iModelHandlers\n );\n\n const { user } = render(\n <ReportMappings report={mockReport} goBack={jest.fn()} />\n );\n\n await waitForElementToBeRemoved(() => screen.getByText(/loading/i));\n\n const searchButton = within(screen.getByTestId(/search-bar/i)).getByRole(\n \"button\"\n );\n await user.click(searchButton);\n const searchInput = screen.getByRole(\"textbox\", {\n name: /search\\-textbox/i,\n });\n\n // Be an exact match on display name.\n await user.type(searchInput, mockMappings[0].mapping?.mappingName ?? \"\");\n expect(screen.getAllByTestId(\"horizontal-tile\")).toHaveLength(1);\n expect(\n screen.getByText(mockMappings[0].mapping?.mappingName ?? \"\")\n ).toBeInTheDocument();\n\n // Be an exact match on description.\n await user.clear(searchInput);\n await user.type(searchInput, mockMappings[0].mapping?.description ?? \"\");\n expect(screen.getAllByTestId(\"horizontal-tile\")).toHaveLength(1);\n expect(\n screen.getByTitle(mockMappings[0].mapping?.description ?? \"\")\n ).toBeInTheDocument();\n\n // Be an exact match on iModel Name.\n const iModel = mockIModelsResponse.find(\n (mockIModel) =>\n mockIModel.iModel.id === mockMappings[0].mapping?._links?.imodel?.href\n );\n await user.clear(searchInput);\n await user.type(searchInput, iModel?.iModel.displayName ?? \"\");\n expect(screen.getAllByTestId(\"horizontal-tile\")).toHaveLength(1);\n expect(\n screen.getByText(iModel?.iModel.displayName ?? \"\")\n ).toBeInTheDocument();\n });\n\n it(\"remove a report mapping\", async () => {\n const mockReportMappings = mockReportMappingsFactory();\n const [_, iModelHandlers] = mockMappingsFactory(mockReportMappings);\n\n const mockReportMappingsOriginalSize = mockReportMappings.mappings!.length;\n\n server.use(\n rest.get(\n `${REPORTS_CONFIG_BASE_URL}/insights/reporting/reports/${mockReportId}/datasources/imodelMappings`,\n async (_req, res, ctx) => {\n return res(\n ctx.delay(),\n ctx.status(200),\n ctx.json(mockReportMappings)\n );\n }\n ),\n rest.get(\n `${Constants.api.baseUrl}/${mockIModelId1}`,\n async (_req, res, ctx) => {\n return res(\n ctx.delay(),\n ctx.status(200),\n ctx.json(mockIModelsResponse[0])\n );\n }\n ),\n rest.get(\n `${Constants.api.baseUrl}/${mockIModelId2}`,\n async (_req, res, ctx) => {\n return res(\n ctx.delay(),\n ctx.status(200),\n ctx.json(mockIModelsResponse[1])\n );\n }\n ),\n ...iModelHandlers,\n rest.delete(\n `${REPORTS_CONFIG_BASE_URL}/insights/reporting/reports/${mockReportId}/datasources/imodelMappings/${\n mockReportMappings.mappings![0].mappingId ?? \"\"\n }`,\n async (_req, res, ctx) => {\n mockReportMappings.mappings = mockReportMappings.mappings!.filter(\n (mapping) =>\n mapping.mappingId !== mockReportMappings.mappings![0].mappingId ??\n \"\"\n );\n return res(ctx.delay(100), ctx.status(204));\n }\n )\n );\n\n const { user } = render(\n <ReportMappings report={mockReport} goBack={jest.fn()} />\n );\n\n await waitForElementToBeRemoved(() => screen.getByText(/loading/i));\n\n const firstMenuDropdown = within(\n screen.getAllByTestId(/tile-action-button/i)[0]\n ).getByRole(\"button\");\n await user.click(firstMenuDropdown);\n const removeButton = screen.getByRole(\"menuitem\", { name: /remove/i });\n await user.click(removeButton);\n // Delete modal dialog should appear\n expect(screen.getByRole(\"dialog\")).toBeInTheDocument();\n\n const deleteButton = screen.getByRole(\"button\", {\n name: /delete/i,\n });\n\n await user.click(deleteButton);\n\n await waitForElementToBeRemoved(() =>\n screen.getByTestId(/rcw-loading-delete/i)\n );\n await waitForElementToBeRemoved(() => screen.getByRole(\"dialog\"));\n\n // Should be one less mapping\n expect(screen.getAllByTestId(\"horizontal-tile\")).toHaveLength(\n mockReportMappingsOriginalSize - 1\n );\n });\n\n it(\"add mapping\", async () => {\n const mockReportMappings = mockReportMappingsFactory();\n const [mockMappings, iModelHandlers] =\n mockMappingsFactory(mockReportMappings);\n\n // Adding an extra unmapped mapping.\n const extraMappingId = faker.datatype.uuid();\n const extraMappingName = faker.random.alpha(10);\n\n mockMappings.push({\n mapping: {\n id: extraMappingId,\n mappingName: extraMappingName,\n description: faker.random.words(10),\n extractionEnabled: false,\n createdOn: \"\",\n createdBy: \"\",\n modifiedOn: \"\",\n modifiedBy: \"\",\n _links: {\n imodel: {\n href: \"\",\n },\n },\n },\n });\n\n const mockMappingsResponse: MappingCollection = {\n // Type guarding\n mappings: mockMappings\n .map((mapping) => mapping.mapping)\n .filter((mapping): mapping is Mapping => !!mapping),\n _links: {\n next: undefined,\n self: {\n href: \"\",\n },\n },\n };\n\n server.use(\n rest.get(\n `${REPORTS_CONFIG_BASE_URL}/insights/reporting/reports/${mockReportId}/datasources/imodelMappings`,\n async (_req, res, ctx) => {\n return res(\n ctx.delay(),\n ctx.status(200),\n ctx.json(mockReportMappings)\n );\n }\n ),\n rest.get(`${Constants.api.baseUrl}`, async (_req, res, ctx) => {\n return res(ctx.delay(), ctx.status(200), ctx.json(mockProjectIModels));\n }),\n rest.get(\n `${Constants.api.baseUrl}/${mockIModelId1}`,\n async (_req, res, ctx) => {\n return res(\n ctx.delay(),\n ctx.status(200),\n ctx.json(mockIModelsResponse[0])\n );\n }\n ),\n rest.get(\n `${Constants.api.baseUrl}/${mockIModelId2}`,\n async (_req, res, ctx) => {\n return res(\n ctx.delay(),\n ctx.status(200),\n ctx.json(mockIModelsResponse[1])\n );\n }\n ),\n rest.get(\n `${REPORTS_CONFIG_BASE_URL}/insights/reporting/datasources/imodels/${mockProjectIModels.iModels[0].id}/mappings`,\n async (_req, res, ctx) => {\n return res(\n ctx.delay(),\n ctx.status(200),\n ctx.json(mockMappingsResponse)\n );\n }\n ),\n rest.post(\n `${REPORTS_CONFIG_BASE_URL}/insights/reporting/reports/${mockReportId}/datasources/imodelMappings`,\n async (_req, res, ctx) => {\n return res(\n ctx.delay(),\n ctx.status(200),\n ctx.json(mockReportMappings)\n );\n }\n ),\n ...iModelHandlers\n );\n\n const { user } = render(\n <ReportMappings report={mockReport} goBack={jest.fn()} />\n );\n\n await waitForElementToBeRemoved(() => screen.getByText(/loading/i));\n\n const addMappingButton = screen.getByRole(\"button\", {\n name: /addmapping/i,\n });\n\n await user.click(addMappingButton);\n\n await waitForElementToBeRemoved(() =>\n screen.getByTestId(/rcw-action-loading-spinner/i)\n );\n // Add modal dialog should appear\n const modal = screen.getByRole(\"dialog\");\n expect(screen.getByRole(\"dialog\")).toBeInTheDocument();\n\n const withinModal = within(modal);\n expect(withinModal.getByText(/addmappings/i)).toBeInTheDocument();\n\n const addButton = withinModal.getByRole(\"button\", {\n name: /add/i,\n });\n // Add button should be disabled\n expect(addButton).toBeDisabled();\n\n // Already mapped mappings are disabled\n for (let i = 0; i < mockMappings.length - 1; i++) {\n const row = screen.getByRole(\"row\", {\n name: new RegExp(\n `toggle row selected ${mockMappings[i].mapping?.mappingName} ${mockMappings[i].mapping?.description}`,\n \"i\"\n ),\n });\n\n const checkbox = within(row).getByRole(\"checkbox\", {\n name: /toggle row selected/i,\n });\n expect(checkbox).toBeDisabled();\n }\n\n // Click on checkbox on new mapping\n const unmappedRow = screen.getByRole(\"row\", {\n name: new RegExp(\n `toggle row selected ${\n mockMappings[mockMappings.length - 1].mapping?.mappingName\n } ${mockMappings[mockMappings.length - 1].mapping?.description}`,\n \"i\"\n ),\n });\n\n const enabledCheckbox = within(unmappedRow).getByRole(\"checkbox\", {\n name: /toggle row selected/i,\n });\n\n await user.click(enabledCheckbox);\n\n await user.click(addButton);\n // Modal should go away\n await waitForElementToBeRemoved(() =>\n screen.getByTestId(/rcw-action-loading-spinner/i)\n );\n await waitForElementToBeRemoved(() => screen.getByRole(\"dialog\"));\n });\n\n it(\"odata feed url\", async () => {\n const mockReportMappings = mockReportMappingsFactory();\n const [_, iModelHandlers] = mockMappingsFactory(mockReportMappings);\n\n server.use(\n rest.get(\n `${REPORTS_CONFIG_BASE_URL}/insights/reporting/reports/${mockReportId}/datasources/imodelMappings`,\n async (_req, res, ctx) => {\n return res(\n ctx.delay(),\n ctx.status(200),\n ctx.json(mockReportMappings)\n );\n }\n ),\n rest.get(\n `${Constants.api.baseUrl}/${mockIModelId1}`,\n async (_req, res, ctx) => {\n return res(\n ctx.delay(),\n ctx.status(200),\n ctx.json(mockIModelsResponse[0])\n );\n }\n ),\n rest.get(\n `${Constants.api.baseUrl}/${mockIModelId2}`,\n async (_req, res, ctx) => {\n return res(\n ctx.delay(),\n ctx.status(200),\n ctx.json(mockIModelsResponse[1])\n );\n }\n ),\n ...iModelHandlers\n );\n\n const { user } = render(\n <ReportMappings report={mockReport} goBack={jest.fn()} />\n );\n\n await waitForElementToBeRemoved(() => screen.getByText(/loading/i));\n\n const urlTextbox = screen.getByRole(\"textbox\", {\n name: /odatafeedurl/i,\n });\n expect(urlTextbox).toBeInTheDocument();\n expect(\n screen.getByDisplayValue(\n `https://api.bentley.com/insights/reporting/odata/${mockReport.id}`\n )\n ).toBeInTheDocument();\n\n const copyButton = screen.getByRole(\"button\", {\n name: /copy/i,\n });\n\n await user.click(copyButton);\n expect(screen.getByText(/copiedtoclipboard/i)).toBeInTheDocument();\n });\n\n it(\"full extraction\", async () => {\n const mockReportMappings = mockReportMappingsFactory();\n const [_, iModelHandlers] = mockMappingsFactory(mockReportMappings);\n\n const delay = REFRESH_DELAY;\n\n // Faking timers currently makes all promise based queries from RTL become unpredictable.\n // https://github.com/testing-library/dom-testing-library/issues/988\n // Should come back to this later.\n // Consequently, this test will be a bit slower.\n // jest.useFakeTimers()\n\n Element.prototype.scrollIntoView = jest.fn();\n\n const mockIModel = mockIModelsResponse[0].iModel;\n const mockRunId = faker.datatype.uuid();\n\n const mockExtractionResponse = {\n run: {\n id: mockRunId,\n _links: {\n status: {\n href: \"\",\n },\n },\n },\n };\n\n let mockStatusResponse: ExtractionStatus = {\n status: {\n state: \"Queued\",\n reason: \"\",\n },\n };\n\n server.use(\n rest.get(\n `${REPORTS_CONFIG_BASE_URL}/insights/reporting/reports/${mockReportId}/datasources/imodelMappings`,\n async (_req, res, ctx) => {\n return res(\n ctx.delay(),\n ctx.status(200),\n ctx.json(mockReportMappings)\n );\n }\n ),\n rest.get(\n `${Constants.api.baseUrl}/${mockIModelId1}`,\n async (_req, res, ctx) => {\n return res(\n ctx.delay(),\n ctx.status(200),\n ctx.json(mockIModelsResponse[0])\n );\n }\n ),\n rest.get(\n `${Constants.api.baseUrl}/${mockIModelId2}`,\n async (_req, res, ctx) => {\n return res(\n ctx.delay(),\n ctx.status(200),\n ctx.json(mockIModelsResponse[1])\n );\n }\n ),\n ...iModelHandlers,\n rest.post(\n `${REPORTS_CONFIG_BASE_URL}/insights/reporting/datasources/imodels/${mockIModel.id}/extraction/run`,\n async (_req, res, ctx) => {\n return res(\n ctx.delay(),\n ctx.status(200),\n ctx.json(mockExtractionResponse)\n );\n }\n ),\n rest.get(\n `${REPORTS_CONFIG_BASE_URL}/insights/reporting/datasources/extraction/status/${mockRunId}`,\n async (_req, res, ctx) => {\n return res(\n ctx.delay(),\n ctx.status(200),\n ctx.json(mockStatusResponse)\n );\n }\n )\n );\n\n render(<ReportMappings report={mockReport} goBack={jest.fn()} />);\n\n // https://github.com/testing-library/user-event/issues/833\n const user = userEvent.setup({ delay: null });\n\n await waitForElementToBeRemoved(() => screen.getByText(/loading/i));\n\n const comboBox = screen.getByRole(\"combobox\", {\n name: /updatedataset/i,\n });\n await user.type(comboBox, mockIModel.displayName);\n\n const option = screen.getByRole(\"option\", {\n name: mockIModel.displayName,\n });\n\n await user.click(option);\n\n // Combobox should have correct status\n const extractionComponent = screen.getByTestId(\"extraction-combo-box\");\n expect(\n within(extractionComponent).getByDisplayValue(mockIModel.displayName)\n ).toBeInTheDocument();\n // Should be two in the document. One in the status and the other in the list.\n // TODO Assert that it is in the correct HorizontalTile\n expect(screen.getAllByTitle(/starting/i)).toHaveLength(2);\n\n const loadingStates = await screen.findAllByTitle(/loading/i);\n expect(loadingStates).toHaveLength(2);\n\n // act(() => {\n // jest.advanceTimersByTime(2000)\n // });\n const queuedStates = await screen.findAllByTitle(/queued/i, undefined, {\n timeout: delay,\n });\n expect(queuedStates).toHaveLength(2);\n\n mockStatusResponse = {\n status: {\n state: \"Running\",\n reason: \"\",\n },\n };\n\n const runningStates = await screen.findAllByTitle(/running/i, undefined, {\n timeout: delay,\n });\n expect(runningStates).toHaveLength(2);\n\n mockStatusResponse = {\n status: {\n state: \"Succeeded\",\n reason: \"\",\n },\n };\n\n const succeededStates = await screen.findAllByTitle(/success/i, undefined, {\n timeout: delay,\n });\n expect(succeededStates).toHaveLength(2);\n });\n});\n"]}