@@ -43,11 +43,12 @@ import {
43
43
} from "./Utils.js" ;
44
44
import { validateHierarchyVisibility } from "./VisibilityValidation.js" ;
45
45
46
- import type { VisibilityExpectations } from "./VisibilityValidation.js" ;
47
- import type { InstanceKey } from "@itwin/presentation-common" ;
48
46
import type { IModelConnection , Viewport } from "@itwin/core-frontend" ;
49
- import type { CategoriesTreeHierarchyConfiguration } from "../../../../tree-widget-react/components/trees/categories-tree/CategoriesTreeDefinition.js " ;
47
+ import type { InstanceKey } from "@itwin/presentation-common " ;
50
48
import type { GroupingHierarchyNode , HierarchyNodeIdentifiersPath , NonGroupingHierarchyNode } from "@itwin/presentation-hierarchies" ;
49
+ import type { CategoriesTreeHierarchyConfiguration } from "../../../../tree-widget-react/components/trees/categories-tree/CategoriesTreeDefinition.js" ;
50
+ import type { VisibilityExpectations } from "./VisibilityValidation.js" ;
51
+
51
52
describe ( "CategoriesTreeVisibilityHandler" , ( ) => {
52
53
before ( async ( ) => {
53
54
await initializePresentationTesting ( {
@@ -169,6 +170,7 @@ describe("CategoriesTreeVisibilityHandler", () => {
169
170
expectations : "all-hidden" ,
170
171
} ) ;
171
172
} ) ;
173
+
172
174
describe ( "definitionContainers" , ( ) => {
173
175
it ( "showing definition container makes it and all of its contained elements visible" , async function ( ) {
174
176
await using buildIModelResult = await buildIModel ( this , async ( builder ) => {
@@ -259,13 +261,13 @@ describe("CategoriesTreeVisibilityHandler", () => {
259
261
handler,
260
262
viewport,
261
263
expectations : {
262
- [ keys . definitionContainerRoot2 . id ] : "hidden" ,
263
264
[ keys . definitionContainerRoot . id ] : "visible" ,
264
265
[ keys . definitionContainerChild . id ] : "visible" ,
265
- [ keys . category2 . id ] : "hidden" ,
266
266
[ keys . indirectCategory . id ] : "visible" ,
267
- [ keys . subCategory2 . id ] : "hidden" ,
268
267
[ keys . indirectSubCategory . id ] : "visible" ,
268
+ [ keys . definitionContainerRoot2 . id ] : "hidden" ,
269
+ [ keys . category2 . id ] : "hidden" ,
270
+ [ keys . subCategory2 . id ] : "hidden" ,
269
271
} ,
270
272
} ) ;
271
273
} ) ;
@@ -780,44 +782,6 @@ describe("CategoriesTreeVisibilityHandler", () => {
780
782
} ) ;
781
783
} ) ;
782
784
783
- describe ( "hideSubCategories set to true" , ( ) => {
784
- it ( "showing subCategory does not do anything" , async function ( ) {
785
- await using buildIModelResult = await buildIModel ( this , async ( builder ) => {
786
- const physicalModel = insertPhysicalModelWithPartition ( { builder, codeValue : "TestPhysicalModel" } ) ;
787
- const definitionContainerRoot = insertDefinitionContainer ( { builder, codeValue : "DefinitionContainerRoot" } ) ;
788
- const definitionModelRoot = insertSubModel ( { builder, classFullName : CLASS_NAME_DefinitionModel , modeledElementId : definitionContainerRoot . id } ) ;
789
-
790
- const category = insertSpatialCategory ( { builder, codeValue : "SpatialCategory" , modelId : definitionModelRoot . id } ) ;
791
- insertPhysicalElement ( { builder, modelId : physicalModel . id , categoryId : category . id } ) ;
792
- const subCategory = insertSubCategory ( {
793
- builder,
794
- parentCategoryId : category . id ,
795
- codeValue : "subCategory" ,
796
- modelId : definitionModelRoot . id ,
797
- } ) ;
798
- return { category, subCategory, definitionContainerRoot, physicalModel } ;
799
- } ) ;
800
-
801
- const { imodel, ...keys } = buildIModelResult ;
802
-
803
- using visibilityTestData = await createVisibilityTestData ( {
804
- imodel,
805
- ...getModelAndCategoryIds ( keys ) ,
806
- hierarchyConfig : { hideSubCategories : true } ,
807
- } ) ;
808
- const { handler, provider, viewport } = visibilityTestData ;
809
- setupInitialDisplayState ( { viewport, ...createHiddenTestData ( keys ) } ) ;
810
-
811
- await handler . changeVisibility ( createSubCategoryHierarchyNode ( keys . subCategory . id , keys . category . id ) , true ) ;
812
- await validateHierarchyVisibility ( {
813
- provider,
814
- handler,
815
- viewport,
816
- expectations : "all-hidden" ,
817
- } ) ;
818
- } ) ;
819
- } ) ;
820
-
821
785
describe ( "showElements set to true" , ( ) => {
822
786
describe ( "definitionContainers" , ( ) => {
823
787
it ( "showing definition container makes it and all of its contained elements visible" , async function ( ) {
@@ -1790,9 +1754,7 @@ describe("CategoriesTreeVisibilityHandler", () => {
1790
1754
elementId : ids . subModelElement ?. id ,
1791
1755
} ) ,
1792
1756
expectations : ( ids : IModelWithSubModelIds ) => ( {
1793
- // This happens because changing element state does not turn on category visiblity, it only turns on model display if it is off.
1794
- // Since subModelCategory is also displayed at tree root (it does not have children) it's visibility remains hidden.
1795
- [ ids . subModelCategory ?. id ?? "" ] : "hidden" ,
1757
+ [ ids . subModelCategory ?. id ?? "" ] : "visible" ,
1796
1758
[ `${ ids . modeledElement . id } -${ ids . subModelCategory ?. id ?? "" } ` ] : "visible" ,
1797
1759
[ ids . category . id ] : "partial" ,
1798
1760
[ ids . modeledElement . id ] : "partial" ,
@@ -2664,38 +2626,6 @@ describe("CategoriesTreeVisibilityHandler", () => {
2664
2626
} ) ;
2665
2627
} ) ;
2666
2628
2667
- describe ( "hideSubCategories set to true" , ( ) => {
2668
- it ( "showing subCategory does not do anything" , async function ( ) {
2669
- await using buildIModelResult = await buildIModel ( this , async ( builder ) => {
2670
- const physicalModel = insertPhysicalModelWithPartition ( { builder, codeValue : "TestPhysicalModel" } ) ;
2671
- const definitionContainerRoot = insertDefinitionContainer ( { builder, codeValue : "DefinitionContainerRoot" } ) ;
2672
- const definitionModelRoot = insertSubModel ( { builder, classFullName : CLASS_NAME_DefinitionModel , modeledElementId : definitionContainerRoot . id } ) ;
2673
-
2674
- const category = insertSpatialCategory ( { builder, codeValue : "SpatialCategory" , modelId : definitionModelRoot . id } ) ;
2675
- insertPhysicalElement ( { builder, modelId : physicalModel . id , categoryId : category . id } ) ;
2676
- const subCategory = insertSubCategory ( {
2677
- builder,
2678
- parentCategoryId : category . id ,
2679
- codeValue : "subCategory" ,
2680
- modelId : definitionModelRoot . id ,
2681
- } ) ;
2682
- return { category, subCategory, definitionContainerRoot, physicalModel } ;
2683
- } ) ;
2684
-
2685
- const { imodel, ...keys } = buildIModelResult ;
2686
- using visibilityTestData = await createVisibilityTestData ( { imodel, ...getModelAndCategoryIds ( keys ) , hierarchyConfig : { hideSubCategories : true } } ) ;
2687
- const { handler, provider, viewport } = visibilityTestData ;
2688
- setupInitialDisplayState ( { viewport } ) ;
2689
-
2690
- await handler . changeVisibility ( createSubCategoryHierarchyNode ( keys . subCategory . id , keys . category . id ) , true ) ;
2691
- await validateHierarchyVisibility ( {
2692
- provider,
2693
- handler,
2694
- viewport,
2695
- expectations : "all-visible" ,
2696
- } ) ;
2697
- } ) ;
2698
- } ) ;
2699
2629
describe ( "disabling category visibility through overrides" , ( ) => {
2700
2630
it ( "category is hidden when only one model contains category and override is set to 'Hide'" , async function ( ) {
2701
2631
await using buildIModelResult = await buildIModel ( this , async ( builder ) => {
0 commit comments