@@ -8,15 +8,19 @@ import { configureTestSuite } from '../../test-utils/configure-suite';
88import { ColumnPinningPosition , RowPinningPosition } from '../common/enums' ;
99import { IPinningConfig } from '../common/grid.interface' ;
1010import { SampleTestData } from '../../test-utils/sample-test-data.spec' ;
11- import { verifyLayoutHeadersAreAligned , verifyDOMMatchesLayoutSettings } from '../../test-utils/helper-utils.spec' ;
11+ import {
12+ verifyLayoutHeadersAreAligned ,
13+ verifyDOMMatchesLayoutSettings ,
14+ setupGridScrollDetection
15+ } from '../../test-utils/helper-utils.spec' ;
1216import { GridFunctions } from '../../test-utils/grid-functions.spec' ;
1317import { SortingDirection } from '../../data-operations/sorting-expression.interface' ;
1418import { IgxGridTransaction } from '../tree-grid' ;
1519import { IgxTransactionService } from '../../services' ;
1620import { GridSummaryFunctions } from '../../test-utils/grid-functions.spec' ;
1721import { IgxStringFilteringOperand } from '../../data-operations/filtering-condition' ;
1822import { IgxPaginatorComponent } from '../../paginator/paginator.component' ;
19- import { wait } from '../../test-utils/ui-interactions.spec' ;
23+ import { wait , UIInteractions } from '../../test-utils/ui-interactions.spec' ;
2024
2125describe ( 'Row Pinning #grid' , ( ) => {
2226 const FIXED_ROW_CONTAINER = '.igx-grid__tr--pinned ' ;
@@ -439,7 +443,7 @@ describe('Row Pinning #grid', () => {
439443 pinRowContainer = fix . debugElement . queryAll ( By . css ( FIXED_ROW_CONTAINER ) ) ;
440444 expect ( pinRowContainer . length ) . toBe ( 0 ) ;
441445
442- expect ( grid . dataView . length ) . toBe ( 6 ) ;
446+ expect ( grid . dataView . length ) . toBe ( 5 ) ;
443447 expect ( paginator . componentInstance . totalPages ) . toEqual ( 6 ) ;
444448 } ) ;
445449
@@ -774,6 +778,233 @@ describe('Row Pinning #grid', () => {
774778 expect ( grid . calcHeight - expectedHeight ) . toBeLessThanOrEqual ( 1 ) ;
775779 } ) ;
776780 } ) ;
781+
782+ describe ( ' Navigation' , ( ) => {
783+ let gridContent : DebugElement ;
784+
785+ beforeEach ( ( ) => {
786+ fix = TestBed . createComponent ( GridRowPinningComponent ) ;
787+ fix . detectChanges ( ) ;
788+ grid = fix . componentInstance . instance ;
789+ setupGridScrollDetection ( fix , grid ) ;
790+ gridContent = GridFunctions . getGridContent ( fix ) ;
791+ } ) ;
792+
793+ it ( 'should navigate to bottom from top pinned row using Ctrl+ArrowDown' , async ( ) => {
794+ grid . getRowByIndex ( 5 ) . pin ( ) ;
795+ fix . detectChanges ( ) ;
796+
797+ const firstRowCell = grid . getRowByIndex ( 0 ) . cells . toArray ( ) [ 1 ] ;
798+ UIInteractions . simulateClickAndSelectCellEvent ( firstRowCell ) ;
799+ fix . detectChanges ( ) ;
800+
801+ UIInteractions . triggerEventHandlerKeyDown ( 'ArrowDown' , gridContent , false , false , true ) ;
802+ await wait ( DEBOUNCE_TIME ) ;
803+ fix . detectChanges ( ) ;
804+ await wait ( DEBOUNCE_TIME ) ;
805+ fix . detectChanges ( ) ;
806+
807+ const lastRowCell = grid . getRowByIndex ( 27 ) . cells . toArray ( ) [ 1 ] ;
808+ const selectedCell = fix . componentInstance . instance . selectedCells [ 0 ] ;
809+ expect ( selectedCell ) . toBe ( lastRowCell ) ;
810+ expect ( selectedCell . rowIndex ) . toBe ( 27 ) ;
811+ } ) ;
812+
813+ it ( 'should navigate and scroll to first unpinned row from top pinned row using ArrowDown' , async ( ) => {
814+ grid . getRowByIndex ( 5 ) . pin ( ) ;
815+ fix . detectChanges ( ) ;
816+
817+ grid . navigateTo ( 10 ) ;
818+ await wait ( DEBOUNCE_TIME ) ;
819+ fix . detectChanges ( ) ;
820+
821+ const firstRowCell = grid . getRowByIndex ( 0 ) . cells . toArray ( ) [ 1 ] ;
822+ UIInteractions . simulateClickAndSelectCellEvent ( firstRowCell ) ;
823+ fix . detectChanges ( ) ;
824+
825+ UIInteractions . triggerEventHandlerKeyDown ( 'ArrowDown' , gridContent ) ;
826+ await wait ( DEBOUNCE_TIME ) ;
827+ fix . detectChanges ( ) ;
828+ await wait ( DEBOUNCE_TIME ) ;
829+ fix . detectChanges ( ) ;
830+
831+ const secondRowCell = grid . getRowByIndex ( 1 ) . cells . toArray ( ) [ 1 ] ;
832+ const selectedCell = fix . componentInstance . instance . selectedCells [ 0 ] ;
833+ expect ( selectedCell ) . toBe ( secondRowCell ) ;
834+ expect ( selectedCell . rowIndex ) . toBe ( 1 ) ;
835+ } ) ;
836+
837+ it ( 'should navigate to top pinned row from bottom unpinned row without scrolling using Ctrl+ArrowUp' , async ( ) => {
838+ grid . getRowByIndex ( 5 ) . pin ( ) ;
839+ fix . detectChanges ( ) ;
840+
841+ grid . navigateTo ( 27 ) ;
842+ await wait ( DEBOUNCE_TIME ) ;
843+ fix . detectChanges ( ) ;
844+
845+ expect ( grid . verticalScrollContainer . getScroll ( ) . scrollTop ) . not . toEqual ( 0 ) ;
846+
847+ const lastRowCell = grid . getRowByIndex ( 27 ) . cells . toArray ( ) [ 1 ] ;
848+ UIInteractions . simulateClickAndSelectCellEvent ( lastRowCell ) ;
849+ fix . detectChanges ( ) ;
850+
851+ UIInteractions . triggerEventHandlerKeyDown ( 'ArrowUp' , gridContent , false , false , true ) ;
852+ await wait ( DEBOUNCE_TIME ) ;
853+ fix . detectChanges ( ) ;
854+ await wait ( DEBOUNCE_TIME ) ;
855+ fix . detectChanges ( ) ;
856+
857+ const firstRowCell = grid . getRowByIndex ( 0 ) . cells . toArray ( ) [ 1 ] ;
858+ const selectedCell = fix . componentInstance . instance . selectedCells [ 0 ] ;
859+ expect ( selectedCell ) . toBe ( firstRowCell ) ;
860+ expect ( selectedCell . rowIndex ) . toBe ( 0 ) ;
861+ expect ( grid . verticalScrollContainer . getScroll ( ) . scrollTop ) . not . toEqual ( 0 ) ;
862+ } ) ;
863+
864+ it ( 'should navigate to top pinned row from first unpinned row using ArrowUp' , async ( ) => {
865+ grid . getRowByIndex ( 5 ) . pin ( ) ;
866+ grid . getRowByIndex ( 1 ) . pin ( ) ;
867+ fix . detectChanges ( ) ;
868+
869+ const thirdRowCell = grid . getRowByIndex ( 2 ) . cells . toArray ( ) [ 1 ] ;
870+ UIInteractions . simulateClickAndSelectCellEvent ( thirdRowCell ) ;
871+ fix . detectChanges ( ) ;
872+
873+ expect ( grid . navigation . activeNode . row ) . toBe ( 2 ) ;
874+ expect ( grid . navigation . activeNode . column ) . toBe ( 1 ) ;
875+
876+ UIInteractions . triggerEventHandlerKeyDown ( 'ArrowUp' , gridContent ) ;
877+ await wait ( DEBOUNCE_TIME ) ;
878+ fix . detectChanges ( ) ;
879+
880+ const secondRowCell = grid . getRowByIndex ( 1 ) . cells . toArray ( ) [ 1 ] ;
881+ const selectedCell = fix . componentInstance . instance . selectedCells [ 0 ] ;
882+ expect ( selectedCell ) . toBe ( secondRowCell ) ;
883+ expect ( selectedCell . rowIndex ) . toBe ( 1 ) ;
884+ } ) ;
885+
886+ it ( 'should navigate and scroll to top from bottom pinned row using Ctrl+ArrowUp' , async ( ) => {
887+ fix . componentInstance . pinningConfig = { columns : ColumnPinningPosition . Start , rows : RowPinningPosition . Bottom } ;
888+ grid . getRowByIndex ( 5 ) . pin ( ) ;
889+ fix . detectChanges ( ) ;
890+
891+ grid . navigateTo ( 26 ) ;
892+ await wait ( DEBOUNCE_TIME ) ;
893+ fix . detectChanges ( ) ;
894+
895+ const lastRowCell = grid . getRowByIndex ( 27 ) . cells . toArray ( ) [ 1 ] ;
896+ UIInteractions . simulateClickAndSelectCellEvent ( lastRowCell ) ;
897+ fix . detectChanges ( ) ;
898+
899+ expect ( grid . navigation . activeNode . row ) . toBe ( 27 ) ;
900+ expect ( grid . navigation . activeNode . column ) . toBe ( 1 ) ;
901+
902+ UIInteractions . triggerEventHandlerKeyDown ( 'ArrowUp' , gridContent , false , false , true ) ;
903+ await wait ( DEBOUNCE_TIME ) ;
904+ fix . detectChanges ( ) ;
905+ await wait ( DEBOUNCE_TIME ) ;
906+ fix . detectChanges ( ) ;
907+
908+ const firstRowCell = grid . getRowByIndex ( 0 ) . cells . toArray ( ) [ 1 ] ;
909+ const selectedCell = fix . componentInstance . instance . selectedCells [ 0 ] ;
910+ expect ( selectedCell ) . toBe ( firstRowCell ) ;
911+ expect ( selectedCell . rowIndex ) . toBe ( 0 ) ;
912+ } ) ;
913+
914+ it ( 'should navigate to last unpinned row from bottom pinned row using ArrowUp' , async ( ) => {
915+ fix . componentInstance . pinningConfig = { columns : ColumnPinningPosition . Start , rows : RowPinningPosition . Bottom } ;
916+ grid . getRowByIndex ( 5 ) . pin ( ) ;
917+ fix . detectChanges ( ) ;
918+
919+ const firstRowCell = grid . getRowByIndex ( 27 ) . cells . toArray ( ) [ 1 ] ;
920+ UIInteractions . simulateClickAndSelectCellEvent ( firstRowCell ) ;
921+ fix . detectChanges ( ) ;
922+
923+ UIInteractions . triggerEventHandlerKeyDown ( 'ArrowUp' , gridContent ) ;
924+ await wait ( DEBOUNCE_TIME ) ;
925+ fix . detectChanges ( ) ;
926+ await wait ( DEBOUNCE_TIME ) ;
927+ fix . detectChanges ( ) ;
928+
929+ const lastUnpinnedRowCell = grid . getRowByIndex ( 26 ) . cells . toArray ( ) [ 1 ] ;
930+ const selectedCell = fix . componentInstance . instance . selectedCells [ 0 ] ;
931+ expect ( selectedCell ) . toBe ( lastUnpinnedRowCell ) ;
932+ expect ( selectedCell . rowIndex ) . toBe ( 26 ) ;
933+ } ) ;
934+
935+ it ( 'should navigate to bottom pinned row from top unpinned row without scrolling using Ctrl+ArrowDown' , async ( ) => {
936+ fix . componentInstance . pinningConfig = { columns : ColumnPinningPosition . Start , rows : RowPinningPosition . Bottom } ;
937+ grid . getRowByIndex ( 5 ) . pin ( ) ;
938+ fix . detectChanges ( ) ;
939+
940+ expect ( grid . verticalScrollContainer . getScroll ( ) . scrollTop ) . toEqual ( 0 ) ;
941+
942+ const firstRowCell = grid . getRowByIndex ( 0 ) . cells . toArray ( ) [ 1 ] ;
943+ UIInteractions . simulateClickAndSelectCellEvent ( firstRowCell ) ;
944+ fix . detectChanges ( ) ;
945+
946+ UIInteractions . triggerEventHandlerKeyDown ( 'ArrowDown' , gridContent , false , false , true ) ;
947+ await wait ( DEBOUNCE_TIME ) ;
948+ fix . detectChanges ( ) ;
949+ await wait ( DEBOUNCE_TIME ) ;
950+ fix . detectChanges ( ) ;
951+
952+ const lastRowCell = grid . getRowByIndex ( 27 ) . cells . toArray ( ) [ 1 ] ;
953+ const selectedCell = fix . componentInstance . instance . selectedCells [ 0 ] ;
954+ expect ( selectedCell ) . toBe ( lastRowCell ) ;
955+ expect ( selectedCell . rowIndex ) . toBe ( 27 ) ;
956+ expect ( grid . verticalScrollContainer . getScroll ( ) . scrollTop ) . toEqual ( 0 ) ;
957+ } ) ;
958+
959+ it ( 'should navigate to bottom pinned row from last unpinned row using ArrowDown' , async ( ) => {
960+ fix . componentInstance . pinningConfig = { columns : ColumnPinningPosition . Start , rows : RowPinningPosition . Bottom } ;
961+ grid . getRowByIndex ( 5 ) . pin ( ) ;
962+ grid . getRowByIndex ( 1 ) . pin ( ) ;
963+ fix . detectChanges ( ) ;
964+
965+ grid . navigateTo ( 26 ) ;
966+ await wait ( DEBOUNCE_TIME ) ;
967+ fix . detectChanges ( ) ;
968+
969+ const firstRowCell = grid . getRowByIndex ( 26 ) . cells . toArray ( ) [ 1 ] ;
970+ UIInteractions . simulateClickAndSelectCellEvent ( firstRowCell ) ;
971+ fix . detectChanges ( ) ;
972+
973+ expect ( grid . navigation . activeNode . row ) . toBe ( 26 ) ;
974+ expect ( grid . navigation . activeNode . column ) . toBe ( 1 ) ;
975+
976+ UIInteractions . triggerEventHandlerKeyDown ( 'ArrowDown' , gridContent ) ;
977+ await wait ( DEBOUNCE_TIME ) ;
978+ fix . detectChanges ( ) ;
979+
980+ const lastRowCell = grid . getRowByIndex ( 27 ) . cells . toArray ( ) [ 1 ] ;
981+ const selectedCell = fix . componentInstance . instance . selectedCells [ 0 ] ;
982+ expect ( selectedCell ) . toBe ( lastRowCell ) ;
983+ expect ( selectedCell . rowIndex ) . toBe ( 27 ) ;
984+ } ) ;
985+
986+ it ( 'should navigate down from pinned to unpinned row when there are filtered out pinned rows' , async ( ) => {
987+ grid . getRowByIndex ( 5 ) . pin ( ) ;
988+ grid . getRowByIndex ( 1 ) . pin ( ) ;
989+ fix . detectChanges ( ) ;
990+
991+ grid . filter ( 'ID' , 'B' , IgxStringFilteringOperand . instance ( ) . condition ( 'contains' ) , false ) ;
992+ fix . detectChanges ( ) ;
993+
994+ const firstRowCell = grid . getRowByIndex ( 0 ) . cells . toArray ( ) [ 1 ] ;
995+ UIInteractions . simulateClickAndSelectCellEvent ( firstRowCell ) ;
996+ fix . detectChanges ( ) ;
997+
998+ UIInteractions . triggerEventHandlerKeyDown ( 'ArrowDown' , gridContent ) ;
999+ await wait ( DEBOUNCE_TIME ) ;
1000+ fix . detectChanges ( ) ;
1001+
1002+ const lastRowCell = grid . getRowByIndex ( 1 ) . cells . toArray ( ) [ 1 ] ;
1003+ const selectedCell = fix . componentInstance . instance . selectedCells [ 0 ] ;
1004+ expect ( selectedCell ) . toBe ( lastRowCell ) ;
1005+ expect ( selectedCell . rowIndex ) . toBe ( 1 ) ;
1006+ } ) ;
1007+ } ) ;
7771008} ) ;
7781009
7791010@Component ( {
0 commit comments