@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.
- package/.rush/temp/package-deps_rebuild.json +48 -0
- package/.rush/temp/shrinkwrap-deps.json +868 -0
- package/CHANGELOG.json +17 -0
- package/CHANGELOG.md +11 -0
- package/LICENSE.md +9 -0
- package/README.md +38 -0
- package/__mocks__/fileMock.js +5 -0
- package/coverage/clover.xml +612 -0
- package/coverage/coverage-final.json +19 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +191 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +196 -0
- package/coverage/lcov-report/src/ReportsConfigWidget.ts.html +193 -0
- package/coverage/lcov-report/src/index.html +116 -0
- package/coverage/lcov-report/src/test/index.html +116 -0
- package/coverage/lcov-report/src/test/test-utils.tsx.html +316 -0
- package/coverage/lcov-report/src/widget/ReportsConfigUiProvider.tsx.html +286 -0
- package/coverage/lcov-report/src/widget/components/ActionPanel.tsx.html +253 -0
- package/coverage/lcov-report/src/widget/components/AddMappingsModal.tsx.html +610 -0
- package/coverage/lcov-report/src/widget/components/DeleteModal.tsx.html +385 -0
- package/coverage/lcov-report/src/widget/components/Extraction.tsx.html +1030 -0
- package/coverage/lcov-report/src/widget/components/HorizontalTile.tsx.html +256 -0
- package/coverage/lcov-report/src/widget/components/LocalizedTablePaginator.tsx.html +262 -0
- package/coverage/lcov-report/src/widget/components/ReportAction.tsx.html +523 -0
- package/coverage/lcov-report/src/widget/components/ReportMappings.tsx.html +1135 -0
- package/coverage/lcov-report/src/widget/components/Reports.tsx.html +829 -0
- package/coverage/lcov-report/src/widget/components/ReportsContainer.tsx.html +193 -0
- package/coverage/lcov-report/src/widget/components/SearchBar.tsx.html +271 -0
- package/coverage/lcov-report/src/widget/components/SelectIModel.tsx.html +391 -0
- package/coverage/lcov-report/src/widget/components/index.html +296 -0
- package/coverage/lcov-report/src/widget/components/utils.tsx.html +562 -0
- package/coverage/lcov-report/src/widget/context/ReportsApiConfigContext.tsx.html +166 -0
- package/coverage/lcov-report/src/widget/context/index.html +116 -0
- package/coverage/lcov-report/src/widget/hooks/index.html +116 -0
- package/coverage/lcov-report/src/widget/hooks/useValidator.ts.html +295 -0
- package/coverage/lcov-report/src/widget/index.html +116 -0
- package/coverage/lcov.info +1260 -0
- package/jest.config.js +19 -0
- package/lib/cjs/ReportsConfigWidget.d.ts +10 -0
- package/lib/cjs/ReportsConfigWidget.d.ts.map +1 -0
- package/lib/cjs/ReportsConfigWidget.js +24 -0
- package/lib/cjs/ReportsConfigWidget.js.map +1 -0
- package/lib/cjs/reports-config-widget-react.d.ts +4 -0
- package/lib/cjs/reports-config-widget-react.d.ts.map +1 -0
- package/lib/cjs/reports-config-widget-react.js +20 -0
- package/lib/cjs/reports-config-widget-react.js.map +1 -0
- package/lib/cjs/test/ReportAction.test.d.ts +2 -0
- package/lib/cjs/test/ReportAction.test.d.ts.map +1 -0
- package/lib/cjs/test/ReportAction.test.js +194 -0
- package/lib/cjs/test/ReportAction.test.js.map +1 -0
- package/lib/cjs/test/ReportMappings.test.d.ts +2 -0
- package/lib/cjs/test/ReportMappings.test.d.ts.map +1 -0
- package/lib/cjs/test/ReportMappings.test.js +530 -0
- package/lib/cjs/test/ReportMappings.test.js.map +1 -0
- package/lib/cjs/test/Reports.test.d.ts +2 -0
- package/lib/cjs/test/Reports.test.d.ts.map +1 -0
- package/lib/cjs/test/Reports.test.js +232 -0
- package/lib/cjs/test/Reports.test.js.map +1 -0
- package/lib/cjs/test/WidgetHeader.test.d.ts +2 -0
- package/lib/cjs/test/WidgetHeader.test.d.ts.map +1 -0
- package/lib/cjs/test/WidgetHeader.test.js +30 -0
- package/lib/cjs/test/WidgetHeader.test.js.map +1 -0
- package/lib/cjs/test/test-utils.d.ts +69 -0
- package/lib/cjs/test/test-utils.d.ts.map +1 -0
- package/lib/cjs/test/test-utils.js +77 -0
- package/lib/cjs/test/test-utils.js.map +1 -0
- package/lib/cjs/tsconfig.tsbuildinfo +1 -0
- package/lib/cjs/widget/ReportsConfigUiProvider.d.ts +12 -0
- package/lib/cjs/widget/ReportsConfigUiProvider.d.ts.map +1 -0
- package/lib/cjs/widget/ReportsConfigUiProvider.js +55 -0
- package/lib/cjs/widget/ReportsConfigUiProvider.js.map +1 -0
- package/lib/cjs/widget/components/ActionPanel.d.ts +13 -0
- package/lib/cjs/widget/components/ActionPanel.d.ts.map +1 -0
- package/lib/cjs/widget/components/ActionPanel.js +39 -0
- package/lib/cjs/widget/components/ActionPanel.js.map +1 -0
- package/lib/cjs/widget/components/ActionPanel.scss +12 -0
- package/lib/cjs/widget/components/AddMappingsModal.d.ts +15 -0
- package/lib/cjs/widget/components/AddMappingsModal.d.ts.map +1 -0
- package/lib/cjs/widget/components/AddMappingsModal.js +118 -0
- package/lib/cjs/widget/components/AddMappingsModal.js.map +1 -0
- package/lib/cjs/widget/components/AddMappingsModal.scss +18 -0
- package/lib/cjs/widget/components/DeleteModal.d.ts +12 -0
- package/lib/cjs/widget/components/DeleteModal.d.ts.map +1 -0
- package/lib/cjs/widget/components/DeleteModal.js +65 -0
- package/lib/cjs/widget/components/DeleteModal.js.map +1 -0
- package/lib/cjs/widget/components/DeleteModal.scss +18 -0
- package/lib/cjs/widget/components/Extraction.d.ts +28 -0
- package/lib/cjs/widget/components/Extraction.d.ts.map +1 -0
- package/lib/cjs/widget/components/Extraction.js +193 -0
- package/lib/cjs/widget/components/Extraction.js.map +1 -0
- package/lib/cjs/widget/components/Extraction.scss +39 -0
- package/lib/cjs/widget/components/HorizontalTile.d.ts +13 -0
- package/lib/cjs/widget/components/HorizontalTile.d.ts.map +1 -0
- package/lib/cjs/widget/components/HorizontalTile.js +18 -0
- package/lib/cjs/widget/components/HorizontalTile.js.map +1 -0
- package/lib/cjs/widget/components/HorizontalTile.scss +32 -0
- package/lib/cjs/widget/components/LocalizedTablePaginator.d.ts +4 -0
- package/lib/cjs/widget/components/LocalizedTablePaginator.d.ts.map +1 -0
- package/lib/cjs/widget/components/LocalizedTablePaginator.js +41 -0
- package/lib/cjs/widget/components/LocalizedTablePaginator.js.map +1 -0
- package/lib/cjs/widget/components/ReportAction.d.ts +11 -0
- package/lib/cjs/widget/components/ReportAction.d.ts.map +1 -0
- package/lib/cjs/widget/components/ReportAction.js +101 -0
- package/lib/cjs/widget/components/ReportAction.js.map +1 -0
- package/lib/cjs/widget/components/ReportAction.scss +16 -0
- package/lib/cjs/widget/components/ReportMappings.d.ts +17 -0
- package/lib/cjs/widget/components/ReportMappings.d.ts.map +1 -0
- package/lib/cjs/widget/components/ReportMappings.js +174 -0
- package/lib/cjs/widget/components/ReportMappings.js.map +1 -0
- package/lib/cjs/widget/components/ReportMappings.scss +46 -0
- package/lib/cjs/widget/components/Reports.d.ts +7 -0
- package/lib/cjs/widget/components/Reports.d.ts.map +1 -0
- package/lib/cjs/widget/components/Reports.js +143 -0
- package/lib/cjs/widget/components/Reports.js.map +1 -0
- package/lib/cjs/widget/components/Reports.scss +36 -0
- package/lib/cjs/widget/components/ReportsContainer.d.ts +10 -0
- package/lib/cjs/widget/components/ReportsContainer.d.ts.map +1 -0
- package/lib/cjs/widget/components/ReportsContainer.js +34 -0
- package/lib/cjs/widget/components/ReportsContainer.js.map +1 -0
- package/lib/cjs/widget/components/ReportsContainer.scss +15 -0
- package/lib/cjs/widget/components/SearchBar.d.ts +10 -0
- package/lib/cjs/widget/components/SearchBar.d.ts.map +1 -0
- package/lib/cjs/widget/components/SearchBar.js +50 -0
- package/lib/cjs/widget/components/SearchBar.js.map +1 -0
- package/lib/cjs/widget/components/SearchBar.scss +27 -0
- package/lib/cjs/widget/components/SelectIModel.d.ts +9 -0
- package/lib/cjs/widget/components/SelectIModel.d.ts.map +1 -0
- package/lib/cjs/widget/components/SelectIModel.js +82 -0
- package/lib/cjs/widget/components/SelectIModel.js.map +1 -0
- package/lib/cjs/widget/components/SelectIModel.scss +15 -0
- package/lib/cjs/widget/components/utils.d.ts +23 -0
- package/lib/cjs/widget/components/utils.d.ts.map +1 -0
- package/lib/cjs/widget/components/utils.js +87 -0
- package/lib/cjs/widget/components/utils.js.map +1 -0
- package/lib/cjs/widget/components/utils.scss +39 -0
- package/lib/cjs/widget/context/ReportsApiConfigContext.d.ts +9 -0
- package/lib/cjs/widget/context/ReportsApiConfigContext.d.ts.map +1 -0
- package/lib/cjs/widget/context/ReportsApiConfigContext.js +37 -0
- package/lib/cjs/widget/context/ReportsApiConfigContext.js.map +1 -0
- package/lib/cjs/widget/hooks/useValidator.d.ts +8 -0
- package/lib/cjs/widget/hooks/useValidator.d.ts.map +1 -0
- package/lib/cjs/widget/hooks/useValidator.js +56 -0
- package/lib/cjs/widget/hooks/useValidator.js.map +1 -0
- package/lib/esm/ReportsConfigWidget.d.ts +10 -0
- package/lib/esm/ReportsConfigWidget.d.ts.map +1 -0
- package/lib/esm/ReportsConfigWidget.js +20 -0
- package/lib/esm/ReportsConfigWidget.js.map +1 -0
- package/lib/esm/reports-config-widget-react.d.ts +4 -0
- package/lib/esm/reports-config-widget-react.d.ts.map +1 -0
- package/lib/esm/reports-config-widget-react.js +8 -0
- package/lib/esm/reports-config-widget-react.js.map +1 -0
- package/lib/esm/test/ReportAction.test.d.ts +2 -0
- package/lib/esm/test/ReportAction.test.d.ts.map +1 -0
- package/lib/esm/test/ReportAction.test.js +170 -0
- package/lib/esm/test/ReportAction.test.js.map +1 -0
- package/lib/esm/test/ReportMappings.test.d.ts +2 -0
- package/lib/esm/test/ReportMappings.test.d.ts.map +1 -0
- package/lib/esm/test/ReportMappings.test.js +506 -0
- package/lib/esm/test/ReportMappings.test.js.map +1 -0
- package/lib/esm/test/Reports.test.d.ts +2 -0
- package/lib/esm/test/Reports.test.d.ts.map +1 -0
- package/lib/esm/test/Reports.test.js +208 -0
- package/lib/esm/test/Reports.test.js.map +1 -0
- package/lib/esm/test/WidgetHeader.test.d.ts +2 -0
- package/lib/esm/test/WidgetHeader.test.d.ts.map +1 -0
- package/lib/esm/test/WidgetHeader.test.js +25 -0
- package/lib/esm/test/WidgetHeader.test.js.map +1 -0
- package/lib/esm/test/test-utils.d.ts +69 -0
- package/lib/esm/test/test-utils.d.ts.map +1 -0
- package/lib/esm/test/test-utils.js +48 -0
- package/lib/esm/test/test-utils.js.map +1 -0
- package/lib/esm/tsconfig.tsbuildinfo +1 -0
- package/lib/esm/widget/ReportsConfigUiProvider.d.ts +12 -0
- package/lib/esm/widget/ReportsConfigUiProvider.d.ts.map +1 -0
- package/lib/esm/widget/ReportsConfigUiProvider.js +29 -0
- package/lib/esm/widget/ReportsConfigUiProvider.js.map +1 -0
- package/lib/esm/widget/components/ActionPanel.d.ts +13 -0
- package/lib/esm/widget/components/ActionPanel.d.ts.map +1 -0
- package/lib/esm/widget/components/ActionPanel.js +18 -0
- package/lib/esm/widget/components/ActionPanel.js.map +1 -0
- package/lib/esm/widget/components/ActionPanel.scss +12 -0
- package/lib/esm/widget/components/AddMappingsModal.d.ts +15 -0
- package/lib/esm/widget/components/AddMappingsModal.d.ts.map +1 -0
- package/lib/esm/widget/components/AddMappingsModal.js +94 -0
- package/lib/esm/widget/components/AddMappingsModal.js.map +1 -0
- package/lib/esm/widget/components/AddMappingsModal.scss +18 -0
- package/lib/esm/widget/components/DeleteModal.d.ts +12 -0
- package/lib/esm/widget/components/DeleteModal.d.ts.map +1 -0
- package/lib/esm/widget/components/DeleteModal.js +42 -0
- package/lib/esm/widget/components/DeleteModal.js.map +1 -0
- package/lib/esm/widget/components/DeleteModal.scss +18 -0
- package/lib/esm/widget/components/Extraction.d.ts +28 -0
- package/lib/esm/widget/components/Extraction.d.ts.map +1 -0
- package/lib/esm/widget/components/Extraction.js +169 -0
- package/lib/esm/widget/components/Extraction.js.map +1 -0
- package/lib/esm/widget/components/Extraction.scss +39 -0
- package/lib/esm/widget/components/HorizontalTile.d.ts +13 -0
- package/lib/esm/widget/components/HorizontalTile.d.ts.map +1 -0
- package/lib/esm/widget/components/HorizontalTile.js +11 -0
- package/lib/esm/widget/components/HorizontalTile.js.map +1 -0
- package/lib/esm/widget/components/HorizontalTile.scss +32 -0
- package/lib/esm/widget/components/LocalizedTablePaginator.d.ts +4 -0
- package/lib/esm/widget/components/LocalizedTablePaginator.d.ts.map +1 -0
- package/lib/esm/widget/components/LocalizedTablePaginator.js +18 -0
- package/lib/esm/widget/components/LocalizedTablePaginator.js.map +1 -0
- package/lib/esm/widget/components/ReportAction.d.ts +11 -0
- package/lib/esm/widget/components/ReportAction.d.ts.map +1 -0
- package/lib/esm/widget/components/ReportAction.js +77 -0
- package/lib/esm/widget/components/ReportAction.js.map +1 -0
- package/lib/esm/widget/components/ReportAction.scss +16 -0
- package/lib/esm/widget/components/ReportMappings.d.ts +17 -0
- package/lib/esm/widget/components/ReportMappings.d.ts.map +1 -0
- package/lib/esm/widget/components/ReportMappings.js +148 -0
- package/lib/esm/widget/components/ReportMappings.js.map +1 -0
- package/lib/esm/widget/components/ReportMappings.scss +46 -0
- package/lib/esm/widget/components/Reports.d.ts +7 -0
- package/lib/esm/widget/components/Reports.d.ts.map +1 -0
- package/lib/esm/widget/components/Reports.js +117 -0
- package/lib/esm/widget/components/Reports.js.map +1 -0
- package/lib/esm/widget/components/Reports.scss +36 -0
- package/lib/esm/widget/components/ReportsContainer.d.ts +10 -0
- package/lib/esm/widget/components/ReportsContainer.d.ts.map +1 -0
- package/lib/esm/widget/components/ReportsContainer.js +13 -0
- package/lib/esm/widget/components/ReportsContainer.js.map +1 -0
- package/lib/esm/widget/components/ReportsContainer.scss +15 -0
- package/lib/esm/widget/components/SearchBar.d.ts +10 -0
- package/lib/esm/widget/components/SearchBar.d.ts.map +1 -0
- package/lib/esm/widget/components/SearchBar.js +27 -0
- package/lib/esm/widget/components/SearchBar.js.map +1 -0
- package/lib/esm/widget/components/SearchBar.scss +27 -0
- package/lib/esm/widget/components/SelectIModel.d.ts +9 -0
- package/lib/esm/widget/components/SelectIModel.d.ts.map +1 -0
- package/lib/esm/widget/components/SelectIModel.js +59 -0
- package/lib/esm/widget/components/SelectIModel.js.map +1 -0
- package/lib/esm/widget/components/SelectIModel.scss +15 -0
- package/lib/esm/widget/components/utils.d.ts +23 -0
- package/lib/esm/widget/components/utils.d.ts.map +1 -0
- package/lib/esm/widget/components/utils.js +73 -0
- package/lib/esm/widget/components/utils.js.map +1 -0
- package/lib/esm/widget/components/utils.scss +39 -0
- package/lib/esm/widget/context/ReportsApiConfigContext.d.ts +9 -0
- package/lib/esm/widget/context/ReportsApiConfigContext.d.ts.map +1 -0
- package/lib/esm/widget/context/ReportsApiConfigContext.js +14 -0
- package/lib/esm/widget/context/ReportsApiConfigContext.js.map +1 -0
- package/lib/esm/widget/hooks/useValidator.d.ts +8 -0
- package/lib/esm/widget/hooks/useValidator.d.ts.map +1 -0
- package/lib/esm/widget/hooks/useValidator.js +50 -0
- package/lib/esm/widget/hooks/useValidator.js.map +1 -0
- package/lib/public/locales/en/ReportsConfigWidget.json +76 -0
- package/package.json +124 -0
- package/public/locales/en/ReportsConfigWidget.json +76 -0
- package/reports-config-widget-react.build.error.log +10 -0
- package/reports-config-widget-react.build.log +45 -0
- package/src/ReportsConfigWidget.ts +36 -0
- package/src/reports-config-widget-react.ts +7 -0
- package/src/test/ReportAction.test.tsx +258 -0
- package/src/test/ReportMappings.test.tsx +882 -0
- package/src/test/Reports.test.tsx +365 -0
- package/src/test/WidgetHeader.test.tsx +29 -0
- package/src/test/test-utils.tsx +77 -0
- package/src/widget/ReportsConfigUiProvider.tsx +67 -0
- package/src/widget/components/ActionPanel.scss +12 -0
- package/src/widget/components/ActionPanel.tsx +56 -0
- package/src/widget/components/AddMappingsModal.scss +18 -0
- package/src/widget/components/AddMappingsModal.tsx +175 -0
- package/src/widget/components/DeleteModal.scss +18 -0
- package/src/widget/components/DeleteModal.tsx +100 -0
- package/src/widget/components/Extraction.scss +39 -0
- package/src/widget/components/Extraction.tsx +315 -0
- package/src/widget/components/HorizontalTile.scss +32 -0
- package/src/widget/components/HorizontalTile.tsx +57 -0
- package/src/widget/components/LocalizedTablePaginator.tsx +59 -0
- package/src/widget/components/ReportAction.scss +16 -0
- package/src/widget/components/ReportAction.tsx +146 -0
- package/src/widget/components/ReportMappings.scss +46 -0
- package/src/widget/components/ReportMappings.tsx +350 -0
- package/src/widget/components/Reports.scss +36 -0
- package/src/widget/components/Reports.tsx +248 -0
- package/src/widget/components/ReportsContainer.scss +15 -0
- package/src/widget/components/ReportsContainer.tsx +36 -0
- package/src/widget/components/SearchBar.scss +27 -0
- package/src/widget/components/SearchBar.tsx +62 -0
- package/src/widget/components/SelectIModel.scss +15 -0
- package/src/widget/components/SelectIModel.tsx +102 -0
- package/src/widget/components/utils.scss +39 -0
- package/src/widget/components/utils.tsx +159 -0
- package/src/widget/context/ReportsApiConfigContext.tsx +27 -0
- package/src/widget/hooks/useValidator.ts +70 -0
- package/tsconfig.json +11 -0
|
@@ -0,0 +1,882 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
import React from "react";
|
|
6
|
+
import faker from "@faker-js/faker";
|
|
7
|
+
import "@testing-library/jest-dom";
|
|
8
|
+
import type {
|
|
9
|
+
IModelConnection,
|
|
10
|
+
SelectionSet,
|
|
11
|
+
SelectionSetEvent,
|
|
12
|
+
} from "@itwin/core-frontend";
|
|
13
|
+
import { NoRenderApp } from "@itwin/core-frontend";
|
|
14
|
+
import { ReportsConfigWidget } from "../ReportsConfigWidget";
|
|
15
|
+
import { setupServer } from "msw/node";
|
|
16
|
+
import {
|
|
17
|
+
render,
|
|
18
|
+
screen,
|
|
19
|
+
TestUtils,
|
|
20
|
+
waitForElementToBeRemoved,
|
|
21
|
+
within,
|
|
22
|
+
} from "./test-utils";
|
|
23
|
+
import userEvent from "@testing-library/user-event";
|
|
24
|
+
import * as moq from "typemoq";
|
|
25
|
+
import type { RequestHandler } from "msw";
|
|
26
|
+
import { rest } from "msw";
|
|
27
|
+
import type {
|
|
28
|
+
ExtractionStatus,
|
|
29
|
+
Mapping,
|
|
30
|
+
MappingCollection,
|
|
31
|
+
MappingSingle,
|
|
32
|
+
Report,
|
|
33
|
+
ReportMappingCollection,
|
|
34
|
+
} from "@itwin/insights-client";
|
|
35
|
+
import { ReportMappings } from "../widget/components/ReportMappings";
|
|
36
|
+
import { Constants, IModelState } from "@itwin/imodels-client-management";
|
|
37
|
+
import { REPORTS_CONFIG_BASE_URL } from "../widget/ReportsConfigUiProvider";
|
|
38
|
+
import { REFRESH_DELAY } from "../widget/components/Extraction";
|
|
39
|
+
import type {
|
|
40
|
+
SelectionManager,
|
|
41
|
+
SelectionScopesManager,
|
|
42
|
+
} from "@itwin/presentation-frontend";
|
|
43
|
+
import {
|
|
44
|
+
Presentation,
|
|
45
|
+
SelectionChangeEvent,
|
|
46
|
+
} from "@itwin/presentation-frontend";
|
|
47
|
+
import type { BeEvent } from "@itwin/core-bentley";
|
|
48
|
+
|
|
49
|
+
// For the extraction test
|
|
50
|
+
jest.setTimeout(20000);
|
|
51
|
+
|
|
52
|
+
const mockITwinId = faker.datatype.uuid();
|
|
53
|
+
// Lets work with two iModels for now.
|
|
54
|
+
const mockIModelId1 = faker.datatype.uuid();
|
|
55
|
+
const mockIModelId2 = faker.datatype.uuid();
|
|
56
|
+
|
|
57
|
+
const mockReportId = faker.datatype.uuid();
|
|
58
|
+
|
|
59
|
+
const mockIModelsResponse = [
|
|
60
|
+
{
|
|
61
|
+
iModel: {
|
|
62
|
+
id: mockIModelId1,
|
|
63
|
+
displayName: faker.random.alpha(10),
|
|
64
|
+
name: faker.random.alpha(10),
|
|
65
|
+
description: faker.random.words(10),
|
|
66
|
+
createdDateTime: "2021-10-04T22:13:50.397Z",
|
|
67
|
+
state: IModelState.Initialized,
|
|
68
|
+
projectId: mockITwinId,
|
|
69
|
+
extent: null,
|
|
70
|
+
_links: {
|
|
71
|
+
creator: {
|
|
72
|
+
href: "",
|
|
73
|
+
},
|
|
74
|
+
namedVersions: {
|
|
75
|
+
href: "",
|
|
76
|
+
},
|
|
77
|
+
changesets: {
|
|
78
|
+
href: "",
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
iModel: {
|
|
85
|
+
id: mockIModelId2,
|
|
86
|
+
displayName: faker.random.alpha(10),
|
|
87
|
+
name: faker.random.alpha(10),
|
|
88
|
+
description: faker.random.words(10),
|
|
89
|
+
createdDateTime: "2021-10-04T22:13:50.397Z",
|
|
90
|
+
state: IModelState.Initialized,
|
|
91
|
+
projectId: mockITwinId,
|
|
92
|
+
extent: null,
|
|
93
|
+
_links: {
|
|
94
|
+
creator: {
|
|
95
|
+
href: "",
|
|
96
|
+
},
|
|
97
|
+
namedVersions: {
|
|
98
|
+
href: "",
|
|
99
|
+
},
|
|
100
|
+
changesets: {
|
|
101
|
+
href: "",
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
];
|
|
107
|
+
|
|
108
|
+
const mockProjectIModels = {
|
|
109
|
+
iModels: mockIModelsResponse.map((iModel) => ({
|
|
110
|
+
id: iModel.iModel.id,
|
|
111
|
+
displayName: iModel.iModel.displayName,
|
|
112
|
+
})),
|
|
113
|
+
_links: {
|
|
114
|
+
self: {
|
|
115
|
+
href: "",
|
|
116
|
+
},
|
|
117
|
+
prev: null,
|
|
118
|
+
next: null,
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
const mockReport: Report = {
|
|
123
|
+
id: mockReportId,
|
|
124
|
+
displayName: faker.random.alpha(10),
|
|
125
|
+
description: faker.random.words(10),
|
|
126
|
+
deleted: false,
|
|
127
|
+
_links: {
|
|
128
|
+
project: {
|
|
129
|
+
href: "",
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
const mockReportMappingsFactory = (): ReportMappingCollection => {
|
|
135
|
+
return {
|
|
136
|
+
mappings: [
|
|
137
|
+
{
|
|
138
|
+
reportId: mockReportId,
|
|
139
|
+
mappingId: faker.datatype.uuid(),
|
|
140
|
+
imodelId: mockIModelId1,
|
|
141
|
+
_links: {
|
|
142
|
+
report: {
|
|
143
|
+
href: "",
|
|
144
|
+
},
|
|
145
|
+
mapping: {
|
|
146
|
+
href: "",
|
|
147
|
+
},
|
|
148
|
+
imodel: {
|
|
149
|
+
href: "",
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
reportId: mockReportId,
|
|
155
|
+
mappingId: faker.datatype.uuid(),
|
|
156
|
+
imodelId: mockIModelId2,
|
|
157
|
+
_links: {
|
|
158
|
+
report: {
|
|
159
|
+
href: "",
|
|
160
|
+
},
|
|
161
|
+
mapping: {
|
|
162
|
+
href: "",
|
|
163
|
+
},
|
|
164
|
+
imodel: {
|
|
165
|
+
href: "",
|
|
166
|
+
},
|
|
167
|
+
},
|
|
168
|
+
},
|
|
169
|
+
],
|
|
170
|
+
_links: {
|
|
171
|
+
next: undefined,
|
|
172
|
+
self: {
|
|
173
|
+
href: "",
|
|
174
|
+
},
|
|
175
|
+
},
|
|
176
|
+
};
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
const mockMappingsFactory = (
|
|
180
|
+
mockReportMappings: ReportMappingCollection
|
|
181
|
+
): [MappingSingle[], RequestHandler[]] => {
|
|
182
|
+
const mockMappings: MappingSingle[] = mockReportMappings.mappings!.map(
|
|
183
|
+
(mapping) => ({
|
|
184
|
+
mapping: {
|
|
185
|
+
id: mapping.mappingId,
|
|
186
|
+
mappingName: faker.random.alpha(10),
|
|
187
|
+
description: faker.random.words(10),
|
|
188
|
+
extractionEnabled: false,
|
|
189
|
+
createdOn: "",
|
|
190
|
+
createdBy: "",
|
|
191
|
+
modifiedOn: "",
|
|
192
|
+
modifiedBy: "",
|
|
193
|
+
_links: {
|
|
194
|
+
imodel: {
|
|
195
|
+
// Tie the mapping to to the iModel Id
|
|
196
|
+
href: mapping.imodelId,
|
|
197
|
+
},
|
|
198
|
+
},
|
|
199
|
+
},
|
|
200
|
+
})
|
|
201
|
+
);
|
|
202
|
+
|
|
203
|
+
const iModelHandlers: RequestHandler[] = mockMappings.map((mapping) =>
|
|
204
|
+
rest.get(
|
|
205
|
+
`${REPORTS_CONFIG_BASE_URL}/insights/reporting/datasources/imodels/${
|
|
206
|
+
mapping.mapping?._links?.imodel?.href ?? ""
|
|
207
|
+
}/mappings/${mapping.mapping?.id}`,
|
|
208
|
+
async (_req, res, ctx) => {
|
|
209
|
+
return res(ctx.delay(), ctx.status(200), ctx.json(mapping));
|
|
210
|
+
}
|
|
211
|
+
)
|
|
212
|
+
);
|
|
213
|
+
|
|
214
|
+
return [mockMappings, iModelHandlers];
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
const connectionMock = moq.Mock.ofType<IModelConnection>();
|
|
218
|
+
const selectionManagerMock = moq.Mock.ofType<SelectionManager>();
|
|
219
|
+
const selectionScopesManagerMock = moq.Mock.ofType<SelectionScopesManager>();
|
|
220
|
+
|
|
221
|
+
jest.mock("@itwin/appui-react", () => ({
|
|
222
|
+
...jest.requireActual("@itwin/appui-react"),
|
|
223
|
+
useActiveIModelConnection: () => connectionMock.object,
|
|
224
|
+
}));
|
|
225
|
+
|
|
226
|
+
const server = setupServer();
|
|
227
|
+
|
|
228
|
+
beforeAll(async () => {
|
|
229
|
+
// This is required by the i18n module within iTwin.js
|
|
230
|
+
(global as any).XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest; // eslint-disable-line @typescript-eslint/no-var-requires
|
|
231
|
+
await NoRenderApp.startup();
|
|
232
|
+
await Presentation.initialize();
|
|
233
|
+
const selectionSet = moq.Mock.ofType<SelectionSet>();
|
|
234
|
+
const onChanged = moq.Mock.ofType<BeEvent<(ev: SelectionSetEvent) => void>>();
|
|
235
|
+
selectionSet.setup((x) => x.elements).returns(() => new Set([]));
|
|
236
|
+
selectionSet.setup((x) => x.onChanged).returns(() => onChanged.object);
|
|
237
|
+
connectionMock
|
|
238
|
+
.setup((x) => x.selectionSet)
|
|
239
|
+
.returns(() => selectionSet.object);
|
|
240
|
+
connectionMock.setup((x) => x.iModelId).returns(() => mockIModelId1);
|
|
241
|
+
connectionMock.setup((x) => x.iTwinId).returns(() => mockITwinId);
|
|
242
|
+
|
|
243
|
+
selectionManagerMock
|
|
244
|
+
.setup((x) => x.selectionChange)
|
|
245
|
+
.returns(() => new SelectionChangeEvent());
|
|
246
|
+
|
|
247
|
+
selectionScopesManagerMock
|
|
248
|
+
.setup(async (x) => x.getSelectionScopes(connectionMock.object))
|
|
249
|
+
.returns(async () => []);
|
|
250
|
+
selectionManagerMock
|
|
251
|
+
.setup((x) => x.scopes)
|
|
252
|
+
.returns(() => selectionScopesManagerMock.object);
|
|
253
|
+
|
|
254
|
+
Presentation.setSelectionManager(selectionManagerMock.object);
|
|
255
|
+
await TestUtils.initializeUiFramework(connectionMock.object);
|
|
256
|
+
await ReportsConfigWidget.initialize();
|
|
257
|
+
server.listen();
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
afterAll(() => {
|
|
261
|
+
TestUtils.terminateUiFramework();
|
|
262
|
+
server.close();
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
afterEach(() => {
|
|
266
|
+
server.resetHandlers();
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
describe("Report Mappings View", () => {
|
|
270
|
+
it("shows all report mappings", async () => {
|
|
271
|
+
const mockReportMappings = mockReportMappingsFactory();
|
|
272
|
+
const [mockMappings, iModelHandlers] =
|
|
273
|
+
mockMappingsFactory(mockReportMappings);
|
|
274
|
+
|
|
275
|
+
server.use(
|
|
276
|
+
rest.get(
|
|
277
|
+
`${REPORTS_CONFIG_BASE_URL}/insights/reporting/reports/${mockReportId}/datasources/imodelMappings`,
|
|
278
|
+
async (_req, res, ctx) => {
|
|
279
|
+
return res(
|
|
280
|
+
ctx.delay(),
|
|
281
|
+
ctx.status(200),
|
|
282
|
+
ctx.json(mockReportMappings)
|
|
283
|
+
);
|
|
284
|
+
}
|
|
285
|
+
),
|
|
286
|
+
rest.get(
|
|
287
|
+
`${Constants.api.baseUrl}/${mockIModelId1}`,
|
|
288
|
+
async (_req, res, ctx) => {
|
|
289
|
+
return res(
|
|
290
|
+
ctx.delay(),
|
|
291
|
+
ctx.status(200),
|
|
292
|
+
ctx.json(mockIModelsResponse[0])
|
|
293
|
+
);
|
|
294
|
+
}
|
|
295
|
+
),
|
|
296
|
+
rest.get(
|
|
297
|
+
`${Constants.api.baseUrl}/${mockIModelId2}`,
|
|
298
|
+
async (_req, res, ctx) => {
|
|
299
|
+
return res(
|
|
300
|
+
ctx.delay(),
|
|
301
|
+
ctx.status(200),
|
|
302
|
+
ctx.json(mockIModelsResponse[1])
|
|
303
|
+
);
|
|
304
|
+
}
|
|
305
|
+
),
|
|
306
|
+
...iModelHandlers
|
|
307
|
+
);
|
|
308
|
+
|
|
309
|
+
render(<ReportMappings report={mockReport} goBack={jest.fn()} />);
|
|
310
|
+
|
|
311
|
+
await waitForElementToBeRemoved(() => screen.getByText(/loading/i));
|
|
312
|
+
|
|
313
|
+
const horizontalTiles = screen.getAllByTestId("horizontal-tile");
|
|
314
|
+
|
|
315
|
+
expect(horizontalTiles).toHaveLength(mockMappings.length);
|
|
316
|
+
|
|
317
|
+
for (const [index, horizontalTile] of horizontalTiles.entries()) {
|
|
318
|
+
const reportMappingTile = within(horizontalTile);
|
|
319
|
+
const mockiModel = mockIModelsResponse.find(
|
|
320
|
+
(iModel) =>
|
|
321
|
+
iModel.iModel.id === mockMappings[index].mapping?._links?.imodel?.href
|
|
322
|
+
);
|
|
323
|
+
expect(
|
|
324
|
+
reportMappingTile.getByText(
|
|
325
|
+
mockMappings[index].mapping?.mappingName ?? ""
|
|
326
|
+
)
|
|
327
|
+
).toBeInTheDocument();
|
|
328
|
+
expect(
|
|
329
|
+
reportMappingTile.getByTitle(
|
|
330
|
+
mockMappings[index].mapping?.description ?? ""
|
|
331
|
+
)
|
|
332
|
+
).toBeInTheDocument();
|
|
333
|
+
expect(
|
|
334
|
+
reportMappingTile.getByText(mockiModel?.iModel.displayName ?? "")
|
|
335
|
+
).toBeInTheDocument();
|
|
336
|
+
}
|
|
337
|
+
});
|
|
338
|
+
|
|
339
|
+
it("search for a report mapping", async () => {
|
|
340
|
+
const mockReportMappings = mockReportMappingsFactory();
|
|
341
|
+
const [mockMappings, iModelHandlers] =
|
|
342
|
+
mockMappingsFactory(mockReportMappings);
|
|
343
|
+
|
|
344
|
+
server.use(
|
|
345
|
+
rest.get(
|
|
346
|
+
`${REPORTS_CONFIG_BASE_URL}/insights/reporting/reports/${mockReportId}/datasources/imodelMappings`,
|
|
347
|
+
async (_req, res, ctx) => {
|
|
348
|
+
return res(
|
|
349
|
+
ctx.delay(),
|
|
350
|
+
ctx.status(200),
|
|
351
|
+
ctx.json(mockReportMappings)
|
|
352
|
+
);
|
|
353
|
+
}
|
|
354
|
+
),
|
|
355
|
+
rest.get(
|
|
356
|
+
`${Constants.api.baseUrl}/${mockIModelId1}`,
|
|
357
|
+
async (_req, res, ctx) => {
|
|
358
|
+
return res(
|
|
359
|
+
ctx.delay(),
|
|
360
|
+
ctx.status(200),
|
|
361
|
+
ctx.json(mockIModelsResponse[0])
|
|
362
|
+
);
|
|
363
|
+
}
|
|
364
|
+
),
|
|
365
|
+
rest.get(
|
|
366
|
+
`${Constants.api.baseUrl}/${mockIModelId2}`,
|
|
367
|
+
async (_req, res, ctx) => {
|
|
368
|
+
return res(
|
|
369
|
+
ctx.delay(),
|
|
370
|
+
ctx.status(200),
|
|
371
|
+
ctx.json(mockIModelsResponse[1])
|
|
372
|
+
);
|
|
373
|
+
}
|
|
374
|
+
),
|
|
375
|
+
...iModelHandlers
|
|
376
|
+
);
|
|
377
|
+
|
|
378
|
+
const { user } = render(
|
|
379
|
+
<ReportMappings report={mockReport} goBack={jest.fn()} />
|
|
380
|
+
);
|
|
381
|
+
|
|
382
|
+
await waitForElementToBeRemoved(() => screen.getByText(/loading/i));
|
|
383
|
+
|
|
384
|
+
const searchButton = within(screen.getByTestId(/search-bar/i)).getByRole(
|
|
385
|
+
"button"
|
|
386
|
+
);
|
|
387
|
+
await user.click(searchButton);
|
|
388
|
+
const searchInput = screen.getByRole("textbox", {
|
|
389
|
+
name: /search\-textbox/i,
|
|
390
|
+
});
|
|
391
|
+
|
|
392
|
+
// Be an exact match on display name.
|
|
393
|
+
await user.type(searchInput, mockMappings[0].mapping?.mappingName ?? "");
|
|
394
|
+
expect(screen.getAllByTestId("horizontal-tile")).toHaveLength(1);
|
|
395
|
+
expect(
|
|
396
|
+
screen.getByText(mockMappings[0].mapping?.mappingName ?? "")
|
|
397
|
+
).toBeInTheDocument();
|
|
398
|
+
|
|
399
|
+
// Be an exact match on description.
|
|
400
|
+
await user.clear(searchInput);
|
|
401
|
+
await user.type(searchInput, mockMappings[0].mapping?.description ?? "");
|
|
402
|
+
expect(screen.getAllByTestId("horizontal-tile")).toHaveLength(1);
|
|
403
|
+
expect(
|
|
404
|
+
screen.getByTitle(mockMappings[0].mapping?.description ?? "")
|
|
405
|
+
).toBeInTheDocument();
|
|
406
|
+
|
|
407
|
+
// Be an exact match on iModel Name.
|
|
408
|
+
const iModel = mockIModelsResponse.find(
|
|
409
|
+
(mockIModel) =>
|
|
410
|
+
mockIModel.iModel.id === mockMappings[0].mapping?._links?.imodel?.href
|
|
411
|
+
);
|
|
412
|
+
await user.clear(searchInput);
|
|
413
|
+
await user.type(searchInput, iModel?.iModel.displayName ?? "");
|
|
414
|
+
expect(screen.getAllByTestId("horizontal-tile")).toHaveLength(1);
|
|
415
|
+
expect(
|
|
416
|
+
screen.getByText(iModel?.iModel.displayName ?? "")
|
|
417
|
+
).toBeInTheDocument();
|
|
418
|
+
});
|
|
419
|
+
|
|
420
|
+
it("remove a report mapping", async () => {
|
|
421
|
+
const mockReportMappings = mockReportMappingsFactory();
|
|
422
|
+
const [_, iModelHandlers] = mockMappingsFactory(mockReportMappings);
|
|
423
|
+
|
|
424
|
+
const mockReportMappingsOriginalSize = mockReportMappings.mappings!.length;
|
|
425
|
+
|
|
426
|
+
server.use(
|
|
427
|
+
rest.get(
|
|
428
|
+
`${REPORTS_CONFIG_BASE_URL}/insights/reporting/reports/${mockReportId}/datasources/imodelMappings`,
|
|
429
|
+
async (_req, res, ctx) => {
|
|
430
|
+
return res(
|
|
431
|
+
ctx.delay(),
|
|
432
|
+
ctx.status(200),
|
|
433
|
+
ctx.json(mockReportMappings)
|
|
434
|
+
);
|
|
435
|
+
}
|
|
436
|
+
),
|
|
437
|
+
rest.get(
|
|
438
|
+
`${Constants.api.baseUrl}/${mockIModelId1}`,
|
|
439
|
+
async (_req, res, ctx) => {
|
|
440
|
+
return res(
|
|
441
|
+
ctx.delay(),
|
|
442
|
+
ctx.status(200),
|
|
443
|
+
ctx.json(mockIModelsResponse[0])
|
|
444
|
+
);
|
|
445
|
+
}
|
|
446
|
+
),
|
|
447
|
+
rest.get(
|
|
448
|
+
`${Constants.api.baseUrl}/${mockIModelId2}`,
|
|
449
|
+
async (_req, res, ctx) => {
|
|
450
|
+
return res(
|
|
451
|
+
ctx.delay(),
|
|
452
|
+
ctx.status(200),
|
|
453
|
+
ctx.json(mockIModelsResponse[1])
|
|
454
|
+
);
|
|
455
|
+
}
|
|
456
|
+
),
|
|
457
|
+
...iModelHandlers,
|
|
458
|
+
rest.delete(
|
|
459
|
+
`${REPORTS_CONFIG_BASE_URL}/insights/reporting/reports/${mockReportId}/datasources/imodelMappings/${
|
|
460
|
+
mockReportMappings.mappings![0].mappingId ?? ""
|
|
461
|
+
}`,
|
|
462
|
+
async (_req, res, ctx) => {
|
|
463
|
+
mockReportMappings.mappings = mockReportMappings.mappings!.filter(
|
|
464
|
+
(mapping) =>
|
|
465
|
+
mapping.mappingId !== mockReportMappings.mappings![0].mappingId ??
|
|
466
|
+
""
|
|
467
|
+
);
|
|
468
|
+
return res(ctx.delay(100), ctx.status(204));
|
|
469
|
+
}
|
|
470
|
+
)
|
|
471
|
+
);
|
|
472
|
+
|
|
473
|
+
const { user } = render(
|
|
474
|
+
<ReportMappings report={mockReport} goBack={jest.fn()} />
|
|
475
|
+
);
|
|
476
|
+
|
|
477
|
+
await waitForElementToBeRemoved(() => screen.getByText(/loading/i));
|
|
478
|
+
|
|
479
|
+
const firstMenuDropdown = within(
|
|
480
|
+
screen.getAllByTestId(/tile-action-button/i)[0]
|
|
481
|
+
).getByRole("button");
|
|
482
|
+
await user.click(firstMenuDropdown);
|
|
483
|
+
const removeButton = screen.getByRole("menuitem", { name: /remove/i });
|
|
484
|
+
await user.click(removeButton);
|
|
485
|
+
// Delete modal dialog should appear
|
|
486
|
+
expect(screen.getByRole("dialog")).toBeInTheDocument();
|
|
487
|
+
|
|
488
|
+
const deleteButton = screen.getByRole("button", {
|
|
489
|
+
name: /delete/i,
|
|
490
|
+
});
|
|
491
|
+
|
|
492
|
+
await user.click(deleteButton);
|
|
493
|
+
|
|
494
|
+
await waitForElementToBeRemoved(() =>
|
|
495
|
+
screen.getByTestId(/rcw-loading-delete/i)
|
|
496
|
+
);
|
|
497
|
+
await waitForElementToBeRemoved(() => screen.getByRole("dialog"));
|
|
498
|
+
|
|
499
|
+
// Should be one less mapping
|
|
500
|
+
expect(screen.getAllByTestId("horizontal-tile")).toHaveLength(
|
|
501
|
+
mockReportMappingsOriginalSize - 1
|
|
502
|
+
);
|
|
503
|
+
});
|
|
504
|
+
|
|
505
|
+
it("add mapping", async () => {
|
|
506
|
+
const mockReportMappings = mockReportMappingsFactory();
|
|
507
|
+
const [mockMappings, iModelHandlers] =
|
|
508
|
+
mockMappingsFactory(mockReportMappings);
|
|
509
|
+
|
|
510
|
+
// Adding an extra unmapped mapping.
|
|
511
|
+
const extraMappingId = faker.datatype.uuid();
|
|
512
|
+
const extraMappingName = faker.random.alpha(10);
|
|
513
|
+
|
|
514
|
+
mockMappings.push({
|
|
515
|
+
mapping: {
|
|
516
|
+
id: extraMappingId,
|
|
517
|
+
mappingName: extraMappingName,
|
|
518
|
+
description: faker.random.words(10),
|
|
519
|
+
extractionEnabled: false,
|
|
520
|
+
createdOn: "",
|
|
521
|
+
createdBy: "",
|
|
522
|
+
modifiedOn: "",
|
|
523
|
+
modifiedBy: "",
|
|
524
|
+
_links: {
|
|
525
|
+
imodel: {
|
|
526
|
+
href: "",
|
|
527
|
+
},
|
|
528
|
+
},
|
|
529
|
+
},
|
|
530
|
+
});
|
|
531
|
+
|
|
532
|
+
const mockMappingsResponse: MappingCollection = {
|
|
533
|
+
// Type guarding
|
|
534
|
+
mappings: mockMappings
|
|
535
|
+
.map((mapping) => mapping.mapping)
|
|
536
|
+
.filter((mapping): mapping is Mapping => !!mapping),
|
|
537
|
+
_links: {
|
|
538
|
+
next: undefined,
|
|
539
|
+
self: {
|
|
540
|
+
href: "",
|
|
541
|
+
},
|
|
542
|
+
},
|
|
543
|
+
};
|
|
544
|
+
|
|
545
|
+
server.use(
|
|
546
|
+
rest.get(
|
|
547
|
+
`${REPORTS_CONFIG_BASE_URL}/insights/reporting/reports/${mockReportId}/datasources/imodelMappings`,
|
|
548
|
+
async (_req, res, ctx) => {
|
|
549
|
+
return res(
|
|
550
|
+
ctx.delay(),
|
|
551
|
+
ctx.status(200),
|
|
552
|
+
ctx.json(mockReportMappings)
|
|
553
|
+
);
|
|
554
|
+
}
|
|
555
|
+
),
|
|
556
|
+
rest.get(`${Constants.api.baseUrl}`, async (_req, res, ctx) => {
|
|
557
|
+
return res(ctx.delay(), ctx.status(200), ctx.json(mockProjectIModels));
|
|
558
|
+
}),
|
|
559
|
+
rest.get(
|
|
560
|
+
`${Constants.api.baseUrl}/${mockIModelId1}`,
|
|
561
|
+
async (_req, res, ctx) => {
|
|
562
|
+
return res(
|
|
563
|
+
ctx.delay(),
|
|
564
|
+
ctx.status(200),
|
|
565
|
+
ctx.json(mockIModelsResponse[0])
|
|
566
|
+
);
|
|
567
|
+
}
|
|
568
|
+
),
|
|
569
|
+
rest.get(
|
|
570
|
+
`${Constants.api.baseUrl}/${mockIModelId2}`,
|
|
571
|
+
async (_req, res, ctx) => {
|
|
572
|
+
return res(
|
|
573
|
+
ctx.delay(),
|
|
574
|
+
ctx.status(200),
|
|
575
|
+
ctx.json(mockIModelsResponse[1])
|
|
576
|
+
);
|
|
577
|
+
}
|
|
578
|
+
),
|
|
579
|
+
rest.get(
|
|
580
|
+
`${REPORTS_CONFIG_BASE_URL}/insights/reporting/datasources/imodels/${mockProjectIModels.iModels[0].id}/mappings`,
|
|
581
|
+
async (_req, res, ctx) => {
|
|
582
|
+
return res(
|
|
583
|
+
ctx.delay(),
|
|
584
|
+
ctx.status(200),
|
|
585
|
+
ctx.json(mockMappingsResponse)
|
|
586
|
+
);
|
|
587
|
+
}
|
|
588
|
+
),
|
|
589
|
+
rest.post(
|
|
590
|
+
`${REPORTS_CONFIG_BASE_URL}/insights/reporting/reports/${mockReportId}/datasources/imodelMappings`,
|
|
591
|
+
async (_req, res, ctx) => {
|
|
592
|
+
return res(
|
|
593
|
+
ctx.delay(),
|
|
594
|
+
ctx.status(200),
|
|
595
|
+
ctx.json(mockReportMappings)
|
|
596
|
+
);
|
|
597
|
+
}
|
|
598
|
+
),
|
|
599
|
+
...iModelHandlers
|
|
600
|
+
);
|
|
601
|
+
|
|
602
|
+
const { user } = render(
|
|
603
|
+
<ReportMappings report={mockReport} goBack={jest.fn()} />
|
|
604
|
+
);
|
|
605
|
+
|
|
606
|
+
await waitForElementToBeRemoved(() => screen.getByText(/loading/i));
|
|
607
|
+
|
|
608
|
+
const addMappingButton = screen.getByRole("button", {
|
|
609
|
+
name: /addmapping/i,
|
|
610
|
+
});
|
|
611
|
+
|
|
612
|
+
await user.click(addMappingButton);
|
|
613
|
+
|
|
614
|
+
await waitForElementToBeRemoved(() =>
|
|
615
|
+
screen.getByTestId(/rcw-action-loading-spinner/i)
|
|
616
|
+
);
|
|
617
|
+
// Add modal dialog should appear
|
|
618
|
+
const modal = screen.getByRole("dialog");
|
|
619
|
+
expect(screen.getByRole("dialog")).toBeInTheDocument();
|
|
620
|
+
|
|
621
|
+
const withinModal = within(modal);
|
|
622
|
+
expect(withinModal.getByText(/addmappings/i)).toBeInTheDocument();
|
|
623
|
+
|
|
624
|
+
const addButton = withinModal.getByRole("button", {
|
|
625
|
+
name: /add/i,
|
|
626
|
+
});
|
|
627
|
+
// Add button should be disabled
|
|
628
|
+
expect(addButton).toBeDisabled();
|
|
629
|
+
|
|
630
|
+
// Already mapped mappings are disabled
|
|
631
|
+
for (let i = 0; i < mockMappings.length - 1; i++) {
|
|
632
|
+
const row = screen.getByRole("row", {
|
|
633
|
+
name: new RegExp(
|
|
634
|
+
`toggle row selected ${mockMappings[i].mapping?.mappingName} ${mockMappings[i].mapping?.description}`,
|
|
635
|
+
"i"
|
|
636
|
+
),
|
|
637
|
+
});
|
|
638
|
+
|
|
639
|
+
const checkbox = within(row).getByRole("checkbox", {
|
|
640
|
+
name: /toggle row selected/i,
|
|
641
|
+
});
|
|
642
|
+
expect(checkbox).toBeDisabled();
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
// Click on checkbox on new mapping
|
|
646
|
+
const unmappedRow = screen.getByRole("row", {
|
|
647
|
+
name: new RegExp(
|
|
648
|
+
`toggle row selected ${
|
|
649
|
+
mockMappings[mockMappings.length - 1].mapping?.mappingName
|
|
650
|
+
} ${mockMappings[mockMappings.length - 1].mapping?.description}`,
|
|
651
|
+
"i"
|
|
652
|
+
),
|
|
653
|
+
});
|
|
654
|
+
|
|
655
|
+
const enabledCheckbox = within(unmappedRow).getByRole("checkbox", {
|
|
656
|
+
name: /toggle row selected/i,
|
|
657
|
+
});
|
|
658
|
+
|
|
659
|
+
await user.click(enabledCheckbox);
|
|
660
|
+
|
|
661
|
+
await user.click(addButton);
|
|
662
|
+
// Modal should go away
|
|
663
|
+
await waitForElementToBeRemoved(() =>
|
|
664
|
+
screen.getByTestId(/rcw-action-loading-spinner/i)
|
|
665
|
+
);
|
|
666
|
+
await waitForElementToBeRemoved(() => screen.getByRole("dialog"));
|
|
667
|
+
});
|
|
668
|
+
|
|
669
|
+
it("odata feed url", async () => {
|
|
670
|
+
const mockReportMappings = mockReportMappingsFactory();
|
|
671
|
+
const [_, iModelHandlers] = mockMappingsFactory(mockReportMappings);
|
|
672
|
+
|
|
673
|
+
server.use(
|
|
674
|
+
rest.get(
|
|
675
|
+
`${REPORTS_CONFIG_BASE_URL}/insights/reporting/reports/${mockReportId}/datasources/imodelMappings`,
|
|
676
|
+
async (_req, res, ctx) => {
|
|
677
|
+
return res(
|
|
678
|
+
ctx.delay(),
|
|
679
|
+
ctx.status(200),
|
|
680
|
+
ctx.json(mockReportMappings)
|
|
681
|
+
);
|
|
682
|
+
}
|
|
683
|
+
),
|
|
684
|
+
rest.get(
|
|
685
|
+
`${Constants.api.baseUrl}/${mockIModelId1}`,
|
|
686
|
+
async (_req, res, ctx) => {
|
|
687
|
+
return res(
|
|
688
|
+
ctx.delay(),
|
|
689
|
+
ctx.status(200),
|
|
690
|
+
ctx.json(mockIModelsResponse[0])
|
|
691
|
+
);
|
|
692
|
+
}
|
|
693
|
+
),
|
|
694
|
+
rest.get(
|
|
695
|
+
`${Constants.api.baseUrl}/${mockIModelId2}`,
|
|
696
|
+
async (_req, res, ctx) => {
|
|
697
|
+
return res(
|
|
698
|
+
ctx.delay(),
|
|
699
|
+
ctx.status(200),
|
|
700
|
+
ctx.json(mockIModelsResponse[1])
|
|
701
|
+
);
|
|
702
|
+
}
|
|
703
|
+
),
|
|
704
|
+
...iModelHandlers
|
|
705
|
+
);
|
|
706
|
+
|
|
707
|
+
const { user } = render(
|
|
708
|
+
<ReportMappings report={mockReport} goBack={jest.fn()} />
|
|
709
|
+
);
|
|
710
|
+
|
|
711
|
+
await waitForElementToBeRemoved(() => screen.getByText(/loading/i));
|
|
712
|
+
|
|
713
|
+
const urlTextbox = screen.getByRole("textbox", {
|
|
714
|
+
name: /odatafeedurl/i,
|
|
715
|
+
});
|
|
716
|
+
expect(urlTextbox).toBeInTheDocument();
|
|
717
|
+
expect(
|
|
718
|
+
screen.getByDisplayValue(
|
|
719
|
+
`https://api.bentley.com/insights/reporting/odata/${mockReport.id}`
|
|
720
|
+
)
|
|
721
|
+
).toBeInTheDocument();
|
|
722
|
+
|
|
723
|
+
const copyButton = screen.getByRole("button", {
|
|
724
|
+
name: /copy/i,
|
|
725
|
+
});
|
|
726
|
+
|
|
727
|
+
await user.click(copyButton);
|
|
728
|
+
expect(screen.getByText(/copiedtoclipboard/i)).toBeInTheDocument();
|
|
729
|
+
});
|
|
730
|
+
|
|
731
|
+
it("full extraction", async () => {
|
|
732
|
+
const mockReportMappings = mockReportMappingsFactory();
|
|
733
|
+
const [_, iModelHandlers] = mockMappingsFactory(mockReportMappings);
|
|
734
|
+
|
|
735
|
+
const delay = REFRESH_DELAY;
|
|
736
|
+
|
|
737
|
+
// Faking timers currently makes all promise based queries from RTL become unpredictable.
|
|
738
|
+
// https://github.com/testing-library/dom-testing-library/issues/988
|
|
739
|
+
// Should come back to this later.
|
|
740
|
+
// Consequently, this test will be a bit slower.
|
|
741
|
+
// jest.useFakeTimers()
|
|
742
|
+
|
|
743
|
+
Element.prototype.scrollIntoView = jest.fn();
|
|
744
|
+
|
|
745
|
+
const mockIModel = mockIModelsResponse[0].iModel;
|
|
746
|
+
const mockRunId = faker.datatype.uuid();
|
|
747
|
+
|
|
748
|
+
const mockExtractionResponse = {
|
|
749
|
+
run: {
|
|
750
|
+
id: mockRunId,
|
|
751
|
+
_links: {
|
|
752
|
+
status: {
|
|
753
|
+
href: "",
|
|
754
|
+
},
|
|
755
|
+
},
|
|
756
|
+
},
|
|
757
|
+
};
|
|
758
|
+
|
|
759
|
+
let mockStatusResponse: ExtractionStatus = {
|
|
760
|
+
status: {
|
|
761
|
+
state: "Queued",
|
|
762
|
+
reason: "",
|
|
763
|
+
},
|
|
764
|
+
};
|
|
765
|
+
|
|
766
|
+
server.use(
|
|
767
|
+
rest.get(
|
|
768
|
+
`${REPORTS_CONFIG_BASE_URL}/insights/reporting/reports/${mockReportId}/datasources/imodelMappings`,
|
|
769
|
+
async (_req, res, ctx) => {
|
|
770
|
+
return res(
|
|
771
|
+
ctx.delay(),
|
|
772
|
+
ctx.status(200),
|
|
773
|
+
ctx.json(mockReportMappings)
|
|
774
|
+
);
|
|
775
|
+
}
|
|
776
|
+
),
|
|
777
|
+
rest.get(
|
|
778
|
+
`${Constants.api.baseUrl}/${mockIModelId1}`,
|
|
779
|
+
async (_req, res, ctx) => {
|
|
780
|
+
return res(
|
|
781
|
+
ctx.delay(),
|
|
782
|
+
ctx.status(200),
|
|
783
|
+
ctx.json(mockIModelsResponse[0])
|
|
784
|
+
);
|
|
785
|
+
}
|
|
786
|
+
),
|
|
787
|
+
rest.get(
|
|
788
|
+
`${Constants.api.baseUrl}/${mockIModelId2}`,
|
|
789
|
+
async (_req, res, ctx) => {
|
|
790
|
+
return res(
|
|
791
|
+
ctx.delay(),
|
|
792
|
+
ctx.status(200),
|
|
793
|
+
ctx.json(mockIModelsResponse[1])
|
|
794
|
+
);
|
|
795
|
+
}
|
|
796
|
+
),
|
|
797
|
+
...iModelHandlers,
|
|
798
|
+
rest.post(
|
|
799
|
+
`${REPORTS_CONFIG_BASE_URL}/insights/reporting/datasources/imodels/${mockIModel.id}/extraction/run`,
|
|
800
|
+
async (_req, res, ctx) => {
|
|
801
|
+
return res(
|
|
802
|
+
ctx.delay(),
|
|
803
|
+
ctx.status(200),
|
|
804
|
+
ctx.json(mockExtractionResponse)
|
|
805
|
+
);
|
|
806
|
+
}
|
|
807
|
+
),
|
|
808
|
+
rest.get(
|
|
809
|
+
`${REPORTS_CONFIG_BASE_URL}/insights/reporting/datasources/extraction/status/${mockRunId}`,
|
|
810
|
+
async (_req, res, ctx) => {
|
|
811
|
+
return res(
|
|
812
|
+
ctx.delay(),
|
|
813
|
+
ctx.status(200),
|
|
814
|
+
ctx.json(mockStatusResponse)
|
|
815
|
+
);
|
|
816
|
+
}
|
|
817
|
+
)
|
|
818
|
+
);
|
|
819
|
+
|
|
820
|
+
render(<ReportMappings report={mockReport} goBack={jest.fn()} />);
|
|
821
|
+
|
|
822
|
+
// https://github.com/testing-library/user-event/issues/833
|
|
823
|
+
const user = userEvent.setup({ delay: null });
|
|
824
|
+
|
|
825
|
+
await waitForElementToBeRemoved(() => screen.getByText(/loading/i));
|
|
826
|
+
|
|
827
|
+
const comboBox = screen.getByRole("combobox", {
|
|
828
|
+
name: /updatedataset/i,
|
|
829
|
+
});
|
|
830
|
+
await user.type(comboBox, mockIModel.displayName);
|
|
831
|
+
|
|
832
|
+
const option = screen.getByRole("option", {
|
|
833
|
+
name: mockIModel.displayName,
|
|
834
|
+
});
|
|
835
|
+
|
|
836
|
+
await user.click(option);
|
|
837
|
+
|
|
838
|
+
// Combobox should have correct status
|
|
839
|
+
const extractionComponent = screen.getByTestId("extraction-combo-box");
|
|
840
|
+
expect(
|
|
841
|
+
within(extractionComponent).getByDisplayValue(mockIModel.displayName)
|
|
842
|
+
).toBeInTheDocument();
|
|
843
|
+
// Should be two in the document. One in the status and the other in the list.
|
|
844
|
+
// TODO Assert that it is in the correct HorizontalTile
|
|
845
|
+
expect(screen.getAllByTitle(/starting/i)).toHaveLength(2);
|
|
846
|
+
|
|
847
|
+
const loadingStates = await screen.findAllByTitle(/loading/i);
|
|
848
|
+
expect(loadingStates).toHaveLength(2);
|
|
849
|
+
|
|
850
|
+
// act(() => {
|
|
851
|
+
// jest.advanceTimersByTime(2000)
|
|
852
|
+
// });
|
|
853
|
+
const queuedStates = await screen.findAllByTitle(/queued/i, undefined, {
|
|
854
|
+
timeout: delay,
|
|
855
|
+
});
|
|
856
|
+
expect(queuedStates).toHaveLength(2);
|
|
857
|
+
|
|
858
|
+
mockStatusResponse = {
|
|
859
|
+
status: {
|
|
860
|
+
state: "Running",
|
|
861
|
+
reason: "",
|
|
862
|
+
},
|
|
863
|
+
};
|
|
864
|
+
|
|
865
|
+
const runningStates = await screen.findAllByTitle(/running/i, undefined, {
|
|
866
|
+
timeout: delay,
|
|
867
|
+
});
|
|
868
|
+
expect(runningStates).toHaveLength(2);
|
|
869
|
+
|
|
870
|
+
mockStatusResponse = {
|
|
871
|
+
status: {
|
|
872
|
+
state: "Succeeded",
|
|
873
|
+
reason: "",
|
|
874
|
+
},
|
|
875
|
+
};
|
|
876
|
+
|
|
877
|
+
const succeededStates = await screen.findAllByTitle(/success/i, undefined, {
|
|
878
|
+
timeout: delay,
|
|
879
|
+
});
|
|
880
|
+
expect(succeededStates).toHaveLength(2);
|
|
881
|
+
});
|
|
882
|
+
});
|