@itwin/grouping-mapping-widget 0.6.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/README.md +84 -0
  2. package/lib/cjs/grouping-mapping-widget.d.ts +1 -0
  3. package/lib/cjs/grouping-mapping-widget.js +3 -1
  4. package/lib/cjs/grouping-mapping-widget.js.map +1 -1
  5. package/lib/cjs/test/GroupingMappingCustomUI.test.d.ts +2 -0
  6. package/lib/cjs/test/GroupingMappingCustomUI.test.js +162 -0
  7. package/lib/cjs/test/GroupingMappingCustomUI.test.js.map +1 -0
  8. package/lib/cjs/test/WidgetHeader.test.d.ts +2 -0
  9. package/lib/cjs/test/WidgetHeader.test.js +36 -0
  10. package/lib/cjs/test/WidgetHeader.test.js.map +1 -0
  11. package/lib/cjs/test/test-utils.d.ts +72 -0
  12. package/lib/cjs/test/test-utils.js +71 -0
  13. package/lib/cjs/test/test-utils.js.map +1 -0
  14. package/lib/cjs/widget/components/GroupAction.d.ts +2 -1
  15. package/lib/cjs/widget/components/GroupAction.js +82 -75
  16. package/lib/cjs/widget/components/GroupAction.js.map +1 -1
  17. package/lib/cjs/widget/components/GroupAction.scss +1 -13
  18. package/lib/cjs/widget/components/GroupPropertyAction.d.ts +1 -1
  19. package/lib/cjs/widget/components/GroupPropertyAction.js +149 -302
  20. package/lib/cjs/widget/components/GroupPropertyAction.js.map +1 -1
  21. package/lib/cjs/widget/components/GroupPropertyAction.scss +82 -8
  22. package/lib/cjs/widget/components/GroupPropertyUtils.d.ts +21 -0
  23. package/lib/cjs/widget/components/GroupPropertyUtils.js +287 -0
  24. package/lib/cjs/widget/components/GroupPropertyUtils.js.map +1 -0
  25. package/lib/cjs/widget/components/Grouping.d.ts +5 -0
  26. package/lib/cjs/widget/components/Grouping.js +107 -44
  27. package/lib/cjs/widget/components/Grouping.js.map +1 -1
  28. package/lib/cjs/widget/components/Grouping.scss +18 -3
  29. package/lib/cjs/widget/components/GroupingMapping.d.ts +6 -1
  30. package/lib/cjs/widget/components/GroupingMapping.js +22 -9
  31. package/lib/cjs/widget/components/GroupingMapping.js.map +1 -1
  32. package/lib/cjs/widget/components/HorizontalTile.d.ts +5 -3
  33. package/lib/cjs/widget/components/HorizontalTile.js +9 -6
  34. package/lib/cjs/widget/components/HorizontalTile.js.map +1 -1
  35. package/lib/cjs/widget/components/HorizontalTile.scss +46 -22
  36. package/lib/cjs/widget/components/Mapping.scss +4 -5
  37. package/lib/cjs/widget/components/SelectProject.js +2 -0
  38. package/lib/cjs/widget/components/SelectProject.js.map +1 -1
  39. package/lib/cjs/widget/components/SortableHorizontalTile.d.ts +8 -0
  40. package/lib/cjs/widget/components/SortableHorizontalTile.js +51 -0
  41. package/lib/cjs/widget/components/SortableHorizontalTile.js.map +1 -0
  42. package/lib/cjs/widget/components/context/GroupingMappingCustomUIContext.d.ts +6 -0
  43. package/lib/cjs/widget/components/context/GroupingMappingCustomUIContext.js +25 -0
  44. package/lib/cjs/widget/components/context/GroupingMappingCustomUIContext.js.map +1 -0
  45. package/lib/cjs/widget/components/customUI/GroupingMappingCustomUI.d.ts +91 -0
  46. package/lib/cjs/widget/components/customUI/GroupingMappingCustomUI.js +9 -0
  47. package/lib/cjs/widget/components/customUI/GroupingMappingCustomUI.js.map +1 -0
  48. package/lib/cjs/widget/components/customUI/ManualGroupingCustomUI.d.ts +6 -0
  49. package/lib/cjs/widget/components/customUI/ManualGroupingCustomUI.js +31 -0
  50. package/lib/cjs/widget/components/customUI/ManualGroupingCustomUI.js.map +1 -0
  51. package/lib/cjs/widget/components/customUI/ManualGroupingCustomUI.scss +17 -0
  52. package/lib/cjs/widget/components/customUI/SearchGroupingCustomUI.d.ts +6 -0
  53. package/lib/cjs/widget/components/customUI/SearchGroupingCustomUI.js +97 -0
  54. package/lib/cjs/widget/components/customUI/SearchGroupingCustomUI.js.map +1 -0
  55. package/lib/cjs/widget/components/customUI/SearchGroupingCustomUI.scss +17 -0
  56. package/lib/esm/grouping-mapping-widget.d.ts +1 -0
  57. package/lib/esm/grouping-mapping-widget.js +1 -0
  58. package/lib/esm/grouping-mapping-widget.js.map +1 -1
  59. package/lib/esm/test/GroupingMappingCustomUI.test.d.ts +2 -0
  60. package/lib/esm/test/GroupingMappingCustomUI.test.js +138 -0
  61. package/lib/esm/test/GroupingMappingCustomUI.test.js.map +1 -0
  62. package/lib/esm/test/WidgetHeader.test.d.ts +2 -0
  63. package/lib/esm/test/WidgetHeader.test.js +31 -0
  64. package/lib/esm/test/WidgetHeader.test.js.map +1 -0
  65. package/lib/esm/test/test-utils.d.ts +72 -0
  66. package/lib/esm/test/test-utils.js +42 -0
  67. package/lib/esm/test/test-utils.js.map +1 -0
  68. package/lib/esm/widget/components/GroupAction.d.ts +2 -1
  69. package/lib/esm/widget/components/GroupAction.js +85 -78
  70. package/lib/esm/widget/components/GroupAction.js.map +1 -1
  71. package/lib/esm/widget/components/GroupAction.scss +1 -13
  72. package/lib/esm/widget/components/GroupPropertyAction.d.ts +1 -1
  73. package/lib/esm/widget/components/GroupPropertyAction.js +151 -304
  74. package/lib/esm/widget/components/GroupPropertyAction.js.map +1 -1
  75. package/lib/esm/widget/components/GroupPropertyAction.scss +82 -8
  76. package/lib/esm/widget/components/GroupPropertyUtils.d.ts +21 -0
  77. package/lib/esm/widget/components/GroupPropertyUtils.js +280 -0
  78. package/lib/esm/widget/components/GroupPropertyUtils.js.map +1 -0
  79. package/lib/esm/widget/components/Grouping.d.ts +5 -0
  80. package/lib/esm/widget/components/Grouping.js +107 -44
  81. package/lib/esm/widget/components/Grouping.js.map +1 -1
  82. package/lib/esm/widget/components/Grouping.scss +18 -3
  83. package/lib/esm/widget/components/GroupingMapping.d.ts +6 -1
  84. package/lib/esm/widget/components/GroupingMapping.js +23 -10
  85. package/lib/esm/widget/components/GroupingMapping.js.map +1 -1
  86. package/lib/esm/widget/components/HorizontalTile.d.ts +5 -3
  87. package/lib/esm/widget/components/HorizontalTile.js +9 -6
  88. package/lib/esm/widget/components/HorizontalTile.js.map +1 -1
  89. package/lib/esm/widget/components/HorizontalTile.scss +46 -22
  90. package/lib/esm/widget/components/Mapping.scss +4 -5
  91. package/lib/esm/widget/components/SelectProject.js +2 -0
  92. package/lib/esm/widget/components/SelectProject.js.map +1 -1
  93. package/lib/esm/widget/components/SortableHorizontalTile.d.ts +8 -0
  94. package/lib/esm/widget/components/SortableHorizontalTile.js +30 -0
  95. package/lib/esm/widget/components/SortableHorizontalTile.js.map +1 -0
  96. package/lib/esm/widget/components/context/GroupingMappingCustomUIContext.d.ts +6 -0
  97. package/lib/esm/widget/components/context/GroupingMappingCustomUIContext.js +20 -0
  98. package/lib/esm/widget/components/context/GroupingMappingCustomUIContext.js.map +1 -0
  99. package/lib/esm/widget/components/customUI/GroupingMappingCustomUI.d.ts +91 -0
  100. package/lib/esm/widget/components/customUI/GroupingMappingCustomUI.js +6 -0
  101. package/lib/esm/widget/components/customUI/GroupingMappingCustomUI.js.map +1 -0
  102. package/lib/esm/widget/components/customUI/ManualGroupingCustomUI.d.ts +6 -0
  103. package/lib/esm/widget/components/customUI/ManualGroupingCustomUI.js +26 -0
  104. package/lib/esm/widget/components/customUI/ManualGroupingCustomUI.js.map +1 -0
  105. package/lib/esm/widget/components/customUI/ManualGroupingCustomUI.scss +17 -0
  106. package/lib/esm/widget/components/customUI/SearchGroupingCustomUI.d.ts +6 -0
  107. package/lib/esm/widget/components/customUI/SearchGroupingCustomUI.js +92 -0
  108. package/lib/esm/widget/components/customUI/SearchGroupingCustomUI.js.map +1 -0
  109. package/lib/esm/widget/components/customUI/SearchGroupingCustomUI.scss +17 -0
  110. package/package.json +24 -5
@@ -0,0 +1,17 @@
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 "~@itwin/itwinui-css/scss/variables";
6
+
7
+ .gmw-search-form {
8
+ display: flex;
9
+ flex-direction: column;
10
+ gap: $iui-baseline;
11
+ margin-top: $iui-baseline;
12
+ > .gmw-search-actions {
13
+ display: flex;
14
+ justify-content: flex-end;
15
+ gap: $iui-s;
16
+ }
17
+ }
@@ -12,4 +12,5 @@ export { PropertyMenu } from "./widget/components/PropertyMenu";
12
12
  export { resolveFormulaDataType } from "./formula/FormulaDataTypeResolver";
13
13
  export { DataType, PropertyMap } from "./formula/Types";
14
14
  export { IResult } from "./formula/IResult";
15
+ export { GroupingMappingCustomUI, GroupingMappingCustomUIType, ContextCustomUI, GroupingCustomUI, GroupingCustomUIProps, ContextCustomUIProps } from "./widget/components/customUI/GroupingMappingCustomUI";
15
16
  //# sourceMappingURL=grouping-mapping-widget.d.ts.map
@@ -13,4 +13,5 @@ export { Groupings } from "./widget/components/Grouping";
13
13
  export { PropertyMenu } from "./widget/components/PropertyMenu";
14
14
  /** Formula DataType resolver */
15
15
  export { resolveFormulaDataType } from "./formula/FormulaDataTypeResolver";
16
+ export { GroupingMappingCustomUIType } from "./widget/components/customUI/GroupingMappingCustomUI";
16
17
  //# sourceMappingURL=grouping-mapping-widget.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"grouping-mapping-widget.js","sourceRoot":"","sources":["../../src/grouping-mapping-widget.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,gDAAgD;AAChD,cAAc,gCAAgC,CAAC;AAE/C,0EAA0E;AAC1E,OAAO,EAAE,0BAA0B,EAAE,MAAM,kDAAkD,CAAC;AAE9F,cAAc,wBAAwB,CAAC;AAEvC,yCAAyC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAEhE,gCAAgC;AAChC,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,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*--------------------------------------------------------------------------------------------*/\n/** UI Provider for iTwin Viewer Applications */\nexport * from \"./widget/GroupingMappingWidget\";\n\n/** Interfaces for providing custom MappingClient and API configuration */\nexport { createDefaultMappingClient } from \"./widget/components/context/MappingClientContext\";\nexport { ClientPrefix, GetAccessTokenFn } from \"./widget/components/context/GroupingApiConfigContext\";\nexport * from \"@itwin/insights-client\";\n\n/** Internal components for custom UIs */\nexport { Mappings } from \"./widget/components/Mapping\";\nexport { Groupings } from \"./widget/components/Grouping\";\nexport { PropertyMenu } from \"./widget/components/PropertyMenu\";\n\n/** Formula DataType resolver */\nexport { resolveFormulaDataType } from \"./formula/FormulaDataTypeResolver\";\nexport { DataType, PropertyMap } from \"./formula/Types\";\nexport { IResult } from \"./formula/IResult\";\n"]}
1
+ {"version":3,"file":"grouping-mapping-widget.js","sourceRoot":"","sources":["../../src/grouping-mapping-widget.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,gDAAgD;AAChD,cAAc,gCAAgC,CAAC;AAE/C,0EAA0E;AAC1E,OAAO,EAAE,0BAA0B,EAAE,MAAM,kDAAkD,CAAC;AAE9F,cAAc,wBAAwB,CAAC;AAEvC,yCAAyC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAEhE,gCAAgC;AAChC,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAG3E,OAAO,EAA2B,2BAA2B,EAAkF,MAAM,sDAAsD,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*--------------------------------------------------------------------------------------------*/\n/** UI Provider for iTwin Viewer Applications */\nexport * from \"./widget/GroupingMappingWidget\";\n\n/** Interfaces for providing custom MappingClient and API configuration */\nexport { createDefaultMappingClient } from \"./widget/components/context/MappingClientContext\";\nexport { ClientPrefix, GetAccessTokenFn } from \"./widget/components/context/GroupingApiConfigContext\";\nexport * from \"@itwin/insights-client\";\n\n/** Internal components for custom UIs */\nexport { Mappings } from \"./widget/components/Mapping\";\nexport { Groupings } from \"./widget/components/Grouping\";\nexport { PropertyMenu } from \"./widget/components/PropertyMenu\";\n\n/** Formula DataType resolver */\nexport { resolveFormulaDataType } from \"./formula/FormulaDataTypeResolver\";\nexport { DataType, PropertyMap } from \"./formula/Types\";\nexport { IResult } from \"./formula/IResult\";\nexport { GroupingMappingCustomUI, GroupingMappingCustomUIType, ContextCustomUI, GroupingCustomUI, GroupingCustomUIProps, ContextCustomUIProps } from \"./widget/components/customUI/GroupingMappingCustomUI\";\n"]}
@@ -0,0 +1,2 @@
1
+ import "@testing-library/jest-dom";
2
+ //# sourceMappingURL=GroupingMappingCustomUI.test.d.ts.map
@@ -0,0 +1,138 @@
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 "@testing-library/jest-dom";
7
+ import { mockAccessToken, mockMappingClient, render, screen, TestUtils, waitForElementToBeRemoved, within } from "./test-utils";
8
+ import { faker } from "@faker-js/faker";
9
+ import { Groupings } from "../grouping-mapping-widget";
10
+ import * as moq from "typemoq";
11
+ import { NoRenderApp } from "@itwin/core-frontend";
12
+ import { Presentation, SelectionChangeEvent } from "@itwin/presentation-frontend";
13
+ import { EmptyLocalization } from "@itwin/core-common";
14
+ const mockITwinId = faker.datatype.uuid();
15
+ const mockIModelId = faker.datatype.uuid();
16
+ const mockMappingId = faker.datatype.uuid();
17
+ const mockMapping = {
18
+ id: mockMappingId,
19
+ mappingName: "mOcKmApPiNg1",
20
+ description: "mOcKmApPiNgDeScRiPtIoN1",
21
+ createdBy: faker.random.alpha(),
22
+ createdOn: faker.date.past().toDateString(),
23
+ modifiedBy: faker.random.alpha(),
24
+ modifiedOn: faker.date.past().toDateString(),
25
+ extractionEnabled: false,
26
+ _links: {
27
+ imodel: {
28
+ href: "",
29
+ },
30
+ },
31
+ };
32
+ const groupsFactory = () => ({
33
+ groups: Array.from({ length: faker.datatype.number({ min: 3, max: 5 }) }, (_, index) => ({
34
+ id: `${faker.datatype.uuid()}`,
35
+ groupName: `mOcKgRoUp${index}`,
36
+ description: `mOcKgRoUpDeScRiPtIoN${index}`,
37
+ query: `mOcKgRoUpQuErY${index}`,
38
+ _links: {
39
+ imodel: {
40
+ href: "",
41
+ },
42
+ mapping: {
43
+ href: "",
44
+ },
45
+ },
46
+ })),
47
+ _links: {
48
+ next: undefined,
49
+ self: {
50
+ href: "",
51
+ },
52
+ },
53
+ });
54
+ const connectionMock = moq.Mock.ofType();
55
+ const selectionManagerMock = moq.Mock.ofType();
56
+ const selectionScopesManagerMock = moq.Mock.ofType();
57
+ jest.mock("@itwin/appui-react", () => ({
58
+ ...jest.requireActual("@itwin/appui-react"),
59
+ useActiveIModelConnection: () => connectionMock.object,
60
+ }));
61
+ beforeAll(async () => {
62
+ await NoRenderApp.startup({ localization: new EmptyLocalization() });
63
+ await Presentation.initialize();
64
+ const selectionSet = moq.Mock.ofType();
65
+ const onChanged = moq.Mock.ofType();
66
+ selectionSet.setup((x) => x.elements).returns(() => new Set([]));
67
+ selectionSet.setup((x) => x.onChanged).returns(() => onChanged.object);
68
+ connectionMock
69
+ .setup((x) => x.selectionSet)
70
+ .returns(() => selectionSet.object);
71
+ connectionMock.setup((x) => x.iModelId).returns(() => mockIModelId);
72
+ connectionMock.setup((x) => x.iTwinId).returns(() => mockITwinId);
73
+ selectionManagerMock
74
+ .setup((x) => x.selectionChange)
75
+ .returns(() => new SelectionChangeEvent());
76
+ selectionScopesManagerMock
77
+ .setup(async (x) => x.getSelectionScopes(connectionMock.object))
78
+ .returns(async () => []);
79
+ selectionManagerMock
80
+ .setup((x) => x.scopes)
81
+ .returns(() => selectionScopesManagerMock.object);
82
+ Presentation.setSelectionManager(selectionManagerMock.object);
83
+ await TestUtils.initializeUiFramework(connectionMock.object);
84
+ });
85
+ describe("Groupings View with default UIs", () => {
86
+ it("List all groups and click on add group and edit group buttons", async () => {
87
+ // Arange
88
+ const mockGroups = groupsFactory();
89
+ const mockedAccessToken = await mockAccessToken();
90
+ mockMappingClient
91
+ .setup(async (x) => x.getGroups(mockedAccessToken, mockIModelId, mockMappingId))
92
+ .returns(async () => mockGroups.groups);
93
+ // Act
94
+ const { user } = render(React.createElement(Groupings, { mapping: mockMapping, goBack: jest.fn() }));
95
+ await waitForElementToBeRemoved(() => screen.getByText(/loading/i));
96
+ // Assert
97
+ const addButton = screen.getAllByTestId("gmw-add-group-button");
98
+ expect(addButton).toHaveLength(1);
99
+ // Click on 'Add Group' button
100
+ await user.click(addButton[0]);
101
+ // Should have three menu items
102
+ const addSelection = screen.getAllByTestId("gmw-add-0");
103
+ expect(addSelection).toHaveLength(1);
104
+ const addSearch = screen.getAllByTestId("gmw-add-1");
105
+ expect(addSearch).toHaveLength(1);
106
+ const addManual = screen.getAllByTestId("gmw-add-2");
107
+ expect(addManual).toHaveLength(1);
108
+ // Should have the right group number
109
+ const horizontalTiles = screen.getAllByTestId("gmw-horizontal-tile");
110
+ expect(horizontalTiles).toHaveLength(mockGroups.groups.length);
111
+ horizontalTiles.forEach((horizontalTile, index) => {
112
+ var _a;
113
+ const groupTile = within(horizontalTile);
114
+ expect(groupTile.getByText(mockGroups.groups[index].groupName)).toBeInTheDocument();
115
+ expect(groupTile.getByText((_a = mockGroups.groups[index].description) !== null && _a !== void 0 ? _a : "")).toBeInTheDocument();
116
+ });
117
+ // Click on first group more icon
118
+ const moreButton = screen.getAllByTestId("gmw-more-button");
119
+ expect(moreButton).toHaveLength(mockGroups.groups.length);
120
+ await user.click(moreButton[0]);
121
+ // Should have 3 context menu items
122
+ const contextMenuItems = screen.getAllByTestId("gmw-context-menu-item");
123
+ expect(contextMenuItems).toHaveLength(3);
124
+ expect(contextMenuItems[0]).toHaveTextContent("Edit");
125
+ expect(contextMenuItems[1]).toHaveTextContent("Properties");
126
+ expect(contextMenuItems[2]).toHaveTextContent("Remove");
127
+ // Hover on 'Edit'
128
+ await user.hover(contextMenuItems[0]);
129
+ // Should have 3 sub menu items
130
+ const editSelection = screen.getAllByTestId(`gmw-edit-0`);
131
+ expect(editSelection).toHaveLength(1);
132
+ const editSearch = screen.getAllByTestId(`gmw-edit-1`);
133
+ expect(editSearch).toHaveLength(1);
134
+ const editManual = screen.getAllByTestId(`gmw-edit-2`);
135
+ expect(editManual).toHaveLength(1);
136
+ });
137
+ });
138
+ //# sourceMappingURL=GroupingMappingCustomUI.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GroupingMappingCustomUI.test.js","sourceRoot":"","sources":["../../../src/test/GroupingMappingCustomUI.test.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,2BAA2B,CAAC;AACnC,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,yBAAyB,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAChI,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAEvD,OAAO,KAAK,GAAG,MAAM,SAAS,CAAC;AAE/B,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAElF,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAEvD,MAAM,WAAW,GAAG,KAAK,CAAC,QAAQ,CA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CAAC,YAAY,CAAC,CAAC;QAC1D,MAAM,CAAC,aAAa,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;QACtC,MAAM,UAAU,GAAG,MAAM,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC;QACvD,MAAM,CAAC,UAAU,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;QACnC,MAAM,UAAU,GAAG,MAAM,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC;QACvD,MAAM,CAAC,UAAU,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IACrC,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 \"@testing-library/jest-dom\";\nimport { mockAccessToken, mockMappingClient, render, screen, TestUtils, waitForElementToBeRemoved, within } from \"./test-utils\";\nimport { faker } from \"@faker-js/faker\";\nimport { Groupings } from \"../grouping-mapping-widget\";\nimport type { GroupCollection, Mapping} from \"@itwin/insights-client\";\nimport * as moq from \"typemoq\";\nimport type { IModelConnection, SelectionSet, SelectionSetEvent} from \"@itwin/core-frontend\";\nimport { NoRenderApp } from \"@itwin/core-frontend\";\nimport type { SelectionManager, SelectionScopesManager } from \"@itwin/presentation-frontend\";\nimport { Presentation, SelectionChangeEvent } from \"@itwin/presentation-frontend\";\nimport type { BeEvent } from \"@itwin/core-bentley\";\nimport { EmptyLocalization } from \"@itwin/core-common\";\n\nconst mockITwinId = faker.datatype.uuid();\nconst mockIModelId = faker.datatype.uuid();\nconst mockMappingId = faker.datatype.uuid();\nconst mockMapping: Mapping = {\n id: mockMappingId,\n mappingName: \"mOcKmApPiNg1\",\n description: \"mOcKmApPiNgDeScRiPtIoN1\",\n createdBy: faker.random.alpha(),\n createdOn: faker.date.past().toDateString(),\n modifiedBy: faker.random.alpha(),\n modifiedOn: faker.date.past().toDateString(),\n extractionEnabled:false,\n _links: {\n imodel: {\n href: \"\",\n },\n },\n};\n\nconst groupsFactory = (): GroupCollection => ({\n groups: Array.from(\n { length: faker.datatype.number({ min: 3, max: 5 }) },\n (_, index) => ({\n id: `${faker.datatype.uuid()}`,\n groupName: `mOcKgRoUp${index}`,\n description: `mOcKgRoUpDeScRiPtIoN${index}`,\n query: `mOcKgRoUpQuErY${index}`,\n _links: {\n imodel: {\n href: \"\",\n },\n mapping: {\n href: \"\",\n },\n },\n })\n ),\n _links: {\n next: undefined,\n self: {\n href: \"\",\n },\n },\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\nbeforeAll(async () => {\n await NoRenderApp.startup({localization: new EmptyLocalization()});\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(() => mockIModelId);\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});\n\ndescribe(\"Groupings View with default UIs\", () => {\n it(\"List all groups and click on add group and edit group buttons\", async () => {\n // Arange\n const mockGroups = groupsFactory();\n const mockedAccessToken = await mockAccessToken();\n mockMappingClient\n .setup(async (x) => x.getGroups(mockedAccessToken, mockIModelId, mockMappingId))\n .returns(async () => mockGroups.groups);\n\n // Act\n const { user } = render(<Groupings mapping={mockMapping} goBack={jest.fn()} />);\n await waitForElementToBeRemoved(() => screen.getByText(/loading/i));\n\n // Assert\n const addButton = screen.getAllByTestId(\"gmw-add-group-button\");\n expect(addButton).toHaveLength(1);\n\n // Click on 'Add Group' button\n await user.click(addButton[0]);\n\n // Should have three menu items\n const addSelection = screen.getAllByTestId(\"gmw-add-0\");\n expect(addSelection).toHaveLength(1);\n const addSearch = screen.getAllByTestId(\"gmw-add-1\");\n expect(addSearch).toHaveLength(1);\n const addManual = screen.getAllByTestId(\"gmw-add-2\");\n expect(addManual).toHaveLength(1);\n\n // Should have the right group number\n const horizontalTiles = screen.getAllByTestId(\"gmw-horizontal-tile\");\n expect(horizontalTiles).toHaveLength(mockGroups.groups.length);\n\n horizontalTiles.forEach((horizontalTile, index) => {\n const groupTile = within(horizontalTile);\n expect(\n groupTile.getByText(\n mockGroups.groups[index].groupName\n )\n ).toBeInTheDocument();\n expect(\n groupTile.getByText(\n mockGroups.groups[index].description ?? \"\"\n )\n ).toBeInTheDocument();\n });\n\n // Click on first group more icon\n const moreButton = screen.getAllByTestId(\"gmw-more-button\");\n expect(moreButton).toHaveLength(mockGroups.groups.length);\n\n await user.click(moreButton[0]);\n\n // Should have 3 context menu items\n const contextMenuItems = screen.getAllByTestId(\"gmw-context-menu-item\");\n expect(contextMenuItems).toHaveLength(3);\n expect(contextMenuItems[0]).toHaveTextContent(\"Edit\");\n expect(contextMenuItems[1]).toHaveTextContent(\"Properties\");\n expect(contextMenuItems[2]).toHaveTextContent(\"Remove\");\n\n // Hover on 'Edit'\n await user.hover(contextMenuItems[0]);\n\n // Should have 3 sub menu items\n const editSelection = screen.getAllByTestId(`gmw-edit-0`);\n expect(editSelection).toHaveLength(1);\n const editSearch = screen.getAllByTestId(`gmw-edit-1`);\n expect(editSearch).toHaveLength(1);\n const editManual = screen.getAllByTestId(`gmw-edit-2`);\n expect(editManual).toHaveLength(1);\n });\n});\n"]}
@@ -0,0 +1,2 @@
1
+ import "@testing-library/jest-dom";
2
+ //# sourceMappingURL=WidgetHeader.test.d.ts.map
@@ -0,0 +1,31 @@
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 "@testing-library/jest-dom";
7
+ import { render, screen } from "../test/test-utils";
8
+ import { WidgetHeader } from "../widget/components/utils";
9
+ import { faker } from "@faker-js/faker";
10
+ describe("Widget Header Component", () => {
11
+ it("title renders", async () => {
12
+ // Arrange
13
+ const fakeTitle = faker.word.interjection();
14
+ // Act
15
+ render(React.createElement(WidgetHeader, { title: fakeTitle }));
16
+ // Assert
17
+ const title = screen.getByText(fakeTitle);
18
+ expect(title).toHaveTextContent(fakeTitle);
19
+ });
20
+ it("header allows return callback", async () => {
21
+ // Arrange
22
+ const mockReturnFn = jest.fn();
23
+ // Act
24
+ const { user, container } = render(React.createElement(WidgetHeader, { title: "", returnFn: mockReturnFn }));
25
+ // Assert
26
+ const returnBtn = container.getElementsByClassName("gmw-chevron")[0];
27
+ await user.click(returnBtn);
28
+ expect(mockReturnFn).toHaveBeenCalledTimes(1);
29
+ });
30
+ });
31
+ //# sourceMappingURL=WidgetHeader.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WidgetHeader.test.js","sourceRoot":"","sources":["../../../src/test/WidgetHeader.test.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,2BAA2B,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAExC,QAAQ,CAAC,yBAAyB,EAAE,GAAG,EAAE;IACvC,EAAE,CAAC,eAAe,EAAE,KAAK,IAAI,EAAE;QAC7B,UAAU;QACV,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC;QAE5C,MAAM;QACN,MAAM,CAAC,oBAAC,YAAY,IAAC,KAAK,EAAE,SAAS,GAAI,CAAC,CAAC;QAE3C,SAAS;QACT,MAAM,KAAK,GAAG,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QAC1C,MAAM,CAAC,KAAK,CAAC,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC;IAC7C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,+BAA+B,EAAE,KAAK,IAAI,EAAE;QAC7C,UAAU;QACV,MAAM,YAAY,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;QAE/B,MAAM;QACN,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,MAAM,CAAC,oBAAC,YAAY,IAAC,KAAK,EAAC,EAAE,EAAC,QAAQ,EAAE,YAAY,GAAI,CAAC,CAAC;QAEtF,SAAS;QACT,MAAM,SAAS,GAAG,SAAS,CAAC,sBAAsB,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;QACrE,MAAM,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QAC5B,MAAM,CAAC,YAAY,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;IAChD,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 \"@testing-library/jest-dom\";\nimport { render, screen } from \"../test/test-utils\";\nimport { WidgetHeader } from \"../widget/components/utils\";\nimport { faker } from \"@faker-js/faker\";\n\ndescribe(\"Widget Header Component\", () => {\n it(\"title renders\", async () => {\n // Arrange\n const fakeTitle = faker.word.interjection();\n\n // Act\n render(<WidgetHeader title={fakeTitle} />);\n\n // Assert\n const title = screen.getByText(fakeTitle);\n expect(title).toHaveTextContent(fakeTitle);\n });\n\n it(\"header allows return callback\", async () => {\n // Arrange\n const mockReturnFn = jest.fn();\n\n // Act\n const { user, container } = render(<WidgetHeader title=\"\" returnFn={mockReturnFn} />);\n\n // Assert\n const returnBtn = container.getElementsByClassName(\"gmw-chevron\")[0];\n await user.click(returnBtn);\n expect(mockReturnFn).toHaveBeenCalledTimes(1);\n });\n});\n"]}
@@ -0,0 +1,72 @@
1
+ import * as React from "react";
2
+ import type { Store } from "redux";
3
+ import type { IModelConnection } from "@itwin/core-frontend";
4
+ import type { IMappingsClient } from "@itwin/insights-client";
5
+ import type { GroupingMappingCustomUI } from "../grouping-mapping-widget";
6
+ import * as moq from "typemoq";
7
+ export declare const mockAccessToken: () => Promise<string>;
8
+ export declare const mockMappingClient: moq.IMock<IMappingsClient>;
9
+ declare function render(ui: React.ReactElement, mockUIs?: GroupingMappingCustomUI[], { ...options }?: {}): {
10
+ container: HTMLElement;
11
+ baseElement: HTMLElement;
12
+ debug: (baseElement?: Element | DocumentFragment | (Element | DocumentFragment)[] | undefined, maxLength?: number | undefined, options?: any) => void;
13
+ rerender: (ui: React.ReactElement<any, string | React.JSXElementConstructor<any>>) => void;
14
+ unmount: () => void;
15
+ asFragment: () => DocumentFragment;
16
+ getByLabelText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").SelectorMatcherOptions | undefined) => HTMLElement;
17
+ getAllByLabelText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").SelectorMatcherOptions | undefined) => HTMLElement[];
18
+ queryByLabelText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").SelectorMatcherOptions | undefined) => HTMLElement | null;
19
+ queryAllByLabelText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").SelectorMatcherOptions | undefined) => HTMLElement[];
20
+ findByLabelText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").SelectorMatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react").waitForOptions | undefined) => Promise<HTMLElement>;
21
+ findAllByLabelText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").SelectorMatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react").waitForOptions | undefined) => Promise<HTMLElement[]>;
22
+ getByPlaceholderText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined) => HTMLElement;
23
+ getAllByPlaceholderText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined) => HTMLElement[];
24
+ queryByPlaceholderText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined) => HTMLElement | null;
25
+ queryAllByPlaceholderText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined) => HTMLElement[];
26
+ findByPlaceholderText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react").waitForOptions | undefined) => Promise<HTMLElement>;
27
+ findAllByPlaceholderText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react").waitForOptions | undefined) => Promise<HTMLElement[]>;
28
+ getByText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").SelectorMatcherOptions | undefined) => HTMLElement;
29
+ getAllByText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").SelectorMatcherOptions | undefined) => HTMLElement[];
30
+ queryByText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").SelectorMatcherOptions | undefined) => HTMLElement | null;
31
+ queryAllByText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").SelectorMatcherOptions | undefined) => HTMLElement[];
32
+ findByText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").SelectorMatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react").waitForOptions | undefined) => Promise<HTMLElement>;
33
+ findAllByText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").SelectorMatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react").waitForOptions | undefined) => Promise<HTMLElement[]>;
34
+ getByAltText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined) => HTMLElement;
35
+ getAllByAltText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined) => HTMLElement[];
36
+ queryByAltText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined) => HTMLElement | null;
37
+ queryAllByAltText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined) => HTMLElement[];
38
+ findByAltText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react").waitForOptions | undefined) => Promise<HTMLElement>;
39
+ findAllByAltText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react").waitForOptions | undefined) => Promise<HTMLElement[]>;
40
+ getByTitle: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined) => HTMLElement;
41
+ getAllByTitle: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined) => HTMLElement[];
42
+ queryByTitle: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined) => HTMLElement | null;
43
+ queryAllByTitle: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined) => HTMLElement[];
44
+ findByTitle: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react").waitForOptions | undefined) => Promise<HTMLElement>;
45
+ findAllByTitle: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react").waitForOptions | undefined) => Promise<HTMLElement[]>;
46
+ getByDisplayValue: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined) => HTMLElement;
47
+ getAllByDisplayValue: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined) => HTMLElement[];
48
+ queryByDisplayValue: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined) => HTMLElement | null;
49
+ queryAllByDisplayValue: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined) => HTMLElement[];
50
+ findByDisplayValue: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react").waitForOptions | undefined) => Promise<HTMLElement>;
51
+ findAllByDisplayValue: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react").waitForOptions | undefined) => Promise<HTMLElement[]>;
52
+ getByRole: (role: any, options?: import("@testing-library/react").ByRoleOptions | undefined) => HTMLElement;
53
+ getAllByRole: (role: any, options?: import("@testing-library/react").ByRoleOptions | undefined) => HTMLElement[];
54
+ queryByRole: (role: any, options?: import("@testing-library/react").ByRoleOptions | undefined) => HTMLElement | null;
55
+ queryAllByRole: (role: any, options?: import("@testing-library/react").ByRoleOptions | undefined) => HTMLElement[];
56
+ findByRole: (role: any, options?: import("@testing-library/react").ByRoleOptions | undefined, waitForElementOptions?: import("@testing-library/react").waitForOptions | undefined) => Promise<HTMLElement>;
57
+ findAllByRole: (role: any, options?: import("@testing-library/react").ByRoleOptions | undefined, waitForElementOptions?: import("@testing-library/react").waitForOptions | undefined) => Promise<HTMLElement[]>;
58
+ getByTestId: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined) => HTMLElement;
59
+ getAllByTestId: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined) => HTMLElement[];
60
+ queryByTestId: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined) => HTMLElement | null;
61
+ queryAllByTestId: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined) => HTMLElement[];
62
+ findByTestId: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react").waitForOptions | undefined) => Promise<HTMLElement>;
63
+ findAllByTestId: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react").waitForOptions | undefined) => Promise<HTMLElement[]>;
64
+ user: import("@testing-library/user-event/dist/types/setup").UserEvent;
65
+ };
66
+ export * from "@testing-library/react";
67
+ export { render };
68
+ export declare class TestUtils {
69
+ static createAppStore(): Store;
70
+ static initializeUiFramework(_?: IModelConnection): Promise<void>;
71
+ }
72
+ //# sourceMappingURL=test-utils.d.ts.map
@@ -0,0 +1,42 @@
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 * as React from "react";
6
+ import { render as rtlRender } from "@testing-library/react";
7
+ import { combineReducers, createStore } from "redux";
8
+ import { FrameworkReducer, SyncUiEventDispatcher, UiFramework, } from "@itwin/appui-react";
9
+ import userEvent from "@testing-library/user-event";
10
+ import { GroupingMappingApiConfigContext } from "../widget/components/context/GroupingApiConfigContext";
11
+ import { MappingClientContext } from "../widget/components/context/MappingClientContext";
12
+ import { GroupingMappingCustomUIContext } from "../widget/components/context/GroupingMappingCustomUIContext";
13
+ import * as moq from "typemoq";
14
+ export const mockAccessToken = async () => "Bearer eyJhbGci";
15
+ export const mockMappingClient = moq.Mock.ofType();
16
+ function render(ui, mockUIs = [], { ...options } = {}) {
17
+ const Wrapper = ({ children }) => (React.createElement(GroupingMappingApiConfigContext.Provider, { value: { getAccessToken: mockAccessToken } },
18
+ React.createElement(MappingClientContext.Provider, { value: mockMappingClient.object },
19
+ React.createElement(GroupingMappingCustomUIContext.Provider, { value: mockUIs }, children))));
20
+ return {
21
+ user: userEvent.setup(),
22
+ ...rtlRender(ui, { wrapper: Wrapper, ...options }),
23
+ };
24
+ }
25
+ export * from "@testing-library/react";
26
+ // override React Testing Library's render with our own
27
+ export { render };
28
+ export class TestUtils {
29
+ static createAppStore() {
30
+ const rootReducer = combineReducers({
31
+ frameworkState: FrameworkReducer,
32
+ });
33
+ return createStore(rootReducer, window.__REDUX_DEVTOOLS_EXTENSION__ &&
34
+ window.__REDUX_DEVTOOLS_EXTENSION__());
35
+ }
36
+ static async initializeUiFramework(_) {
37
+ const store = this.createAppStore();
38
+ await UiFramework.initialize(store);
39
+ SyncUiEventDispatcher.setTimeoutPeriod(0); // disables non-immediate event processing.
40
+ }
41
+ }
42
+ //# sourceMappingURL=test-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-utils.js","sourceRoot":"","sources":["../../../src/test/test-utils.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,MAAM,IAAI,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAE7D,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACrD,OAAO,EACL,gBAAgB,EAChB,qBAAqB,EACrB,WAAW,GACZ,MAAM,oBAAoB,CAAC;AAE5B,OAAO,SAAS,MAAM,6BAA6B,CAAC;AACpD,OAAO,EAAE,+BAA+B,EAAE,MAAM,uDAAuD,CAAC;AAExG,OAAO,EAAE,oBAAoB,EAAE,MAAM,mDAAmD,CAAC;AACzF,OAAO,EAAE,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AAC,cAAc,EAAE,CAAC;QACpC,MAAM,WAAW,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QACpC,qBAAqB,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,2CAA2C;IACxF,CAAC;CACF","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 * as React from \"react\";\nimport { render as rtlRender } from \"@testing-library/react\";\nimport type { Store } from \"redux\";\nimport { combineReducers, createStore } from \"redux\";\nimport {\n FrameworkReducer,\n SyncUiEventDispatcher,\n UiFramework,\n} from \"@itwin/appui-react\";\nimport type { IModelConnection } from \"@itwin/core-frontend\";\nimport userEvent from \"@testing-library/user-event\";\nimport { GroupingMappingApiConfigContext } from \"../widget/components/context/GroupingApiConfigContext\";\nimport type { IMappingsClient } from \"@itwin/insights-client\";\nimport { MappingClientContext } from \"../widget/components/context/MappingClientContext\";\nimport { GroupingMappingCustomUIContext } from \"../widget/components/context/GroupingMappingCustomUIContext\";\nimport type { GroupingMappingCustomUI } from \"../grouping-mapping-widget\";\nimport * as moq from \"typemoq\";\n\nexport const mockAccessToken = async () => \"Bearer eyJhbGci\";\nexport const mockMappingClient = moq.Mock.ofType<IMappingsClient>();\n\ninterface WrapperProps {\n children?: React.ReactNode;\n}\n\nfunction render(ui: React.ReactElement, mockUIs: GroupingMappingCustomUI[] = [], { ...options } = {}) {\n const Wrapper = ({ children }: WrapperProps) => (\n <GroupingMappingApiConfigContext.Provider value={{ getAccessToken: mockAccessToken }}>\n <MappingClientContext.Provider value={mockMappingClient.object}>\n <GroupingMappingCustomUIContext.Provider value={mockUIs}>\n {children}\n </GroupingMappingCustomUIContext.Provider>\n </MappingClientContext.Provider>\n </GroupingMappingApiConfigContext.Provider>\n );\n\n return {\n user: userEvent.setup(),\n ...rtlRender(ui, { wrapper: Wrapper, ...options }),\n };\n}\n\nexport * from \"@testing-library/react\";\n// override React Testing Library's render with our own\nexport { render };\n\nexport class TestUtils {\n public static createAppStore(): Store {\n const rootReducer = combineReducers({\n frameworkState: FrameworkReducer,\n });\n\n return createStore(\n rootReducer,\n (window as any).__REDUX_DEVTOOLS_EXTENSION__ &&\n (window as any).__REDUX_DEVTOOLS_EXTENSION__()\n );\n }\n\n public static async initializeUiFramework(_?: IModelConnection) {\n const store = this.createAppStore();\n await UiFramework.initialize(store);\n SyncUiEventDispatcher.setTimeoutPeriod(0); // disables non-immediate event processing.\n }\n}\n"]}
@@ -5,9 +5,10 @@ interface GroupActionProps {
5
5
  iModelId: string;
6
6
  mappingId: string;
7
7
  group?: IGroupTyped;
8
+ queryGenerationType?: string;
8
9
  goBack: () => Promise<void>;
9
10
  resetView: () => Promise<void>;
10
11
  }
11
- declare const GroupAction: ({ iModelId, mappingId, group, goBack, resetView, }: GroupActionProps) => JSX.Element;
12
+ declare const GroupAction: (props: GroupActionProps) => JSX.Element;
12
13
  export default GroupAction;
13
14
  //# sourceMappingURL=GroupAction.d.ts.map