@@ -523,6 +523,70 @@ describe('resize in rtl', () => {
523523 } ) ;
524524} ) ;
525525
526+ describe ( 'Error handling when getResizerElements returns null' , ( ) => {
527+ const singleColumnDefinition = [ { id : 'id' , header : 'Id' , cell : ( item : any ) => item . id , width : 150 , minWidth : 80 } ] ;
528+
529+ beforeEach ( ( ) => {
530+ jest . doMock ( '../../../lib/components/table/resizer/resizer-lookup' , ( ) => ( {
531+ ...jest . requireActual ( '../../../lib/components/table/resizer/resizer-lookup' ) ,
532+ getResizerElements : jest . fn ( ( ) => null ) ,
533+ } ) ) ;
534+ } ) ;
535+
536+ afterEach ( ( ) => {
537+ jest . resetModules ( ) ;
538+ } ) ;
539+
540+ test ( 'gracefully handles null getResizerElements during resize operations' , ( ) => {
541+ const onChange = jest . fn ( ) ;
542+ const { wrapper } = renderTable (
543+ < Table
544+ { ...defaultProps }
545+ columnDefinitions = { singleColumnDefinition }
546+ onColumnWidthsChange = { event => onChange ( event . detail ) }
547+ />
548+ ) ;
549+
550+ // Test updateColumnWidth and resizeColumn (lines 78, 155)
551+ // When getResizerElements returns null, the functions return early without DOM manipulation
552+ // but onWidthUpdate callback is still called (before the null check)
553+ expect ( ( ) => {
554+ firePointerdown ( wrapper . findColumnResizer ( 1 ) ! ) ;
555+ firePointermove ( 200 ) ;
556+ firePointerup ( 200 ) ;
557+ } ) . not . toThrow ( ) ;
558+
559+ // onChange is called because onWidthUpdate is invoked before the null check
560+ expect ( onChange ) . toHaveBeenCalledTimes ( 1 ) ;
561+ expect ( onChange ) . toHaveBeenCalledWith ( { widths : [ 200 ] } ) ;
562+ } ) ;
563+
564+ test ( 'gracefully handles null getResizerElements in UAP button clicks' , ( ) => {
565+ const onChange = jest . fn ( ) ;
566+ const { wrapper } = renderTable (
567+ < Table
568+ { ...defaultProps }
569+ columnDefinitions = { singleColumnDefinition }
570+ onColumnWidthsChange = { event => onChange ( event . detail ) }
571+ />
572+ ) ;
573+
574+ // Show UAP buttons
575+ wrapper . findColumnResizer ( 1 ) ! . click ( ) ;
576+
577+ // Test onDirectionClick (line 173) - should not throw or trigger onChange
578+ expect ( ( ) => {
579+ const dragHandle = findDragHandle ( ) ;
580+ const inlineEndButton = dragHandle . findVisibleDirectionButtonInlineEnd ( ) ;
581+ if ( inlineEndButton ) {
582+ inlineEndButton . click ( ) ;
583+ }
584+ } ) . not . toThrow ( ) ;
585+
586+ expect ( onChange ) . not . toHaveBeenCalled ( ) ;
587+ } ) ;
588+ } ) ;
589+
526590describe ( 'UAP buttons' , ( ) => {
527591 // Makes the drag buttons (which are positioned in a portal) easier to find if there's only one set.
528592 const singleColumnDefinition = [ { id : 'id' , header : 'Id' , cell : ( item : any ) => item . id , width : 150 , minWidth : 80 } ] ;
0 commit comments