@itwin/grouping-mapping-widget 0.5.8 → 0.7.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 (146) hide show
  1. package/README.md +84 -0
  2. package/lib/cjs/grouping-mapping-widget.d.ts +1 -1
  3. package/lib/cjs/grouping-mapping-widget.js +3 -2
  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/CalculatedPropertyAction.d.ts +2 -2
  15. package/lib/cjs/widget/components/CalculatedPropertyAction.js +13 -13
  16. package/lib/cjs/widget/components/CalculatedPropertyAction.js.map +1 -1
  17. package/lib/cjs/widget/components/CalculatedPropertyTable.d.ts +5 -5
  18. package/lib/cjs/widget/components/CalculatedPropertyTable.js.map +1 -1
  19. package/lib/cjs/widget/components/ConfirmMappingsImport.d.ts +3 -3
  20. package/lib/cjs/widget/components/ConfirmMappingsImport.js.map +1 -1
  21. package/lib/cjs/widget/components/CustomCalculationAction.d.ts +2 -2
  22. package/lib/cjs/widget/components/CustomCalculationAction.js +5 -5
  23. package/lib/cjs/widget/components/CustomCalculationAction.js.map +1 -1
  24. package/lib/cjs/widget/components/CustomCalculationTable.d.ts +5 -5
  25. package/lib/cjs/widget/components/CustomCalculationTable.js.map +1 -1
  26. package/lib/cjs/widget/components/GroupAction.d.ts +4 -3
  27. package/lib/cjs/widget/components/GroupAction.js +82 -75
  28. package/lib/cjs/widget/components/GroupAction.js.map +1 -1
  29. package/lib/cjs/widget/components/GroupAction.scss +1 -13
  30. package/lib/cjs/widget/components/GroupPropertyAction.d.ts +2 -1
  31. package/lib/cjs/widget/components/GroupPropertyAction.js +27 -26
  32. package/lib/cjs/widget/components/GroupPropertyAction.js.map +1 -1
  33. package/lib/cjs/widget/components/GroupPropertyTable.d.ts +5 -5
  34. package/lib/cjs/widget/components/GroupPropertyTable.js.map +1 -1
  35. package/lib/cjs/widget/components/Grouping.d.ts +6 -1
  36. package/lib/cjs/widget/components/Grouping.js +128 -66
  37. package/lib/cjs/widget/components/Grouping.js.map +1 -1
  38. package/lib/cjs/widget/components/Grouping.scss +21 -2
  39. package/lib/cjs/widget/components/GroupingMapping.d.ts +8 -3
  40. package/lib/cjs/widget/components/GroupingMapping.js +22 -9
  41. package/lib/cjs/widget/components/GroupingMapping.js.map +1 -1
  42. package/lib/cjs/widget/components/Mapping.d.ts +1 -1
  43. package/lib/cjs/widget/components/Mapping.js +6 -7
  44. package/lib/cjs/widget/components/Mapping.js.map +1 -1
  45. package/lib/cjs/widget/components/Mapping.scss +4 -5
  46. package/lib/cjs/widget/components/MappingAction.js +1 -2
  47. package/lib/cjs/widget/components/MappingAction.js.map +1 -1
  48. package/lib/cjs/widget/components/MappingImportWizardModal.js.map +1 -1
  49. package/lib/cjs/widget/components/PropertyMenu.d.ts +2 -2
  50. package/lib/cjs/widget/components/PropertyMenu.js +7 -8
  51. package/lib/cjs/widget/components/PropertyMenu.js.map +1 -1
  52. package/lib/cjs/widget/components/SelectMappings.d.ts +2 -2
  53. package/lib/cjs/widget/components/SelectMappings.js +2 -2
  54. package/lib/cjs/widget/components/SelectMappings.js.map +1 -1
  55. package/lib/cjs/widget/components/context/GroupingMappingCustomUIContext.d.ts +6 -0
  56. package/lib/cjs/widget/components/context/GroupingMappingCustomUIContext.js +25 -0
  57. package/lib/cjs/widget/components/context/GroupingMappingCustomUIContext.js.map +1 -0
  58. package/lib/cjs/widget/components/context/MappingClientContext.d.ts +5 -5
  59. package/lib/cjs/widget/components/context/MappingClientContext.js +1 -5
  60. package/lib/cjs/widget/components/context/MappingClientContext.js.map +1 -1
  61. package/lib/cjs/widget/components/customUI/GroupingMappingCustomUI.d.ts +91 -0
  62. package/lib/cjs/widget/components/customUI/GroupingMappingCustomUI.js +9 -0
  63. package/lib/cjs/widget/components/customUI/GroupingMappingCustomUI.js.map +1 -0
  64. package/lib/cjs/widget/components/customUI/ManualGroupingCustomUI.d.ts +6 -0
  65. package/lib/cjs/widget/components/customUI/ManualGroupingCustomUI.js +31 -0
  66. package/lib/cjs/widget/components/customUI/ManualGroupingCustomUI.js.map +1 -0
  67. package/lib/{esm/widget/IMappingClient.js → cjs/widget/components/customUI/ManualGroupingCustomUI.scss} +13 -2
  68. package/lib/cjs/widget/components/customUI/SearchGroupingCustomUI.d.ts +6 -0
  69. package/lib/cjs/widget/components/customUI/SearchGroupingCustomUI.js +97 -0
  70. package/lib/cjs/widget/components/customUI/SearchGroupingCustomUI.js.map +1 -0
  71. package/lib/cjs/widget/{IMappingClient.js → components/customUI/SearchGroupingCustomUI.scss} +13 -3
  72. package/lib/esm/grouping-mapping-widget.d.ts +1 -1
  73. package/lib/esm/grouping-mapping-widget.js +1 -1
  74. package/lib/esm/grouping-mapping-widget.js.map +1 -1
  75. package/lib/esm/test/GroupingMappingCustomUI.test.d.ts +2 -0
  76. package/lib/esm/test/GroupingMappingCustomUI.test.js +138 -0
  77. package/lib/esm/test/GroupingMappingCustomUI.test.js.map +1 -0
  78. package/lib/esm/test/WidgetHeader.test.d.ts +2 -0
  79. package/lib/esm/test/WidgetHeader.test.js +31 -0
  80. package/lib/esm/test/WidgetHeader.test.js.map +1 -0
  81. package/lib/esm/test/test-utils.d.ts +72 -0
  82. package/lib/esm/test/test-utils.js +42 -0
  83. package/lib/esm/test/test-utils.js.map +1 -0
  84. package/lib/esm/widget/components/CalculatedPropertyAction.d.ts +2 -2
  85. package/lib/esm/widget/components/CalculatedPropertyAction.js +13 -13
  86. package/lib/esm/widget/components/CalculatedPropertyAction.js.map +1 -1
  87. package/lib/esm/widget/components/CalculatedPropertyTable.d.ts +5 -5
  88. package/lib/esm/widget/components/CalculatedPropertyTable.js.map +1 -1
  89. package/lib/esm/widget/components/ConfirmMappingsImport.d.ts +3 -3
  90. package/lib/esm/widget/components/ConfirmMappingsImport.js.map +1 -1
  91. package/lib/esm/widget/components/CustomCalculationAction.d.ts +2 -2
  92. package/lib/esm/widget/components/CustomCalculationAction.js +5 -5
  93. package/lib/esm/widget/components/CustomCalculationAction.js.map +1 -1
  94. package/lib/esm/widget/components/CustomCalculationTable.d.ts +5 -5
  95. package/lib/esm/widget/components/CustomCalculationTable.js.map +1 -1
  96. package/lib/esm/widget/components/GroupAction.d.ts +4 -3
  97. package/lib/esm/widget/components/GroupAction.js +85 -78
  98. package/lib/esm/widget/components/GroupAction.js.map +1 -1
  99. package/lib/esm/widget/components/GroupAction.scss +1 -13
  100. package/lib/esm/widget/components/GroupPropertyAction.d.ts +2 -1
  101. package/lib/esm/widget/components/GroupPropertyAction.js +27 -26
  102. package/lib/esm/widget/components/GroupPropertyAction.js.map +1 -1
  103. package/lib/esm/widget/components/GroupPropertyTable.d.ts +5 -5
  104. package/lib/esm/widget/components/GroupPropertyTable.js.map +1 -1
  105. package/lib/esm/widget/components/Grouping.d.ts +6 -1
  106. package/lib/esm/widget/components/Grouping.js +128 -66
  107. package/lib/esm/widget/components/Grouping.js.map +1 -1
  108. package/lib/esm/widget/components/Grouping.scss +21 -2
  109. package/lib/esm/widget/components/GroupingMapping.d.ts +8 -3
  110. package/lib/esm/widget/components/GroupingMapping.js +23 -10
  111. package/lib/esm/widget/components/GroupingMapping.js.map +1 -1
  112. package/lib/esm/widget/components/Mapping.d.ts +1 -1
  113. package/lib/esm/widget/components/Mapping.js +6 -7
  114. package/lib/esm/widget/components/Mapping.js.map +1 -1
  115. package/lib/esm/widget/components/Mapping.scss +4 -5
  116. package/lib/esm/widget/components/MappingAction.js +1 -2
  117. package/lib/esm/widget/components/MappingAction.js.map +1 -1
  118. package/lib/esm/widget/components/MappingImportWizardModal.js.map +1 -1
  119. package/lib/esm/widget/components/PropertyMenu.d.ts +2 -2
  120. package/lib/esm/widget/components/PropertyMenu.js +7 -8
  121. package/lib/esm/widget/components/PropertyMenu.js.map +1 -1
  122. package/lib/esm/widget/components/SelectMappings.d.ts +2 -2
  123. package/lib/esm/widget/components/SelectMappings.js +2 -2
  124. package/lib/esm/widget/components/SelectMappings.js.map +1 -1
  125. package/lib/esm/widget/components/context/GroupingMappingCustomUIContext.d.ts +6 -0
  126. package/lib/esm/widget/components/context/GroupingMappingCustomUIContext.js +20 -0
  127. package/lib/esm/widget/components/context/GroupingMappingCustomUIContext.js.map +1 -0
  128. package/lib/esm/widget/components/context/MappingClientContext.d.ts +5 -5
  129. package/lib/esm/widget/components/context/MappingClientContext.js +2 -6
  130. package/lib/esm/widget/components/context/MappingClientContext.js.map +1 -1
  131. package/lib/esm/widget/components/customUI/GroupingMappingCustomUI.d.ts +91 -0
  132. package/lib/esm/widget/components/customUI/GroupingMappingCustomUI.js +6 -0
  133. package/lib/esm/widget/components/customUI/GroupingMappingCustomUI.js.map +1 -0
  134. package/lib/esm/widget/components/customUI/ManualGroupingCustomUI.d.ts +6 -0
  135. package/lib/esm/widget/components/customUI/ManualGroupingCustomUI.js +26 -0
  136. package/lib/esm/widget/components/customUI/ManualGroupingCustomUI.js.map +1 -0
  137. package/lib/esm/widget/components/customUI/ManualGroupingCustomUI.scss +17 -0
  138. package/lib/esm/widget/components/customUI/SearchGroupingCustomUI.d.ts +6 -0
  139. package/lib/esm/widget/components/customUI/SearchGroupingCustomUI.js +92 -0
  140. package/lib/esm/widget/components/customUI/SearchGroupingCustomUI.js.map +1 -0
  141. package/lib/esm/widget/components/customUI/SearchGroupingCustomUI.scss +17 -0
  142. package/package.json +18 -4
  143. package/lib/cjs/widget/IMappingClient.d.ts +0 -327
  144. package/lib/cjs/widget/IMappingClient.js.map +0 -1
  145. package/lib/esm/widget/IMappingClient.d.ts +0 -327
  146. package/lib/esm/widget/IMappingClient.js.map +0 -1
package/README.md CHANGED
@@ -29,3 +29,87 @@ import { GroupingMappingProvider } from "@itwin/grouping-mapping-widget";
29
29
  uiProviders={[new GroupingMappingProvider()]}
30
30
  />
31
31
  ```
32
+
33
+ ## Custom UI
34
+
35
+ This package provides an interface to define your own custom UI or callback functions in grouping mapping widget. There are different types of custom UIs provided.
36
+
37
+ ### Grouping Custom UI
38
+
39
+ You can use your own UI component to define group creation method.
40
+
41
+ An example of grouping custom UI, [ManualGroupingCustomUI](https://github.com/iTwin/viewer-components-react/blob/master/packages/itwin/grouping-mapping-widget/src/widget/components/customUI/ManualGroupingCustomUI.tsx) helps user to manually define ECSQL query for groups.
42
+
43
+ In `GroupingCustomUIProps`:
44
+
45
+ - `updateQuery` is used to run the query and visualize results in the viewer.
46
+ - `isUpdating` keeps track of the status of query execution.
47
+ - `resetView` enables you to reset the viewer state.
48
+
49
+ To configure your own grouping custom UI, you need to give it:
50
+
51
+ - a `type` as `GroupingMappingCustomUIType.Grouping`
52
+ - a `name` as identifier
53
+ - a `displayLabel` which will be shown in the 'Add Group' dropdown list
54
+ - a `uiComponent` like above
55
+ - an optional `icon`
56
+
57
+ You can define your UI provider as follows in the GroupingMappingProvider:
58
+
59
+ ```tsx
60
+ new GroupingMappingProvider({
61
+ customUIs: [
62
+ {
63
+ type: GroupingMappingCustomUIType.Grouping,
64
+ name: "Manual",
65
+ displayLabel: "Manual Query",
66
+ uiComponent: ManualGroupingCustomUI,
67
+ icon: <SvgDraw />,
68
+ },
69
+ ],
70
+ });
71
+ ```
72
+
73
+ After adding the grouping custom UI, it will be presented in the 'Add Group' drop down list.
74
+
75
+ ![Process Functional Grouping Menu Item](./assets/ProcessGroupingMenuItem.jpg)
76
+
77
+ ### Context Custom UI
78
+
79
+ You can also add custom UI in context menu for each group. This could be UI driven interaction or simply a callback function to execute your own code.
80
+
81
+ You can use the `iModelId`, `mappingId` and `groupId` in `ContextCustomUIProps` provided by Grouping Mapping Widget in your UI component or callback.
82
+
83
+ To configure your own context custom UI, you need to give it:
84
+
85
+ - a `type` as `GroupingMappingCustomUIType.Context`
86
+ - a `name` as identifier
87
+ - a `displayLabel` which will be shown in the context dropdown list in each group tile
88
+ - an optional `uiComponent` which will be presented in the widget as a UI component
89
+ - an optional `onClick` callback function where you could make your own API calls
90
+ - an optional `icon`
91
+
92
+ You can define your context custom UI as following example in the GroupingMappingProvider with an example is to use [clash detection](https://www.itwinjs.org/sandboxes/iTwinPlatform/Clash%20Review) in the widget:
93
+
94
+ ```tsx
95
+ const customCB = (groupId: string, mappingId: string, iModelId: string) => {
96
+ toaster.informational(`Called callback for group ${groupId}`)
97
+ }
98
+
99
+ new GroupingMappingProvider({
100
+ customUIs: [
101
+ {
102
+ type: GroupingMappingCustomUIType.Context,
103
+ name: "ClashDetection",
104
+ displayLabel: "Clash Detection",
105
+ uiComponent: ClashDetectionCustomUI,
106
+ onClick: customCB,
107
+ icon: <SvgClash />,
108
+ },
109
+ ],
110
+ });
111
+ ```
112
+
113
+ After adding the context custom UI, the context menu item will look like this with additional `Clash Detection` menu item.
114
+
115
+ ![Clash Detection Context Menu Item](./assets/ClashDetectionContextMenuItem.jpg)
@@ -4,7 +4,6 @@ export * from "./widget/GroupingMappingWidget";
4
4
  export { createDefaultMappingClient } from "./widget/components/context/MappingClientContext";
5
5
  export { ClientPrefix, GetAccessTokenFn } from "./widget/components/context/GroupingApiConfigContext";
6
6
  export * from "@itwin/insights-client";
7
- export * from "./widget/IMappingClient";
8
7
  /** Internal components for custom UIs */
9
8
  export { Mappings } from "./widget/components/Mapping";
10
9
  export { Groupings } from "./widget/components/Grouping";
@@ -13,4 +12,5 @@ export { PropertyMenu } from "./widget/components/PropertyMenu";
13
12
  export { resolveFormulaDataType } from "./formula/FormulaDataTypeResolver";
14
13
  export { DataType, PropertyMap } from "./formula/Types";
15
14
  export { IResult } from "./formula/IResult";
15
+ export { GroupingMappingCustomUI, GroupingMappingCustomUIType, ContextCustomUI, GroupingCustomUI, GroupingCustomUIProps, ContextCustomUIProps } from "./widget/components/customUI/GroupingMappingCustomUI";
16
16
  //# sourceMappingURL=grouping-mapping-widget.d.ts.map
@@ -10,7 +10,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
10
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.resolveFormulaDataType = exports.PropertyMenu = exports.Groupings = exports.Mappings = exports.createDefaultMappingClient = void 0;
13
+ exports.GroupingMappingCustomUIType = exports.resolveFormulaDataType = exports.PropertyMenu = exports.Groupings = exports.Mappings = exports.createDefaultMappingClient = void 0;
14
14
  /*---------------------------------------------------------------------------------------------
15
15
  * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
16
16
  * See LICENSE.md in the project root for license terms and full copyright notice.
@@ -21,7 +21,6 @@ __exportStar(require("./widget/GroupingMappingWidget"), exports);
21
21
  var MappingClientContext_1 = require("./widget/components/context/MappingClientContext");
22
22
  Object.defineProperty(exports, "createDefaultMappingClient", { enumerable: true, get: function () { return MappingClientContext_1.createDefaultMappingClient; } });
23
23
  __exportStar(require("@itwin/insights-client"), exports);
24
- __exportStar(require("./widget/IMappingClient"), exports);
25
24
  /** Internal components for custom UIs */
26
25
  var Mapping_1 = require("./widget/components/Mapping");
27
26
  Object.defineProperty(exports, "Mappings", { enumerable: true, get: function () { return Mapping_1.Mappings; } });
@@ -32,4 +31,6 @@ Object.defineProperty(exports, "PropertyMenu", { enumerable: true, get: function
32
31
  /** Formula DataType resolver */
33
32
  var FormulaDataTypeResolver_1 = require("./formula/FormulaDataTypeResolver");
34
33
  Object.defineProperty(exports, "resolveFormulaDataType", { enumerable: true, get: function () { return FormulaDataTypeResolver_1.resolveFormulaDataType; } });
34
+ var GroupingMappingCustomUI_1 = require("./widget/components/customUI/GroupingMappingCustomUI");
35
+ Object.defineProperty(exports, "GroupingMappingCustomUIType", { enumerable: true, get: function () { return GroupingMappingCustomUI_1.GroupingMappingCustomUIType; } });
35
36
  //# 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,iEAA+C;AAE/C,0EAA0E;AAC1E,yFAA8F;AAArF,kIAAA,0BAA0B,OAAA;AAEnC,yDAAuC;AACvC,0DAAwC;AAExC,yCAAyC;AACzC,uDAAuD;AAA9C,mGAAA,QAAQ,OAAA;AACjB,yDAAyD;AAAhD,qGAAA,SAAS,OAAA;AAClB,iEAAgE;AAAvD,4GAAA,YAAY,OAAA;AAErB,gCAAgC;AAChC,6EAA2E;AAAlE,iIAAA,sBAAsB,OAAA","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\";\nexport * from \"./widget/IMappingClient\";\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,iEAA+C;AAE/C,0EAA0E;AAC1E,yFAA8F;AAArF,kIAAA,0BAA0B,OAAA;AAEnC,yDAAuC;AAEvC,yCAAyC;AACzC,uDAAuD;AAA9C,mGAAA,QAAQ,OAAA;AACjB,yDAAyD;AAAhD,qGAAA,SAAS,OAAA;AAClB,iEAAgE;AAAvD,4GAAA,YAAY,OAAA;AAErB,gCAAgC;AAChC,6EAA2E;AAAlE,iIAAA,sBAAsB,OAAA;AAG/B,gGAA4M;AAA1K,sIAAA,2BAA2B,OAAA","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,162 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ var __importDefault = (this && this.__importDefault) || function (mod) {
22
+ return (mod && mod.__esModule) ? mod : { "default": mod };
23
+ };
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ /*---------------------------------------------------------------------------------------------
26
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
27
+ * See LICENSE.md in the project root for license terms and full copyright notice.
28
+ *--------------------------------------------------------------------------------------------*/
29
+ const react_1 = __importDefault(require("react"));
30
+ require("@testing-library/jest-dom");
31
+ const test_utils_1 = require("./test-utils");
32
+ const faker_1 = require("@faker-js/faker");
33
+ const grouping_mapping_widget_1 = require("../grouping-mapping-widget");
34
+ const moq = __importStar(require("typemoq"));
35
+ const core_frontend_1 = require("@itwin/core-frontend");
36
+ const presentation_frontend_1 = require("@itwin/presentation-frontend");
37
+ const core_common_1 = require("@itwin/core-common");
38
+ const mockITwinId = faker_1.faker.datatype.uuid();
39
+ const mockIModelId = faker_1.faker.datatype.uuid();
40
+ const mockMappingId = faker_1.faker.datatype.uuid();
41
+ const mockMapping = {
42
+ id: mockMappingId,
43
+ mappingName: "mOcKmApPiNg1",
44
+ description: "mOcKmApPiNgDeScRiPtIoN1",
45
+ createdBy: faker_1.faker.random.alpha(),
46
+ createdOn: faker_1.faker.date.past().toDateString(),
47
+ modifiedBy: faker_1.faker.random.alpha(),
48
+ modifiedOn: faker_1.faker.date.past().toDateString(),
49
+ extractionEnabled: false,
50
+ _links: {
51
+ imodel: {
52
+ href: "",
53
+ },
54
+ },
55
+ };
56
+ const groupsFactory = () => ({
57
+ groups: Array.from({ length: faker_1.faker.datatype.number({ min: 3, max: 5 }) }, (_, index) => ({
58
+ id: `${faker_1.faker.datatype.uuid()}`,
59
+ groupName: `mOcKgRoUp${index}`,
60
+ description: `mOcKgRoUpDeScRiPtIoN${index}`,
61
+ query: `mOcKgRoUpQuErY${index}`,
62
+ _links: {
63
+ imodel: {
64
+ href: "",
65
+ },
66
+ mapping: {
67
+ href: "",
68
+ },
69
+ },
70
+ })),
71
+ _links: {
72
+ next: undefined,
73
+ self: {
74
+ href: "",
75
+ },
76
+ },
77
+ });
78
+ const connectionMock = moq.Mock.ofType();
79
+ const selectionManagerMock = moq.Mock.ofType();
80
+ const selectionScopesManagerMock = moq.Mock.ofType();
81
+ jest.mock("@itwin/appui-react", () => ({
82
+ ...jest.requireActual("@itwin/appui-react"),
83
+ useActiveIModelConnection: () => connectionMock.object,
84
+ }));
85
+ beforeAll(async () => {
86
+ await core_frontend_1.NoRenderApp.startup({ localization: new core_common_1.EmptyLocalization() });
87
+ await presentation_frontend_1.Presentation.initialize();
88
+ const selectionSet = moq.Mock.ofType();
89
+ const onChanged = moq.Mock.ofType();
90
+ selectionSet.setup((x) => x.elements).returns(() => new Set([]));
91
+ selectionSet.setup((x) => x.onChanged).returns(() => onChanged.object);
92
+ connectionMock
93
+ .setup((x) => x.selectionSet)
94
+ .returns(() => selectionSet.object);
95
+ connectionMock.setup((x) => x.iModelId).returns(() => mockIModelId);
96
+ connectionMock.setup((x) => x.iTwinId).returns(() => mockITwinId);
97
+ selectionManagerMock
98
+ .setup((x) => x.selectionChange)
99
+ .returns(() => new presentation_frontend_1.SelectionChangeEvent());
100
+ selectionScopesManagerMock
101
+ .setup(async (x) => x.getSelectionScopes(connectionMock.object))
102
+ .returns(async () => []);
103
+ selectionManagerMock
104
+ .setup((x) => x.scopes)
105
+ .returns(() => selectionScopesManagerMock.object);
106
+ presentation_frontend_1.Presentation.setSelectionManager(selectionManagerMock.object);
107
+ await test_utils_1.TestUtils.initializeUiFramework(connectionMock.object);
108
+ });
109
+ describe("Groupings View with default UIs", () => {
110
+ it("List all groups and click on add group and edit group buttons", async () => {
111
+ // Arange
112
+ const mockGroups = groupsFactory();
113
+ const mockedAccessToken = await test_utils_1.mockAccessToken();
114
+ test_utils_1.mockMappingClient
115
+ .setup(async (x) => x.getGroups(mockedAccessToken, mockIModelId, mockMappingId))
116
+ .returns(async () => mockGroups.groups);
117
+ // Act
118
+ const { user } = test_utils_1.render(react_1.default.createElement(grouping_mapping_widget_1.Groupings, { mapping: mockMapping, goBack: jest.fn() }));
119
+ await test_utils_1.waitForElementToBeRemoved(() => test_utils_1.screen.getByText(/loading/i));
120
+ // Assert
121
+ const addButton = test_utils_1.screen.getAllByTestId("gmw-add-group-button");
122
+ expect(addButton).toHaveLength(1);
123
+ // Click on 'Add Group' button
124
+ await user.click(addButton[0]);
125
+ // Should have three menu items
126
+ const addSelection = test_utils_1.screen.getAllByTestId("gmw-add-0");
127
+ expect(addSelection).toHaveLength(1);
128
+ const addSearch = test_utils_1.screen.getAllByTestId("gmw-add-1");
129
+ expect(addSearch).toHaveLength(1);
130
+ const addManual = test_utils_1.screen.getAllByTestId("gmw-add-2");
131
+ expect(addManual).toHaveLength(1);
132
+ // Should have the right group number
133
+ const horizontalTiles = test_utils_1.screen.getAllByTestId("gmw-horizontal-tile");
134
+ expect(horizontalTiles).toHaveLength(mockGroups.groups.length);
135
+ horizontalTiles.forEach((horizontalTile, index) => {
136
+ var _a;
137
+ const groupTile = test_utils_1.within(horizontalTile);
138
+ expect(groupTile.getByText(mockGroups.groups[index].groupName)).toBeInTheDocument();
139
+ expect(groupTile.getByText((_a = mockGroups.groups[index].description) !== null && _a !== void 0 ? _a : "")).toBeInTheDocument();
140
+ });
141
+ // Click on first group more icon
142
+ const moreButton = test_utils_1.screen.getAllByTestId("gmw-more-button");
143
+ expect(moreButton).toHaveLength(mockGroups.groups.length);
144
+ await user.click(moreButton[0]);
145
+ // Should have 3 context menu items
146
+ const contextMenuItems = test_utils_1.screen.getAllByTestId("gmw-context-menu-item");
147
+ expect(contextMenuItems).toHaveLength(3);
148
+ expect(contextMenuItems[0]).toHaveTextContent("Edit");
149
+ expect(contextMenuItems[1]).toHaveTextContent("Properties");
150
+ expect(contextMenuItems[2]).toHaveTextContent("Remove");
151
+ // Hover on 'Edit'
152
+ await user.hover(contextMenuItems[0]);
153
+ // Should have 3 sub menu items
154
+ const editSelection = test_utils_1.screen.getAllByTestId(`gmw-edit-0`);
155
+ expect(editSelection).toHaveLength(1);
156
+ const editSearch = test_utils_1.screen.getAllByTestId(`gmw-edit-1`);
157
+ expect(editSearch).toHaveLength(1);
158
+ const editManual = test_utils_1.screen.getAllByTestId(`gmw-edit-2`);
159
+ expect(editManual).toHaveLength(1);
160
+ });
161
+ });
162
+ //# 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,kDAA0B;AAC1B,qCAAmC;AACnC,6CAAgI;AAChI,2CAAwC;AACxC,wEAAuD;AAEvD,6CAA+B;AAE/B,wDAAmD;AAEnD,wEAAkF;AAElF,oDAAuD;AAEvD,MAAM,WAAW,GAAG,aAAK,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;AAC1C,MAAM,YAAY,GAAG,aAAK,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;AAC3C,MAAM,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C,CAAC;QACtC,MAAM,UAAU,GAAG,mBAAM,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC;QACvD,MAAM,CAAC,UAAU,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;QACnC,MAAM,UAAU,GAAG,mBAAM,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,36 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ /*---------------------------------------------------------------------------------------------
7
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
8
+ * See LICENSE.md in the project root for license terms and full copyright notice.
9
+ *--------------------------------------------------------------------------------------------*/
10
+ const react_1 = __importDefault(require("react"));
11
+ require("@testing-library/jest-dom");
12
+ const test_utils_1 = require("../test/test-utils");
13
+ const utils_1 = require("../widget/components/utils");
14
+ const faker_1 = require("@faker-js/faker");
15
+ describe("Widget Header Component", () => {
16
+ it("title renders", async () => {
17
+ // Arrange
18
+ const fakeTitle = faker_1.faker.word.interjection();
19
+ // Act
20
+ test_utils_1.render(react_1.default.createElement(utils_1.WidgetHeader, { title: fakeTitle }));
21
+ // Assert
22
+ const title = test_utils_1.screen.getByText(fakeTitle);
23
+ expect(title).toHaveTextContent(fakeTitle);
24
+ });
25
+ it("header allows return callback", async () => {
26
+ // Arrange
27
+ const mockReturnFn = jest.fn();
28
+ // Act
29
+ const { user, container } = test_utils_1.render(react_1.default.createElement(utils_1.WidgetHeader, { title: "", returnFn: mockReturnFn }));
30
+ // Assert
31
+ const returnBtn = container.getElementsByClassName("gmw-chevron")[0];
32
+ await user.click(returnBtn);
33
+ expect(mockReturnFn).toHaveBeenCalledTimes(1);
34
+ });
35
+ });
36
+ //# 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,kDAA0B;AAC1B,qCAAmC;AACnC,mDAAoD;AACpD,sDAA0D;AAC1D,2CAAwC;AAExC,QAAQ,CAAC,yBAAyB,EAAE,GAAG,EAAE;IACvC,EAAE,CAAC,eAAe,EAAE,KAAK,IAAI,EAAE;QAC7B,UAAU;QACV,MAAM,SAAS,GAAG,aAAK,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC;QAE5C,MAAM;QACN,mBAAM,CAAC,8BAAC,oBAAY,IAAC,KAAK,EAAE,SAAS,GAAI,CAAC,CAAC;QAE3C,SAAS;QACT,MAAM,KAAK,GAAG,mBAAM,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,mBAAM,CAAC,8BAAC,oBAAY,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,71 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
22
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
23
+ };
24
+ var __importDefault = (this && this.__importDefault) || function (mod) {
25
+ return (mod && mod.__esModule) ? mod : { "default": mod };
26
+ };
27
+ Object.defineProperty(exports, "__esModule", { value: true });
28
+ exports.TestUtils = exports.render = exports.mockMappingClient = exports.mockAccessToken = void 0;
29
+ /*---------------------------------------------------------------------------------------------
30
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
31
+ * See LICENSE.md in the project root for license terms and full copyright notice.
32
+ *--------------------------------------------------------------------------------------------*/
33
+ const React = __importStar(require("react"));
34
+ const react_1 = require("@testing-library/react");
35
+ const redux_1 = require("redux");
36
+ const appui_react_1 = require("@itwin/appui-react");
37
+ const user_event_1 = __importDefault(require("@testing-library/user-event"));
38
+ const GroupingApiConfigContext_1 = require("../widget/components/context/GroupingApiConfigContext");
39
+ const MappingClientContext_1 = require("../widget/components/context/MappingClientContext");
40
+ const GroupingMappingCustomUIContext_1 = require("../widget/components/context/GroupingMappingCustomUIContext");
41
+ const moq = __importStar(require("typemoq"));
42
+ const mockAccessToken = async () => "Bearer eyJhbGci";
43
+ exports.mockAccessToken = mockAccessToken;
44
+ exports.mockMappingClient = moq.Mock.ofType();
45
+ function render(ui, mockUIs = [], { ...options } = {}) {
46
+ const Wrapper = ({ children }) => (React.createElement(GroupingApiConfigContext_1.GroupingMappingApiConfigContext.Provider, { value: { getAccessToken: exports.mockAccessToken } },
47
+ React.createElement(MappingClientContext_1.MappingClientContext.Provider, { value: exports.mockMappingClient.object },
48
+ React.createElement(GroupingMappingCustomUIContext_1.GroupingMappingCustomUIContext.Provider, { value: mockUIs }, children))));
49
+ return {
50
+ user: user_event_1.default.setup(),
51
+ ...react_1.render(ui, { wrapper: Wrapper, ...options }),
52
+ };
53
+ }
54
+ exports.render = render;
55
+ __exportStar(require("@testing-library/react"), exports);
56
+ class TestUtils {
57
+ static createAppStore() {
58
+ const rootReducer = redux_1.combineReducers({
59
+ frameworkState: appui_react_1.FrameworkReducer,
60
+ });
61
+ return redux_1.createStore(rootReducer, window.__REDUX_DEVTOOLS_EXTENSION__ &&
62
+ window.__REDUX_DEVTOOLS_EXTENSION__());
63
+ }
64
+ static async initializeUiFramework(_) {
65
+ const store = this.createAppStore();
66
+ await appui_react_1.UiFramework.initialize(store);
67
+ appui_react_1.SyncUiEventDispatcher.setTimeoutPeriod(0); // disables non-immediate event processing.
68
+ }
69
+ }
70
+ exports.TestUtils = TestUtils;
71
+ //# 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,6CAA+B;AAC/B,kDAA6D;AAE7D,iCAAqD;AACrD,oDAI4B;AAE5B,6EAAoD;AACpD,oGAAwG;AAExG,4FAAyF;AACzF,gHAA6G;AAE7G,6CAA+B;AAExB,MAAM,eAAe,GAAG,KAAK,IAAI,EAAE,CAAC,iBAAiB,CAAC;AAAhD,QAAA,eAAe,mBAAiC;AAChD,QAAA,iBAAiB,GAAI,GAAG,CAAC,IAAI,CAAC,MAAM,EAAmB,CAAC;AAMrE,SAAS,MAAM,CAAC,EAAsB,EAAE,UAAqC,EAAE,EAAE,EAAE,GAAG,OAAO,EAAE,GAAG,EAAE;IAClG,MAAM,OAAO,GAAG,CAAC,EAAE,QAAQ,EAAgB,EAAE,EAAE,CAAC,CAC9C,oBAAC,0DAA+B,CAAC,QAAQ,IAAC,KAAK,EAAE,EAAE,cAAc,EAAE,uBAAe,EAAE;QAClF,oBAAC,2CAAoB,CAAC,QAAQ,IAAC,KAAK,EAAE,yBAAiB,CAAC,MAAM;YAC5D,oBAAC,+DAA8B,CAAC,QAAQ,IAAC,KAAK,EAAE,OAAO,IACpD,QAAQ,CAC+B,CACZ,CACS,CAC5C,CAAC;IAEF,OAAO;QACL,IAAI,EAAE,oBAAS,CAAC,KAAK,EAAE;QACvB,GAAG,cAAS,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,OAAO,EAAE,CAAC;KACnD,CAAC;AACJ,CAAC;AAIQ,wBAAM;AAFf,yDAAuC;AAIvC,MAAa,SAAS;IACb,MAAM,CAAC,cAAc;QAC1B,MAAM,WAAW,GAAG,uBAAe,CAAC;YAClC,cAAc,EAAE,8BAAgB;SACjC,CAAC,CAAC;QAEH,OAAO,mBAAW,CAChB,WAAW,EACV,MAAc,CAAC,4BAA4B;YAC3C,MAAc,CAAC,4BAA4B,EAAE,CAC/C,CAAC;IACJ,CAAC;IAEM,MAAM,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAoB;QAC5D,MAAM,KAAK,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC;QACpC,MAAM,yBAAW,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QACpC,mCAAqB,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,2CAA2C;IACxF,CAAC;CACF;AAlBD,8BAkBC","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"]}
@@ -1,11 +1,11 @@
1
1
  /// <reference types="react" />
2
2
  import "./CalculatedPropertyAction.scss";
3
- import type { CalculatedPropertyType } from "./CalculatedPropertyTable";
3
+ import type { ICalculatedPropertyTyped } from "./CalculatedPropertyTable";
4
4
  interface CalculatedPropertyActionProps {
5
5
  iModelId: string;
6
6
  mappingId: string;
7
7
  groupId: string;
8
- property?: CalculatedPropertyType;
8
+ property?: ICalculatedPropertyTyped;
9
9
  ids: string[];
10
10
  returnFn: (modified: boolean) => Promise<void>;
11
11
  }