@itwin/reports-config-widget-react 0.1.0 → 0.2.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 +38 -34
- package/.rush/temp/shrinkwrap-deps.json +14 -6
- package/CHANGELOG.json +30 -0
- package/CHANGELOG.md +17 -1
- package/coverage/clover.xml +605 -610
- package/coverage/coverage-final.json +28 -27
- package/coverage/lcov-report/index.html +31 -31
- package/coverage/lcov-report/src/ReportsConfigWidget.ts.html +10 -10
- package/coverage/lcov-report/src/index.html +1 -1
- package/coverage/lcov-report/src/test/index.html +1 -1
- package/coverage/lcov-report/src/test/test-utils.tsx.html +22 -22
- package/coverage/lcov-report/src/widget/ReportsConfigUiProvider.tsx.html +7 -7
- package/coverage/lcov-report/src/widget/components/ActionPanel.tsx.html +29 -41
- package/coverage/lcov-report/src/widget/components/AddMappingsModal.tsx.html +31 -37
- package/coverage/lcov-report/src/widget/components/BulkExtractor.ts.html +270 -162
- package/coverage/lcov-report/src/widget/components/Constants.ts.html +4 -4
- package/coverage/lcov-report/src/widget/components/DeleteModal.tsx.html +21 -21
- package/coverage/lcov-report/src/widget/components/ExtractionStates/FailedExtractionState.tsx.html +6 -6
- package/coverage/lcov-report/src/widget/components/ExtractionStates/QueuedExtractionState.tsx.html +14 -14
- package/coverage/lcov-report/src/widget/components/ExtractionStates/RunningExtractionState.tsx.html +15 -15
- package/coverage/lcov-report/src/widget/components/ExtractionStates/StartingExtractionState.tsx.html +14 -14
- package/coverage/lcov-report/src/widget/components/ExtractionStates/SucceededExtractionState.tsx.html +22 -19
- package/coverage/lcov-report/src/widget/components/ExtractionStates/index.html +43 -43
- package/coverage/lcov-report/src/widget/components/ExtractionStatus.tsx.html +57 -57
- package/coverage/lcov-report/src/widget/components/ExtractionToast.tsx.html +208 -0
- package/coverage/lcov-report/src/widget/components/HorizontalTile.tsx.html +8 -8
- package/coverage/lcov-report/src/widget/components/LocalizedTablePaginator.tsx.html +8 -8
- package/coverage/lcov-report/src/widget/components/ReportAction.tsx.html +14 -20
- package/coverage/lcov-report/src/widget/components/ReportHorizontalTile.tsx.html +30 -33
- package/coverage/lcov-report/src/widget/components/ReportMappingHorizontalTile.tsx.html +469 -0
- package/coverage/lcov-report/src/widget/components/ReportMappings.tsx.html +183 -231
- package/coverage/lcov-report/src/widget/components/Reports.tsx.html +73 -43
- package/coverage/lcov-report/src/widget/components/ReportsContainer.tsx.html +10 -10
- package/coverage/lcov-report/src/widget/components/SearchBar.tsx.html +10 -10
- package/coverage/lcov-report/src/widget/components/SelectIModel.tsx.html +31 -31
- package/coverage/lcov-report/src/widget/components/index.html +100 -85
- package/coverage/lcov-report/src/widget/components/utils.tsx.html +32 -32
- package/coverage/lcov-report/src/widget/context/ReportsApiConfigContext.tsx.html +8 -8
- package/coverage/lcov-report/src/widget/context/index.html +1 -1
- package/coverage/lcov-report/src/widget/hooks/index.html +1 -1
- package/coverage/lcov-report/src/widget/hooks/useValidator.ts.html +7 -7
- package/coverage/lcov-report/src/widget/index.html +1 -1
- package/coverage/lcov.info +990 -1003
- package/jest.config.js +6 -0
- package/lib/cjs/test/AddMappingModal.test.d.ts +2 -0
- package/lib/cjs/test/AddMappingModal.test.d.ts.map +1 -0
- package/lib/cjs/test/AddMappingModal.test.js +277 -0
- package/lib/cjs/test/AddMappingModal.test.js.map +1 -0
- package/lib/cjs/test/BulkExtractor.test.d.ts +2 -0
- package/lib/cjs/test/BulkExtractor.test.d.ts.map +1 -0
- package/lib/cjs/test/BulkExtractor.test.js +182 -0
- package/lib/cjs/test/BulkExtractor.test.js.map +1 -0
- package/lib/cjs/test/DeleteModal.test.d.ts +2 -0
- package/lib/cjs/test/DeleteModal.test.d.ts.map +1 -0
- package/lib/cjs/test/DeleteModal.test.js +93 -0
- package/lib/cjs/test/DeleteModal.test.js.map +1 -0
- package/lib/cjs/test/ReportAction.test.js +2 -3
- package/lib/cjs/test/ReportAction.test.js.map +1 -1
- package/lib/cjs/test/ReportMappingHorizontalTile.test.d.ts +2 -0
- package/lib/cjs/test/ReportMappingHorizontalTile.test.d.ts.map +1 -0
- package/lib/cjs/test/ReportMappingHorizontalTile.test.js +340 -0
- package/lib/cjs/test/ReportMappingHorizontalTile.test.js.map +1 -0
- package/lib/cjs/test/ReportMappings.test.js +115 -267
- package/lib/cjs/test/ReportMappings.test.js.map +1 -1
- package/lib/cjs/test/Reports.test.js +1 -1
- package/lib/cjs/test/Reports.test.js.map +1 -1
- package/lib/cjs/tsconfig.tsbuildinfo +1 -1
- package/lib/cjs/widget/components/ActionPanel.d.ts.map +1 -1
- package/lib/cjs/widget/components/ActionPanel.js +4 -5
- package/lib/cjs/widget/components/ActionPanel.js.map +1 -1
- package/lib/cjs/widget/components/AddMappingsModal.d.ts +2 -2
- package/lib/cjs/widget/components/AddMappingsModal.d.ts.map +1 -1
- package/lib/cjs/widget/components/AddMappingsModal.js +5 -4
- package/lib/cjs/widget/components/AddMappingsModal.js.map +1 -1
- package/lib/cjs/widget/components/AddMappingsModal.scss +4 -3
- package/lib/cjs/widget/components/BulkExtractor.d.ts +18 -9
- package/lib/cjs/widget/components/BulkExtractor.d.ts.map +1 -1
- package/lib/cjs/widget/components/BulkExtractor.js +86 -57
- package/lib/cjs/widget/components/BulkExtractor.js.map +1 -1
- package/lib/cjs/widget/components/DeleteModal.js +1 -1
- package/lib/cjs/widget/components/DeleteModal.js.map +1 -1
- package/lib/cjs/widget/components/DeleteModal.scss +4 -3
- package/lib/cjs/widget/components/ExtractionStates/RunningExtractionState.js +1 -1
- package/lib/cjs/widget/components/ExtractionStates/RunningExtractionState.js.map +1 -1
- package/lib/cjs/widget/components/ExtractionStates/SucceededExtractionState.d.ts.map +1 -1
- package/lib/cjs/widget/components/ExtractionStates/SucceededExtractionState.js +1 -1
- package/lib/cjs/widget/components/ExtractionStates/SucceededExtractionState.js.map +1 -1
- package/lib/cjs/widget/components/ExtractionStatus.scss +15 -1
- package/lib/cjs/widget/components/ExtractionToast.d.ts +11 -0
- package/lib/cjs/widget/components/ExtractionToast.d.ts.map +1 -0
- package/lib/cjs/widget/components/ExtractionToast.js +33 -0
- package/lib/cjs/widget/components/ExtractionToast.js.map +1 -0
- package/lib/cjs/widget/components/HorizontalTile.scss +1 -1
- package/lib/cjs/widget/components/ReportAction.d.ts.map +1 -1
- package/lib/cjs/widget/components/ReportAction.js +3 -3
- package/lib/cjs/widget/components/ReportAction.js.map +1 -1
- package/lib/cjs/widget/components/ReportAction.scss +2 -2
- package/lib/cjs/widget/components/ReportHorizontalTile.d.ts.map +1 -1
- package/lib/cjs/widget/components/ReportHorizontalTile.js +1 -2
- package/lib/cjs/widget/components/ReportHorizontalTile.js.map +1 -1
- package/lib/cjs/widget/components/ReportMappingHorizontalTile.d.ts +13 -0
- package/lib/cjs/widget/components/ReportMappingHorizontalTile.d.ts.map +1 -0
- package/lib/cjs/widget/components/ReportMappingHorizontalTile.js +82 -0
- package/lib/cjs/widget/components/ReportMappingHorizontalTile.js.map +1 -0
- package/lib/cjs/widget/components/ReportMappings.d.ts +3 -1
- package/lib/cjs/widget/components/ReportMappings.d.ts.map +1 -1
- package/lib/cjs/widget/components/ReportMappings.js +39 -40
- package/lib/cjs/widget/components/ReportMappings.js.map +1 -1
- package/lib/cjs/widget/components/ReportMappings.scss +7 -7
- package/lib/cjs/widget/components/Reports.d.ts.map +1 -1
- package/lib/cjs/widget/components/Reports.js +13 -6
- package/lib/cjs/widget/components/Reports.js.map +1 -1
- package/lib/cjs/widget/components/Reports.scss +1 -1
- package/lib/cjs/widget/components/ReportsContainer.js +1 -1
- package/lib/cjs/widget/components/ReportsContainer.js.map +1 -1
- package/lib/cjs/widget/components/ReportsContainer.scss +2 -2
- package/lib/cjs/widget/components/SelectIModel.js +2 -2
- package/lib/cjs/widget/components/SelectIModel.js.map +1 -1
- package/lib/cjs/widget/components/SelectIModel.scss +4 -3
- package/lib/cjs/widget/components/utils.js +1 -1
- package/lib/cjs/widget/components/utils.js.map +1 -1
- package/lib/cjs/widget/components/utils.scss +2 -2
- package/lib/esm/test/AddMappingModal.test.d.ts +2 -0
- package/lib/esm/test/AddMappingModal.test.d.ts.map +1 -0
- package/lib/esm/test/AddMappingModal.test.js +253 -0
- package/lib/esm/test/AddMappingModal.test.js.map +1 -0
- package/lib/esm/test/BulkExtractor.test.d.ts +2 -0
- package/lib/esm/test/BulkExtractor.test.d.ts.map +1 -0
- package/lib/esm/test/BulkExtractor.test.js +158 -0
- package/lib/esm/test/BulkExtractor.test.js.map +1 -0
- package/lib/esm/test/DeleteModal.test.d.ts +2 -0
- package/lib/esm/test/DeleteModal.test.d.ts.map +1 -0
- package/lib/esm/test/DeleteModal.test.js +69 -0
- package/lib/esm/test/DeleteModal.test.js.map +1 -0
- package/lib/esm/test/ReportAction.test.js +2 -3
- package/lib/esm/test/ReportAction.test.js.map +1 -1
- package/lib/esm/test/ReportMappingHorizontalTile.test.d.ts +2 -0
- package/lib/esm/test/ReportMappingHorizontalTile.test.d.ts.map +1 -0
- package/lib/esm/test/ReportMappingHorizontalTile.test.js +316 -0
- package/lib/esm/test/ReportMappingHorizontalTile.test.js.map +1 -0
- package/lib/esm/test/ReportMappings.test.js +117 -269
- package/lib/esm/test/ReportMappings.test.js.map +1 -1
- package/lib/esm/test/Reports.test.js +1 -1
- package/lib/esm/test/Reports.test.js.map +1 -1
- package/lib/esm/tsconfig.tsbuildinfo +1 -1
- package/lib/esm/widget/components/ActionPanel.d.ts.map +1 -1
- package/lib/esm/widget/components/ActionPanel.js +4 -5
- package/lib/esm/widget/components/ActionPanel.js.map +1 -1
- package/lib/esm/widget/components/AddMappingsModal.d.ts +2 -2
- package/lib/esm/widget/components/AddMappingsModal.d.ts.map +1 -1
- package/lib/esm/widget/components/AddMappingsModal.js +4 -5
- package/lib/esm/widget/components/AddMappingsModal.js.map +1 -1
- package/lib/esm/widget/components/AddMappingsModal.scss +4 -3
- package/lib/esm/widget/components/BulkExtractor.d.ts +18 -9
- package/lib/esm/widget/components/BulkExtractor.d.ts.map +1 -1
- package/lib/esm/widget/components/BulkExtractor.js +86 -57
- package/lib/esm/widget/components/BulkExtractor.js.map +1 -1
- package/lib/esm/widget/components/DeleteModal.js +1 -1
- package/lib/esm/widget/components/DeleteModal.js.map +1 -1
- package/lib/esm/widget/components/DeleteModal.scss +4 -3
- package/lib/esm/widget/components/ExtractionStates/RunningExtractionState.js +1 -1
- package/lib/esm/widget/components/ExtractionStates/RunningExtractionState.js.map +1 -1
- package/lib/esm/widget/components/ExtractionStates/SucceededExtractionState.d.ts.map +1 -1
- package/lib/esm/widget/components/ExtractionStates/SucceededExtractionState.js +1 -1
- package/lib/esm/widget/components/ExtractionStates/SucceededExtractionState.js.map +1 -1
- package/lib/esm/widget/components/ExtractionStatus.scss +15 -1
- package/lib/esm/widget/components/ExtractionToast.d.ts +11 -0
- package/lib/esm/widget/components/ExtractionToast.d.ts.map +1 -0
- package/lib/esm/widget/components/ExtractionToast.js +25 -0
- package/lib/esm/widget/components/ExtractionToast.js.map +1 -0
- package/lib/esm/widget/components/HorizontalTile.scss +1 -1
- package/lib/esm/widget/components/ReportAction.d.ts.map +1 -1
- package/lib/esm/widget/components/ReportAction.js +3 -3
- package/lib/esm/widget/components/ReportAction.js.map +1 -1
- package/lib/esm/widget/components/ReportAction.scss +2 -2
- package/lib/esm/widget/components/ReportHorizontalTile.d.ts.map +1 -1
- package/lib/esm/widget/components/ReportHorizontalTile.js +1 -2
- package/lib/esm/widget/components/ReportHorizontalTile.js.map +1 -1
- package/lib/esm/widget/components/ReportMappingHorizontalTile.d.ts +13 -0
- package/lib/esm/widget/components/ReportMappingHorizontalTile.d.ts.map +1 -0
- package/lib/esm/widget/components/ReportMappingHorizontalTile.js +75 -0
- package/lib/esm/widget/components/ReportMappingHorizontalTile.js.map +1 -0
- package/lib/esm/widget/components/ReportMappings.d.ts +3 -1
- package/lib/esm/widget/components/ReportMappings.d.ts.map +1 -1
- package/lib/esm/widget/components/ReportMappings.js +40 -41
- package/lib/esm/widget/components/ReportMappings.js.map +1 -1
- package/lib/esm/widget/components/ReportMappings.scss +7 -7
- package/lib/esm/widget/components/Reports.d.ts.map +1 -1
- package/lib/esm/widget/components/Reports.js +15 -8
- package/lib/esm/widget/components/Reports.js.map +1 -1
- package/lib/esm/widget/components/Reports.scss +1 -1
- package/lib/esm/widget/components/ReportsContainer.js +1 -1
- package/lib/esm/widget/components/ReportsContainer.js.map +1 -1
- package/lib/esm/widget/components/ReportsContainer.scss +2 -2
- package/lib/esm/widget/components/SelectIModel.js +2 -2
- package/lib/esm/widget/components/SelectIModel.js.map +1 -1
- package/lib/esm/widget/components/SelectIModel.scss +4 -3
- package/lib/esm/widget/components/utils.js +1 -1
- package/lib/esm/widget/components/utils.js.map +1 -1
- package/lib/esm/widget/components/utils.scss +2 -2
- package/lib/public/locales/en/ReportsConfigWidget.json +5 -0
- package/package.json +7 -4
- package/public/locales/en/ReportsConfigWidget.json +5 -0
- package/reports-config-widget-react.build.error.log +10 -6
- package/reports-config-widget-react.build.log +51 -46
- package/src/test/AddMappingModal.test.tsx +315 -0
- package/src/test/BulkExtractor.test.ts +301 -0
- package/src/test/DeleteModal.test.tsx +118 -0
- package/src/test/ReportAction.test.tsx +2 -4
- package/src/test/ReportMappingHorizontalTile.test.tsx +451 -0
- package/src/test/ReportMappings.test.tsx +154 -549
- package/src/test/Reports.test.tsx +1 -1
- package/src/widget/components/ActionPanel.tsx +19 -23
- package/src/widget/components/AddMappingsModal.scss +4 -3
- package/src/widget/components/AddMappingsModal.tsx +4 -6
- package/src/widget/components/BulkExtractor.ts +97 -61
- package/src/widget/components/DeleteModal.scss +4 -3
- package/src/widget/components/DeleteModal.tsx +1 -1
- package/src/widget/components/ExtractionStates/RunningExtractionState.tsx +1 -1
- package/src/widget/components/ExtractionStates/SucceededExtractionState.tsx +1 -0
- package/src/widget/components/ExtractionStatus.scss +15 -1
- package/src/widget/components/ExtractionToast.tsx +41 -0
- package/src/widget/components/HorizontalTile.scss +1 -1
- package/src/widget/components/ReportAction.scss +2 -2
- package/src/widget/components/ReportAction.tsx +1 -3
- package/src/widget/components/ReportHorizontalTile.tsx +1 -2
- package/src/widget/components/ReportMappingHorizontalTile.tsx +128 -0
- package/src/widget/components/ReportMappings.scss +7 -7
- package/src/widget/components/ReportMappings.tsx +89 -105
- package/src/widget/components/Reports.scss +1 -1
- package/src/widget/components/Reports.tsx +18 -8
- package/src/widget/components/ReportsContainer.scss +2 -2
- package/src/widget/components/ReportsContainer.tsx +1 -1
- package/src/widget/components/SelectIModel.scss +4 -3
- package/src/widget/components/SelectIModel.tsx +2 -2
- package/src/widget/components/utils.scss +2 -2
- package/src/widget/components/utils.tsx +1 -1
- package/coverage/lcov-report/src/widget/components/Extraction.tsx.html +0 -1030
- package/lib/cjs/widget/components/Extraction.d.ts +0 -28
- package/lib/cjs/widget/components/Extraction.d.ts.map +0 -1
- package/lib/cjs/widget/components/Extraction.js +0 -190
- package/lib/cjs/widget/components/Extraction.js.map +0 -1
- package/lib/cjs/widget/components/Extraction.scss +0 -39
- package/lib/esm/widget/components/Extraction.d.ts +0 -28
- package/lib/esm/widget/components/Extraction.d.ts.map +0 -1
- package/lib/esm/widget/components/Extraction.js +0 -166
- package/lib/esm/widget/components/Extraction.js.map +0 -1
- package/lib/esm/widget/components/Extraction.scss +0 -39
- package/src/widget/components/Extraction.scss +0 -39
- package/src/widget/components/Extraction.tsx +0 -315
|
@@ -0,0 +1,301 @@
|
|
|
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 BulkExtractor from "../widget/components/BulkExtractor";
|
|
6
|
+
import { ExtractionStates } from "../widget/components/ExtractionStatus";
|
|
7
|
+
import { assert } from "chai";
|
|
8
|
+
import * as moq from "typemoq";
|
|
9
|
+
import { ExtractorState } from "@itwin/insights-client";
|
|
10
|
+
import type { AccessToken } from "@itwin/core-bentley";
|
|
11
|
+
|
|
12
|
+
jest.mock("../widget/components/Constants.ts", () => ({
|
|
13
|
+
STATUS_CHECK_INTERVAL: -1,
|
|
14
|
+
}));
|
|
15
|
+
|
|
16
|
+
jest.mock("../widget/components/ExtractionToast.tsx", () => ({
|
|
17
|
+
FailedExtractionToast: jest.fn(),
|
|
18
|
+
SuccessfulExtractionToast: jest.fn(),
|
|
19
|
+
}));
|
|
20
|
+
|
|
21
|
+
const mockRunExtraction = moq.Mock.ofType<(accessToken: AccessToken, iModelId: string) => Promise<{ id: string }>>();
|
|
22
|
+
const mockGetStatus = moq.Mock.ofType<(accessToken: AccessToken, jobId: string) => Promise<{ state: ExtractorState }>>();
|
|
23
|
+
const mockGetReportMappings = moq.Mock.ofType<(accessToken: AccessToken, reportId: string) => Promise<{ imodelId: string }[]>>();
|
|
24
|
+
|
|
25
|
+
jest.mock("@itwin/insights-client", () => ({
|
|
26
|
+
...jest.requireActual("@itwin/insights-client"),
|
|
27
|
+
ReportsClient: jest.fn().mockImplementation(() => ({
|
|
28
|
+
getReportMappings: mockGetReportMappings.object,
|
|
29
|
+
})),
|
|
30
|
+
ExtractionClient: jest.fn().mockImplementation(() => ({
|
|
31
|
+
runExtraction: mockRunExtraction.object,
|
|
32
|
+
getExtractionStatus: mockGetStatus.object,
|
|
33
|
+
})),
|
|
34
|
+
}));
|
|
35
|
+
|
|
36
|
+
afterEach(() => {
|
|
37
|
+
mockRunExtraction.reset();
|
|
38
|
+
mockGetStatus.reset();
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const mockToastCallback = jest.fn();
|
|
42
|
+
|
|
43
|
+
const mockIModelId = "mockIModelId";
|
|
44
|
+
const mockIModelId1 = "mockIModelId1";
|
|
45
|
+
const mockReportId = "mockReportId";
|
|
46
|
+
const mockRunId = "mockRunId";
|
|
47
|
+
const mockRunId1 = "mockRunId1";
|
|
48
|
+
|
|
49
|
+
describe("BulkExtractor", () => {
|
|
50
|
+
const mockApiConfig = {
|
|
51
|
+
getAccessToken: async () => "mockAccessToken",
|
|
52
|
+
baseUrl: "",
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
it("should return status none for unknown iModel", async () => {
|
|
56
|
+
const sut = new BulkExtractor(mockApiConfig, mockToastCallback, mockToastCallback);
|
|
57
|
+
const result = await sut.getIModelState(mockIModelId, "", "");
|
|
58
|
+
assert.strictEqual(result, ExtractionStates.None);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it("should return running status for started extraction", async () => {
|
|
62
|
+
mockRunExtraction.setup(async (x) => x(moq.It.isAny(), mockIModelId)).returns(
|
|
63
|
+
async () => ({ id: mockRunId })
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
mockGetStatus.setup(async (x) => x(moq.It.isAny(), mockRunId)).returns(
|
|
67
|
+
async () => ({ state: ExtractorState.Running })
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
const sut = new BulkExtractor(mockApiConfig, mockToastCallback, mockToastCallback);
|
|
71
|
+
await sut.runIModelExtraction(mockIModelId);
|
|
72
|
+
const result = await sut.getIModelState(mockIModelId, "", "");
|
|
73
|
+
assert.strictEqual(result, ExtractionStates.Running);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it("should return failed status for failed extraction", async () => {
|
|
77
|
+
mockRunExtraction.setup(async (x) => x(moq.It.isAny(), mockIModelId)).returns(
|
|
78
|
+
async () => ({ id: mockRunId })
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
mockGetStatus.setup(async (x) => x(moq.It.isAny(), mockRunId)).returns(
|
|
82
|
+
async () => ({ state: ExtractorState.Failed })
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
const sut = new BulkExtractor(mockApiConfig, mockToastCallback, mockToastCallback);
|
|
86
|
+
await sut.runIModelExtraction(mockIModelId);
|
|
87
|
+
const result = await sut.getIModelState(mockIModelId, "", "");
|
|
88
|
+
assert.strictEqual(result, ExtractionStates.Failed);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it("full status check cycle", async () => {
|
|
92
|
+
mockRunExtraction.setup(async (x) => x(moq.It.isAny(), mockIModelId)).returns(
|
|
93
|
+
async () => ({ id: mockRunId })
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
mockGetStatus.setup(async (x) => x(moq.It.isAny(), mockRunId)).returns(
|
|
97
|
+
async () => ({ state: ExtractorState.Queued })
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
mockGetStatus.setup(async (x) => x(moq.It.isAny(), mockRunId)).returns(
|
|
101
|
+
async () => ({ state: ExtractorState.Running })
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
mockGetStatus.setup(async (x) => x(moq.It.isAny(), mockRunId)).returns(
|
|
105
|
+
async () => ({ state: ExtractorState.Succeeded })
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
const sut = new BulkExtractor(mockApiConfig, mockToastCallback, mockToastCallback);
|
|
109
|
+
await sut.runIModelExtraction(mockIModelId);
|
|
110
|
+
|
|
111
|
+
let result = await sut.getIModelState(mockIModelId, "", "");
|
|
112
|
+
assert.strictEqual(result, ExtractionStates.Queued);
|
|
113
|
+
|
|
114
|
+
result = await sut.getIModelState(mockIModelId, "", "");
|
|
115
|
+
assert.strictEqual(result, ExtractionStates.Running);
|
|
116
|
+
|
|
117
|
+
result = await sut.getIModelState(mockIModelId, "", "");
|
|
118
|
+
assert.strictEqual(result, ExtractionStates.Succeeded);
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it("two started jobs should return status", async () => {
|
|
122
|
+
const mockIModelIds = [mockIModelId, mockIModelId1];
|
|
123
|
+
|
|
124
|
+
mockRunExtraction.setup(async (x) => x(moq.It.isAny(), mockIModelId)).returns(
|
|
125
|
+
async () => ({ id: mockRunId })
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
mockRunExtraction.setup(async (x) => x(moq.It.isAny(), mockIModelId1)).returns(
|
|
129
|
+
async () => ({ id: mockRunId1 })
|
|
130
|
+
);
|
|
131
|
+
|
|
132
|
+
mockGetStatus.setup(async (x) => x(moq.It.isAny(), mockRunId)).returns(
|
|
133
|
+
async () => ({ state: ExtractorState.Queued })
|
|
134
|
+
);
|
|
135
|
+
|
|
136
|
+
mockGetStatus.setup(async (x) => x(moq.It.isAny(), mockRunId1)).returns(
|
|
137
|
+
async () => ({ state: ExtractorState.Queued })
|
|
138
|
+
);
|
|
139
|
+
|
|
140
|
+
const sut = new BulkExtractor(mockApiConfig, mockToastCallback, mockToastCallback);
|
|
141
|
+
|
|
142
|
+
await sut.runIModelExtractions(mockIModelIds);
|
|
143
|
+
|
|
144
|
+
const result1 = await sut.getIModelState(mockIModelId, "", "");
|
|
145
|
+
const result2 = await sut.getIModelState(mockIModelId1, "", "");
|
|
146
|
+
|
|
147
|
+
assert.strictEqual(result1, ExtractionStates.Queued);
|
|
148
|
+
assert.strictEqual(result2, ExtractionStates.Queued);
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
it("should return status none for unknown report", async () => {
|
|
152
|
+
const sut = new BulkExtractor(mockApiConfig, mockToastCallback, mockToastCallback);
|
|
153
|
+
const result = await sut.getReportState(mockReportId);
|
|
154
|
+
assert.strictEqual(result, ExtractionStates.None);
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
it("should return status running for running report", async () => {
|
|
158
|
+
mockRunExtraction.setup(async (x) => x(moq.It.isAny(), mockIModelId)).returns(
|
|
159
|
+
async () => ({ id: mockRunId })
|
|
160
|
+
);
|
|
161
|
+
|
|
162
|
+
mockGetStatus.setup(async (x) => x(moq.It.isAny(), mockRunId)).returns(
|
|
163
|
+
async () => ({ state: ExtractorState.Running })
|
|
164
|
+
);
|
|
165
|
+
|
|
166
|
+
mockGetReportMappings.setup(async (x) => x(moq.It.isAny(), mockReportId)).returns(
|
|
167
|
+
async () => ([{ imodelId: mockIModelId }])
|
|
168
|
+
);
|
|
169
|
+
|
|
170
|
+
const sut = new BulkExtractor(mockApiConfig, mockToastCallback, mockToastCallback);
|
|
171
|
+
|
|
172
|
+
await sut.runReportExtractions([mockReportId]);
|
|
173
|
+
|
|
174
|
+
const result = await sut.getReportState(mockReportId);
|
|
175
|
+
assert.strictEqual(result, ExtractionStates.Running);
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
it("should return status running for both iModels in report", async () => {
|
|
179
|
+
mockRunExtraction.setup(async (x) => x(moq.It.isAny(), mockIModelId)).returns(
|
|
180
|
+
async () => ({ id: mockRunId })
|
|
181
|
+
);
|
|
182
|
+
|
|
183
|
+
mockRunExtraction.setup(async (x) => x(moq.It.isAny(), mockIModelId1)).returns(
|
|
184
|
+
async () => ({ id: mockRunId1 })
|
|
185
|
+
);
|
|
186
|
+
|
|
187
|
+
mockGetStatus.setup(async (x) => x(moq.It.isAny(), mockRunId)).returns(
|
|
188
|
+
async () => ({ state: ExtractorState.Running })
|
|
189
|
+
);
|
|
190
|
+
|
|
191
|
+
mockGetStatus.setup(async (x) => x(moq.It.isAny(), mockRunId1)).returns(
|
|
192
|
+
async () => ({ state: ExtractorState.Running })
|
|
193
|
+
);
|
|
194
|
+
|
|
195
|
+
mockGetReportMappings.setup(async (x) => x(moq.It.isAny(), mockReportId)).returns(
|
|
196
|
+
async () => ([{ imodelId: mockIModelId }, { imodelId: mockIModelId1 }])
|
|
197
|
+
);
|
|
198
|
+
|
|
199
|
+
const sut = new BulkExtractor(mockApiConfig, mockToastCallback, mockToastCallback);
|
|
200
|
+
|
|
201
|
+
await sut.runReportExtractions([mockReportId]);
|
|
202
|
+
|
|
203
|
+
const result1 = await sut.getIModelState(mockIModelId, "", "");
|
|
204
|
+
const result2 = await sut.getIModelState(mockIModelId1, "", "");
|
|
205
|
+
|
|
206
|
+
assert.strictEqual(result1, ExtractionStates.Running);
|
|
207
|
+
assert.strictEqual(result2, ExtractionStates.Running);
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
it("should return lowest progress status for extractions in report", async () => {
|
|
211
|
+
mockRunExtraction.setup(async (x) => x(moq.It.isAny(), mockIModelId)).returns(
|
|
212
|
+
async () => ({ id: mockRunId })
|
|
213
|
+
);
|
|
214
|
+
|
|
215
|
+
mockRunExtraction.setup(async (x) => x(moq.It.isAny(), mockIModelId1)).returns(
|
|
216
|
+
async () => ({ id: mockRunId1 })
|
|
217
|
+
);
|
|
218
|
+
|
|
219
|
+
mockGetStatus.setup(async (x) => x(moq.It.isAny(), mockRunId)).returns(
|
|
220
|
+
async () => ({ state: ExtractorState.Running })
|
|
221
|
+
);
|
|
222
|
+
|
|
223
|
+
mockGetStatus.setup(async (x) => x(moq.It.isAny(), mockRunId1)).returns(
|
|
224
|
+
async () => ({ state: ExtractorState.Queued })
|
|
225
|
+
);
|
|
226
|
+
|
|
227
|
+
mockGetReportMappings.setup(async (x) => x(moq.It.isAny(), mockReportId)).returns(
|
|
228
|
+
async () => ([{ imodelId: mockIModelId }, { imodelId: mockIModelId1 }])
|
|
229
|
+
);
|
|
230
|
+
|
|
231
|
+
const sut = new BulkExtractor(mockApiConfig, mockToastCallback, mockToastCallback);
|
|
232
|
+
|
|
233
|
+
await sut.runReportExtractions([mockReportId]);
|
|
234
|
+
|
|
235
|
+
const result = await sut.getReportState(mockReportId);
|
|
236
|
+
assert.strictEqual(result, ExtractionStates.Queued);
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
it("should return status failed if one of the extractions in report failed", async () => {
|
|
240
|
+
mockRunExtraction.setup(async (x) => x(moq.It.isAny(), mockIModelId)).returns(
|
|
241
|
+
async () => ({ id: mockRunId })
|
|
242
|
+
);
|
|
243
|
+
|
|
244
|
+
mockRunExtraction.setup(async (x) => x(moq.It.isAny(), mockIModelId1)).returns(
|
|
245
|
+
async () => ({ id: mockRunId1 })
|
|
246
|
+
);
|
|
247
|
+
|
|
248
|
+
mockGetStatus.setup(async (x) => x(moq.It.isAny(), mockRunId)).returns(
|
|
249
|
+
async () => ({ state: ExtractorState.Succeeded })
|
|
250
|
+
);
|
|
251
|
+
|
|
252
|
+
mockGetStatus.setup(async (x) => x(moq.It.isAny(), mockRunId1)).returns(
|
|
253
|
+
async () => ({ state: ExtractorState.Failed })
|
|
254
|
+
);
|
|
255
|
+
|
|
256
|
+
mockGetReportMappings.setup(async (x) => x(moq.It.isAny(), mockReportId)).returns(
|
|
257
|
+
async () => ([{ imodelId: mockIModelId1 }, { imodelId: mockIModelId1 }])
|
|
258
|
+
);
|
|
259
|
+
|
|
260
|
+
const sut = new BulkExtractor(mockApiConfig, mockToastCallback, mockToastCallback);
|
|
261
|
+
|
|
262
|
+
await sut.runReportExtractions([mockReportId]);
|
|
263
|
+
|
|
264
|
+
const result = await sut.getReportState(mockReportId);
|
|
265
|
+
assert.strictEqual(result, ExtractionStates.Failed);
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
it("full report extraction status check cycle", async () => {
|
|
269
|
+
mockRunExtraction.setup(async (x) => x(moq.It.isAny(), mockIModelId)).returns(
|
|
270
|
+
async () => ({ id: mockRunId })
|
|
271
|
+
);
|
|
272
|
+
|
|
273
|
+
mockGetStatus.setup(async (x) => x(moq.It.isAny(), mockRunId)).returns(
|
|
274
|
+
async () => ({ state: ExtractorState.Queued })
|
|
275
|
+
);
|
|
276
|
+
|
|
277
|
+
mockGetStatus.setup(async (x) => x(moq.It.isAny(), mockRunId)).returns(
|
|
278
|
+
async () => ({ state: ExtractorState.Running })
|
|
279
|
+
);
|
|
280
|
+
|
|
281
|
+
mockGetStatus.setup(async (x) => x(moq.It.isAny(), mockRunId)).returns(
|
|
282
|
+
async () => ({ state: ExtractorState.Succeeded })
|
|
283
|
+
);
|
|
284
|
+
|
|
285
|
+
mockGetReportMappings.setup(async (x) => x(moq.It.isAny(), mockReportId)).returns(
|
|
286
|
+
async () => ([{ imodelId: mockIModelId }])
|
|
287
|
+
);
|
|
288
|
+
|
|
289
|
+
const sut = new BulkExtractor(mockApiConfig, mockToastCallback, mockToastCallback);
|
|
290
|
+
await sut.runReportExtractions([mockReportId]);
|
|
291
|
+
|
|
292
|
+
let result = await sut.getReportState(mockReportId);
|
|
293
|
+
assert.strictEqual(result, ExtractionStates.Queued);
|
|
294
|
+
|
|
295
|
+
result = await sut.getReportState(mockReportId);
|
|
296
|
+
assert.strictEqual(result, ExtractionStates.Running);
|
|
297
|
+
|
|
298
|
+
result = await sut.getReportState(mockReportId);
|
|
299
|
+
assert.strictEqual(result, ExtractionStates.Succeeded);
|
|
300
|
+
});
|
|
301
|
+
});
|
|
@@ -0,0 +1,118 @@
|
|
|
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 {
|
|
15
|
+
render,
|
|
16
|
+
screen,
|
|
17
|
+
TestUtils,
|
|
18
|
+
} from "./test-utils";
|
|
19
|
+
import * as moq from "typemoq";
|
|
20
|
+
import type {
|
|
21
|
+
SelectionManager,
|
|
22
|
+
SelectionScopesManager,
|
|
23
|
+
} from "@itwin/presentation-frontend";
|
|
24
|
+
import {
|
|
25
|
+
Presentation,
|
|
26
|
+
SelectionChangeEvent,
|
|
27
|
+
} from "@itwin/presentation-frontend";
|
|
28
|
+
import type { BeEvent } from "@itwin/core-bentley";
|
|
29
|
+
import DeleteModal from "../widget/components/DeleteModal";
|
|
30
|
+
import { ReportsConfigWidget } from "../ReportsConfigWidget";
|
|
31
|
+
import { EmptyLocalization } from "@itwin/core-common";
|
|
32
|
+
|
|
33
|
+
const mockITwinId = faker.datatype.uuid();
|
|
34
|
+
const mockIModelId1 = faker.datatype.uuid();
|
|
35
|
+
|
|
36
|
+
const connectionMock = moq.Mock.ofType<IModelConnection>();
|
|
37
|
+
const selectionManagerMock = moq.Mock.ofType<SelectionManager>();
|
|
38
|
+
const selectionScopesManagerMock = moq.Mock.ofType<SelectionScopesManager>();
|
|
39
|
+
|
|
40
|
+
beforeAll(async () => {
|
|
41
|
+
await NoRenderApp.startup({localization: new EmptyLocalization()});
|
|
42
|
+
await Presentation.initialize();
|
|
43
|
+
const selectionSet = moq.Mock.ofType<SelectionSet>();
|
|
44
|
+
const onChanged = moq.Mock.ofType<BeEvent<(ev: SelectionSetEvent) => void>>();
|
|
45
|
+
selectionSet.setup((x) => x.elements).returns(() => new Set([]));
|
|
46
|
+
selectionSet.setup((x) => x.onChanged).returns(() => onChanged.object);
|
|
47
|
+
connectionMock
|
|
48
|
+
.setup((x) => x.selectionSet)
|
|
49
|
+
.returns(() => selectionSet.object);
|
|
50
|
+
connectionMock.setup((x) => x.iModelId).returns(() => mockIModelId1);
|
|
51
|
+
connectionMock.setup((x) => x.iTwinId).returns(() => mockITwinId);
|
|
52
|
+
|
|
53
|
+
selectionManagerMock
|
|
54
|
+
.setup((x) => x.selectionChange)
|
|
55
|
+
.returns(() => new SelectionChangeEvent());
|
|
56
|
+
|
|
57
|
+
selectionScopesManagerMock
|
|
58
|
+
.setup(async (x) => x.getSelectionScopes(connectionMock.object))
|
|
59
|
+
.returns(async () => []);
|
|
60
|
+
selectionManagerMock
|
|
61
|
+
.setup((x) => x.scopes)
|
|
62
|
+
.returns(() => selectionScopesManagerMock.object);
|
|
63
|
+
|
|
64
|
+
Presentation.setSelectionManager(selectionManagerMock.object);
|
|
65
|
+
await TestUtils.initializeUiFramework(connectionMock.object);
|
|
66
|
+
await ReportsConfigWidget.initialize();
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
describe("Delete modal", () => {
|
|
70
|
+
it("should render", () => {
|
|
71
|
+
const { container } = render(
|
|
72
|
+
<DeleteModal
|
|
73
|
+
entityName="test"
|
|
74
|
+
show={true}
|
|
75
|
+
setShow={jest.fn()}
|
|
76
|
+
onDelete={jest.fn()}
|
|
77
|
+
refresh={jest.fn()}
|
|
78
|
+
/>
|
|
79
|
+
);
|
|
80
|
+
expect(container).toBeTruthy();
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it("should call onDelete when delete button is clicked", async () => {
|
|
84
|
+
const onDelete = jest.fn();
|
|
85
|
+
const { user } = render(
|
|
86
|
+
<DeleteModal
|
|
87
|
+
entityName="test"
|
|
88
|
+
show={true}
|
|
89
|
+
setShow={jest.fn()}
|
|
90
|
+
onDelete={onDelete}
|
|
91
|
+
refresh={jest.fn()}
|
|
92
|
+
/>
|
|
93
|
+
);
|
|
94
|
+
const deleteButton = screen.getByRole("button", {
|
|
95
|
+
name: /delete/i,
|
|
96
|
+
});
|
|
97
|
+
await user.click(deleteButton);
|
|
98
|
+
expect(onDelete).toHaveBeenCalled();
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
it("should call setShow when cancel button is clicked", async () => {
|
|
102
|
+
const setShow = jest.fn();
|
|
103
|
+
const { user } = render(
|
|
104
|
+
<DeleteModal
|
|
105
|
+
entityName="test"
|
|
106
|
+
show={true}
|
|
107
|
+
setShow={setShow}
|
|
108
|
+
onDelete={jest.fn()}
|
|
109
|
+
refresh={jest.fn()}
|
|
110
|
+
/>
|
|
111
|
+
);
|
|
112
|
+
const cancelButton = screen.getByRole("button", {
|
|
113
|
+
name: /cancel/i,
|
|
114
|
+
});
|
|
115
|
+
await user.click(cancelButton);
|
|
116
|
+
expect(setShow).toHaveBeenCalled();
|
|
117
|
+
});
|
|
118
|
+
});
|
|
@@ -34,6 +34,7 @@ import {
|
|
|
34
34
|
SelectionChangeEvent,
|
|
35
35
|
} from "@itwin/presentation-frontend";
|
|
36
36
|
import type { BeEvent } from "@itwin/core-bentley";
|
|
37
|
+
import { EmptyLocalization } from "@itwin/core-common";
|
|
37
38
|
|
|
38
39
|
const mockITwinId = faker.datatype.uuid();
|
|
39
40
|
const mockIModelId = faker.datatype.uuid();
|
|
@@ -54,10 +55,7 @@ jest.mock("@itwin/appui-react", () => ({
|
|
|
54
55
|
const server = setupServer();
|
|
55
56
|
|
|
56
57
|
beforeAll(async () => {
|
|
57
|
-
|
|
58
|
-
(global as any).XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest; // eslint-disable-line @typescript-eslint/no-var-requires
|
|
59
|
-
|
|
60
|
-
await NoRenderApp.startup();
|
|
58
|
+
await NoRenderApp.startup({localization: new EmptyLocalization()});
|
|
61
59
|
await Presentation.initialize();
|
|
62
60
|
const selectionSet = moq.Mock.ofType<SelectionSet>();
|
|
63
61
|
const onChanged = moq.Mock.ofType<BeEvent<(ev: SelectionSetEvent) => void>>();
|