@@ -9,8 +9,9 @@ import { IModel, IModelReadRpcInterface } from "@itwin/core-common";
9
9
import { ECSchemaRpcInterface } from "@itwin/ecschema-rpcinterface-common" ;
10
10
import { ECSchemaRpcImpl } from "@itwin/ecschema-rpcinterface-impl" ;
11
11
import { PresentationRpcInterface } from "@itwin/presentation-common" ;
12
- import { HierarchyNodeIdentifier } from "@itwin/presentation-hierarchies" ;
12
+ import { HierarchyFilteringPath , HierarchyNodeIdentifier } from "@itwin/presentation-hierarchies" ;
13
13
import { HierarchyCacheMode , initialize as initializePresentationTesting , terminate as terminatePresentationTesting } from "@itwin/presentation-testing" ;
14
+ import { joinHierarchyFilteringPaths } from "../../../tree-widget-react/components/trees/common/Utils.js" ;
14
15
import { ModelsTreeIdsCache } from "../../../tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.js" ;
15
16
import { defaultHierarchyConfiguration , ModelsTreeDefinition } from "../../../tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.js" ;
16
17
import {
@@ -29,11 +30,9 @@ import { createClassGroupingHierarchyNode, createModelsTreeProvider } from "./Ut
29
30
import type { Id64String } from "@itwin/core-bentley" ;
30
31
import type { IModelConnection } from "@itwin/core-frontend" ;
31
32
import type { InstanceKey } from "@itwin/presentation-common" ;
32
- import type { HierarchyFilteringPath } from "@itwin/presentation-hierarchies" ;
33
33
import type { TestIModelBuilder } from "@itwin/presentation-testing" ;
34
34
import type { ExpectedHierarchyDef } from "../HierarchyValidation.js" ;
35
35
import type { ElementsGroupInfo } from "../../../tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.js" ;
36
-
37
36
type ModelsTreeHierarchyConfiguration = ConstructorParameters < typeof ModelsTreeDefinition > [ 0 ] [ "hierarchyConfig" ] ;
38
37
39
38
interface TreeFilteringTestCaseDefinition < TIModelSetupResult extends { } > {
@@ -100,6 +99,102 @@ describe("Models tree", () => {
100
99
await terminatePresentationTesting ( ) ;
101
100
} ) ;
102
101
102
+ it ( "sets auto-expand on correct nodes with merged sub-tree and filter paths" , async function ( ) {
103
+ await using buildIModelResult = await buildIModel ( this , async ( builder ) => {
104
+ const rootSubject : InstanceKey = { className : "BisCore.Subject" , id : IModel . rootSubjectId } ;
105
+ const model = insertPhysicalModelWithPartition ( { builder, codeValue : `model` , partitionParentId : rootSubject . id } ) ;
106
+ const category = insertSpatialCategory ( { builder, codeValue : "category" } ) ;
107
+ const parentElement = insertPhysicalElement ( {
108
+ builder,
109
+ userLabel : `parent el` ,
110
+ modelId : model . id ,
111
+ categoryId : category . id ,
112
+ } ) ;
113
+ const childElement = insertPhysicalElement ( {
114
+ builder,
115
+ userLabel : `child el` ,
116
+ modelId : model . id ,
117
+ categoryId : category . id ,
118
+ parentId : parentElement . id ,
119
+ } ) ;
120
+ insertPhysicalElement ( {
121
+ builder,
122
+ userLabel : `unrelated el` ,
123
+ modelId : model . id ,
124
+ categoryId : category . id ,
125
+ } ) ;
126
+ return { rootSubject, model, category, parentElement, childElement } ;
127
+ } ) ;
128
+ const { imodel, ...keys } = buildIModelResult ;
129
+ const imodelAccess = createIModelAccess ( imodel ) ;
130
+ const config = { ...defaultHierarchyConfiguration , hideRootSubject : true , elementClassSpecification : keys . parentElement . className } ;
131
+ using idsCache = new ModelsTreeIdsCache ( imodelAccess , config ) ;
132
+ const [ subTreePaths , filterPaths ] = await Promise . all ( [
133
+ ModelsTreeDefinition . createInstanceKeyPaths ( {
134
+ imodelAccess,
135
+ idsCache,
136
+ hierarchyConfig : config ,
137
+ targetItems : [ { id : keys . childElement . id , className : keys . childElement . className } ] ,
138
+ } ) ,
139
+ ModelsTreeDefinition . createInstanceKeyPaths ( { imodelAccess, idsCache, hierarchyConfig : config , label : "parent" } ) ,
140
+ ] ) ;
141
+ const joinedPaths = joinHierarchyFilteringPaths (
142
+ subTreePaths . map ( ( path ) => HierarchyFilteringPath . normalize ( path ) . path ) ,
143
+ filterPaths . map ( ( path ) => {
144
+ const normalizedPath = HierarchyFilteringPath . normalize ( path ) ;
145
+ normalizedPath . options = { autoExpand : true } ;
146
+ return normalizedPath ;
147
+ } ) ,
148
+ ) ;
149
+
150
+ using provider = createModelsTreeProvider ( {
151
+ imodel,
152
+ hierarchyConfig : config ,
153
+ filteredNodePaths : joinedPaths ,
154
+ imodelAccess,
155
+ idsCache,
156
+ } ) ;
157
+ await validateHierarchy ( {
158
+ provider,
159
+ expect : [
160
+ NodeValidators . createForInstanceNode ( {
161
+ instanceKeys : [ keys . model ] ,
162
+ supportsFiltering : true ,
163
+ autoExpand : true ,
164
+ children : [
165
+ NodeValidators . createForInstanceNode ( {
166
+ instanceKeys : [ keys . category ] ,
167
+ supportsFiltering : true ,
168
+ autoExpand : true ,
169
+ children : [
170
+ NodeValidators . createForClassGroupingNode ( {
171
+ autoExpand : true ,
172
+ children : [
173
+ NodeValidators . createForInstanceNode ( {
174
+ instanceKeys : [ keys . parentElement ] ,
175
+ supportsFiltering : true ,
176
+ children : [
177
+ NodeValidators . createForClassGroupingNode ( {
178
+ children : [
179
+ NodeValidators . createForInstanceNode ( {
180
+ instanceKeys : [ keys . childElement ] ,
181
+ supportsFiltering : true ,
182
+ children : false ,
183
+ } ) ,
184
+ ] ,
185
+ } ) ,
186
+ ] ,
187
+ } ) ,
188
+ ] ,
189
+ } ) ,
190
+ ] ,
191
+ } ) ,
192
+ ] ,
193
+ } ) ,
194
+ ] ,
195
+ } ) ;
196
+ } ) ;
197
+
103
198
runTestCases (
104
199
TreeFilteringTestCaseDefinition . create (
105
200
"immediate Subject nodes" ,
0 commit comments