1+ import { TestUtils } from '@deephaven/test-utils' ;
12import { type AxisRange , type BoundedAxisRange } from './GridAxisRange' ;
23import { type ModelIndex , type MoveOperation } from './GridMetrics' ;
34import type GridMetrics from './GridMetrics' ;
4- import GridModel from './GridModel' ;
5+ import type GridModel from './GridModel' ;
56import GridRange , { type GridRangeIndex } from './GridRange' ;
7+ import GridTheme from './GridTheme' ;
68import GridUtils , { type Token , type TokenBox } from './GridUtils' ;
79
810function expectModelIndexes (
@@ -1114,42 +1116,52 @@ describe('getColumnSeparatorIndex', () => {
11141116 allRowHeights : new Map ( ) ,
11151117 } ) ;
11161118
1117- class MockGroupedGridModel extends GridModel {
1118- private headerGroups : Map < number , Map < number , string > > ;
1119+ /**
1120+ * Creates a mock GridModel with grouped column headers for testing
1121+ */
1122+ const createMockGroupedGridModel = (
1123+ headerGroups : Map < number , Map < number , string > >
1124+ ) : GridModel =>
1125+ TestUtils . createMockProxy < GridModel > ( {
1126+ columnCount : 4 ,
1127+ rowCount : 100 ,
1128+ columnHeaderMaxDepth : headerGroups . size ,
1129+ textForColumnHeader : ( column : ModelIndex , depth = 0 ) =>
1130+ headerGroups . get ( depth ) ?. get ( column ) ?? '' ,
1131+ } ) ;
11191132
1120- constructor ( headerGroups : Map < number , Map < number , string > > ) {
1121- super ( ) ;
1122- this . headerGroups = headerGroups ;
1123- }
1124-
1125- // eslint-disable-next-line class-methods-use-this
1126- get rowCount ( ) : number {
1127- return 100 ;
1128- }
1129-
1130- // eslint-disable-next-line class-methods-use-this
1131- get columnCount ( ) : number {
1132- return 4 ;
1133- }
1133+ it ( 'detects separator at column boundary' , ( ) => {
1134+ const metrics = createMockMetrics ( ) as GridMetrics ;
1135+ const x = 150 ; // At boundary between column 0 and 1 (100 + 50)
1136+ const y = 15 ; // In header area
11341137
1135- // eslint-disable-next-line class-methods-use-this
1136- get columnHeaderMaxDepth ( ) : number {
1137- return 2 ;
1138- }
1138+ const headerGroups = new Map ( [
1139+ [
1140+ 0 ,
1141+ new Map ( [
1142+ [ 0 , 'A' ] ,
1143+ [ 1 , 'B' ] ,
1144+ [ 2 , 'C' ] ,
1145+ [ 3 , 'D' ] ,
1146+ ] ) ,
1147+ ] ,
1148+ ] ) ;
1149+ const model = createMockGroupedGridModel ( headerGroups ) ;
11391150
1140- // eslint-disable-next-line class-methods-use-this
1141- textForCell ( column : ModelIndex , row : ModelIndex ) : string {
1142- return `${ column } ,${ row } ` ;
1143- }
1151+ const result = GridUtils . getColumnSeparatorIndex (
1152+ x ,
1153+ y ,
1154+ metrics ,
1155+ mockTheme ,
1156+ model
1157+ ) ;
11441158
1145- textForColumnHeader ( column : ModelIndex , depth = 0 ) : string | undefined {
1146- return this . headerGroups . get ( depth ) ?. get ( column ) ;
1147- }
1148- }
1159+ expect ( result ) . toBe ( 0 ) ;
1160+ } ) ;
11491161
1150- it ( 'detects separator at column boundary ' , ( ) => {
1162+ it ( 'detects there is no separator within the column ' , ( ) => {
11511163 const metrics = createMockMetrics ( ) as GridMetrics ;
1152- const x = 150 ; // At boundary between column 0 and 1 (100 + 50)
1164+ const x = 120 ; // Within column 1
11531165 const y = 15 ; // In header area
11541166
11551167 const headerGroups = new Map ( [
@@ -1163,7 +1175,7 @@ describe('getColumnSeparatorIndex', () => {
11631175 ] ) ,
11641176 ] ,
11651177 ] ) ;
1166- const model = new MockGroupedGridModel ( headerGroups ) ;
1178+ const model = createMockGroupedGridModel ( headerGroups ) ;
11671179
11681180 const result = GridUtils . getColumnSeparatorIndex (
11691181 x ,
@@ -1173,13 +1185,12 @@ describe('getColumnSeparatorIndex', () => {
11731185 model
11741186 ) ;
11751187
1176- expect ( result ) . toBe ( 0 ) ;
1188+ expect ( result ) . toBe ( null ) ;
11771189 } ) ;
11781190
11791191 it ( 'should return null at depth 1 when no separator exists (columns in same group)' , ( ) => {
11801192 // Depth 0 (base columns): A, B, C, D
11811193 // Depth 1 (groups): Group1, Group1, Group2, Group2
1182- // This is the core bug fix: hovering at group level where separator doesn't exist
11831194 const headerGroups = new Map ( [
11841195 [
11851196 0 ,
@@ -1200,7 +1211,7 @@ describe('getColumnSeparatorIndex', () => {
12001211 ] ) ,
12011212 ] ,
12021213 ] ) ;
1203- const model = new MockGroupedGridModel ( headerGroups ) ;
1214+ const model = createMockGroupedGridModel ( headerGroups ) ;
12041215 const metrics = createMockMetrics ( 2 ) as GridMetrics ;
12051216
12061217 const x = 150 ; // Between column 0 and 1
@@ -1214,7 +1225,7 @@ describe('getColumnSeparatorIndex', () => {
12141225 model
12151226 ) ;
12161227
1217- expect ( result ) . toBeNull ( ) ; // No separator at depth 1 (both in Group1)
1228+ expect ( result ) . toBeNull ( ) ;
12181229 } ) ;
12191230
12201231 it ( 'should detect separator at depth 1 when groups differ' , ( ) => {
@@ -1240,7 +1251,7 @@ describe('getColumnSeparatorIndex', () => {
12401251 ] ) ,
12411252 ] ,
12421253 ] ) ;
1243- const model = new MockGroupedGridModel ( headerGroups ) ;
1254+ const model = createMockGroupedGridModel ( headerGroups ) ;
12441255 const metrics = createMockMetrics ( 2 ) as GridMetrics ;
12451256
12461257 const x = 250 ; // Between column 1 (Group1) and 2 (Group2)
@@ -1254,6 +1265,6 @@ describe('getColumnSeparatorIndex', () => {
12541265 model
12551266 ) ;
12561267
1257- expect ( result ) . toBe ( 1 ) ; // Separator exists at depth 1 (Group1 vs Group2)
1268+ expect ( result ) . toBe ( 1 ) ;
12581269 } ) ;
12591270} ) ;
0 commit comments