@@ -9,6 +9,7 @@ import { BasicGridSearchComponent } from '../test-utils/grid-base-components.spe
9
9
import { SampleTestData } from '../test-utils/sample-test-data.spec' ;
10
10
import { GridWithAvatarComponent , GroupableGridSearchComponent , ScrollableGridSearchComponent } from '../test-utils/grid-samples.spec' ;
11
11
import { IForOfState } from '../directives/for-of/for_of.directive' ;
12
+ import { wait } from '../test-utils/ui-interactions.spec' ;
12
13
13
14
describe ( 'IgxGrid - search API' , ( ) => {
14
15
const CELL_CSS_CLASS = '.igx-grid__td' ;
@@ -639,8 +640,8 @@ describe('IgxGrid - search API', () => {
639
640
} ) ;
640
641
641
642
/* ScrollableGrid */
642
- xdescribe ( '' , ( ) => {
643
- beforeEach ( ( ) => {
643
+ describe ( '' , ( ) => {
644
+ beforeEach ( async ( ) => {
644
645
fix = TestBed . createComponent ( ScrollableGridSearchComponent ) ;
645
646
fix . detectChanges ( ) ;
646
647
@@ -649,30 +650,31 @@ describe('IgxGrid - search API', () => {
649
650
grid . data [ 29 ] = { ID : 30 , Name : 'Eduardo Ramirez' , JobTitle : 'Manager' , HireDate : '1887-11-28T11:23:17.714Z' } ;
650
651
grid . width = '500px' ;
651
652
grid . height = '600px' ;
653
+ await wait ( ) ;
652
654
fixNativeElement = fix . debugElement . nativeElement ;
653
655
fix . detectChanges ( ) ;
654
656
} ) ;
655
657
656
- it ( 'findNext scrolls to cells out of view' , ( done ) => {
657
- findNext ( grid , '30' ) . then ( ( ) => {
658
- expect ( isInView ( 29 , grid . virtualizationState ) ) . toBeTruthy ( ) ;
658
+ it ( 'findNext scrolls to cells out of view' , async ( ) => {
659
+ grid . findNext ( '30' ) ;
660
+ await wait ( ) ;
661
+ expect ( isInView ( 29 , grid . virtualizationState ) ) . toBeTruthy ( ) ;
659
662
660
- findNext ( grid , '1887' ) . then ( ( ) => {
661
- expect ( isInView ( 3 , grid . rowList . first . virtDirRow . state ) ) . toBeTruthy ( ) ;
662
- done ( ) ;
663
- } ) ;
664
- } ) ;
663
+ grid . findNext ( '1887' ) ;
664
+ await wait ( ) ;
665
+ expect ( isInView ( 3 , grid . rowList . first . virtDirRow . state ) ) . toBeTruthy ( ) ;
665
666
} ) ;
666
667
667
- it ( 'findPrev scrolls to cells out of view' , ( done ) => {
668
- findNext ( grid , '30' ) . then ( ( ) => {
669
- expect ( isInView ( 29 , grid . virtualizationState ) ) . toBeTruthy ( ) ;
668
+ it ( 'findPrev scrolls to cells out of view' , async ( ) => {
669
+ grid . findPrev ( '30' ) ;
670
+ await wait ( ) ;
671
+ fix . detectChanges ( ) ;
672
+ expect ( isInView ( 29 , grid . virtualizationState ) ) . toBeTruthy ( ) ;
670
673
671
- findNext ( grid , '1887' ) . then ( ( ) => {
672
- expect ( isInView ( 3 , grid . rowList . first . virtDirRow . state ) ) . toBeTruthy ( ) ;
673
- done ( ) ;
674
- } ) ;
675
- } ) ;
674
+ grid . findPrev ( '1887' ) ;
675
+ await wait ( ) ;
676
+ fix . detectChanges ( ) ;
677
+ expect ( isInView ( 3 , grid . rowList . first . virtDirRow . state ) ) . toBeTruthy ( ) ;
676
678
} ) ;
677
679
678
680
it ( 'should keep the active highlight when active cell enters and exits edit mode' , ( ) => {
@@ -743,7 +745,7 @@ describe('IgxGrid - search API', () => {
743
745
expect ( activeHighlight ) . toBe ( highlights [ 0 ] ) ;
744
746
} ) ;
745
747
746
- it ( 'should update highlights when the cell value is cleared' , ( ) => {
748
+ it ( 'should update highlights when the cell value is cleared' , async ( ) => {
747
749
const rv = fix . debugElement . queryAll ( By . css ( CELL_CSS_CLASS ) ) [ 1 ] . nativeElement ;
748
750
const rv2 = fix . debugElement . queryAll ( By . css ( CELL_CSS_CLASS ) ) [ 2 ] . nativeElement ;
749
751
const cell = grid . getCellByColumn ( 0 , 'Name' ) ;
@@ -754,6 +756,7 @@ describe('IgxGrid - search API', () => {
754
756
cell . column . editable = true ;
755
757
756
758
grid . findNext ( 'c' ) ;
759
+ await wait ( ) ;
757
760
fix . detectChanges ( ) ;
758
761
759
762
activeHighlight = rv . querySelector ( '.' + component . activeClass ) ;
@@ -780,31 +783,32 @@ describe('IgxGrid - search API', () => {
780
783
expect ( activeHighlight ) . toBe ( highlights [ 0 ] ) ;
781
784
} ) ;
782
785
783
- it ( 'Should update highlight when setting perPage option' , ( done ) => {
786
+ it ( 'Should update highlight when setting perPage option' , async ( ) => {
784
787
grid . paging = true ;
785
788
fix . detectChanges ( ) ;
786
789
787
790
const searchString = 'casey' ;
788
791
789
792
grid . findNext ( searchString ) ;
790
- findNextWithPaging ( grid , searchString ) . then ( ( ) => {
791
- fix . detectChanges ( ) ;
792
- let highlight = grid . nativeElement . querySelector ( '.' + component . activeClass ) ;
793
- expect ( highlight ) . not . toBeNull ( ) ;
794
- expect ( grid . page ) . toBe ( 0 ) ;
795
- grid . perPage = 10 ;
796
- fix . detectChanges ( ) ;
797
-
798
- highlight = grid . nativeElement . querySelector ( '.' + component . activeClass ) ;
799
- expect ( highlight ) . toBeNull ( ) ;
800
- expect ( grid . page ) . toBe ( 0 ) ;
801
-
802
- grid . page = 1 ;
803
- fix . detectChanges ( ) ;
804
- highlight = grid . nativeElement . querySelector ( '.' + component . activeClass ) ;
805
- expect ( highlight ) . not . toBeNull ( ) ;
806
- done ( ) ;
807
- } ) ;
793
+ grid . findNext ( searchString ) ;
794
+ await wait ( ) ;
795
+ fix . detectChanges ( ) ;
796
+ let highlight = grid . nativeElement . querySelector ( '.' + component . activeClass ) ;
797
+ expect ( highlight ) . not . toBeNull ( ) ;
798
+ expect ( grid . page ) . toBe ( 0 ) ;
799
+
800
+ grid . perPage = 10 ;
801
+ fix . detectChanges ( ) ;
802
+
803
+ highlight = grid . nativeElement . querySelector ( '.' + component . activeClass ) ;
804
+ expect ( highlight ) . toBeNull ( ) ;
805
+ expect ( grid . page ) . toBe ( 0 ) ;
806
+
807
+ grid . page = 1 ;
808
+ await wait ( 30 ) ;
809
+ fix . detectChanges ( ) ;
810
+ highlight = grid . nativeElement . querySelector ( '.' + component . activeClass ) ;
811
+ expect ( highlight ) . not . toBeNull ( ) ;
808
812
} ) ;
809
813
} ) ;
810
814
@@ -819,12 +823,13 @@ describe('IgxGrid - search API', () => {
819
823
fixNativeElement = fix . debugElement . nativeElement ;
820
824
} ) ;
821
825
822
- it ( 'Should be able to navigate through highlights with grouping enabled' , ( ) => {
826
+ it ( 'Should be able to navigate through highlights with grouping enabled' , async ( ) => {
823
827
grid . groupBy ( {
824
828
fieldName : 'JobTitle' ,
825
829
dir : SortingDirection . Asc
826
830
} ) ;
827
831
grid . findNext ( 'Software' ) ;
832
+ await wait ( ) ;
828
833
fix . detectChanges ( ) ;
829
834
830
835
let spans = fixNativeElement . querySelectorAll ( '.' + component . highlightClass ) ;
@@ -834,13 +839,17 @@ describe('IgxGrid - search API', () => {
834
839
835
840
grid . findNext ( 'Software' ) ;
836
841
grid . findNext ( 'Software' ) ;
842
+ await wait ( ) ;
843
+ fix . detectChanges ( ) ;
837
844
838
845
spans = fixNativeElement . querySelectorAll ( '.' + component . highlightClass ) ;
839
846
highlight = fixNativeElement . querySelector ( '.' + component . activeClass ) ;
840
847
expect ( spans . length ) . toBe ( 5 ) ;
841
848
expect ( highlight ) . toBe ( spans [ 2 ] ) ;
842
849
843
850
grid . findPrev ( 'Software' ) ;
851
+ await wait ( ) ;
852
+ fix . detectChanges ( ) ;
844
853
845
854
spans = fixNativeElement . querySelectorAll ( '.' + component . highlightClass ) ;
846
855
highlight = fixNativeElement . querySelector ( '.' + component . activeClass ) ;
@@ -849,21 +858,25 @@ describe('IgxGrid - search API', () => {
849
858
850
859
grid . findPrev ( 'Software' ) ;
851
860
grid . findPrev ( 'Software' ) ;
861
+ await wait ( ) ;
862
+ fix . detectChanges ( ) ;
852
863
853
864
spans = fixNativeElement . querySelectorAll ( '.' + component . highlightClass ) ;
854
865
highlight = fixNativeElement . querySelector ( '.' + component . activeClass ) ;
855
866
expect ( spans . length ) . toBe ( 5 ) ;
856
867
expect ( highlight ) . toBe ( spans [ 4 ] ) ;
857
868
} ) ;
858
869
859
- it ( 'Should be able to react to changes in grouping' , ( ) => {
870
+ it ( 'Should be able to react to changes in grouping' , async ( ) => {
860
871
grid . groupBy ( {
861
872
fieldName : 'JobTitle' ,
862
873
dir : SortingDirection . Asc
863
874
} ) ;
864
875
865
876
let cell = grid . getCellByColumn ( 1 , 'JobTitle' ) ;
866
877
grid . findNext ( 'software' ) ;
878
+ await wait ( ) ;
879
+ fix . detectChanges ( ) ;
867
880
868
881
let highlight = cell . nativeElement . querySelector ( '.' + component . activeClass ) ;
869
882
expect ( highlight !== null ) . toBeTruthy ( ) ;
@@ -895,22 +908,24 @@ describe('IgxGrid - search API', () => {
895
908
} ) ;
896
909
897
910
grid . findNext ( 'software' ) ;
911
+ await wait ( ) ;
912
+ fix . detectChanges ( ) ;
898
913
cell = grid . getCellByColumn ( 5 , 'JobTitle' ) ;
899
914
highlight = cell . nativeElement . querySelector ( '.' + component . activeClass ) ;
900
915
expect ( highlight !== null ) . toBeTruthy ( ) ;
901
916
} ) ;
902
917
903
- it ( 'Should be able to navigate through highlights with grouping and paging enabled' , ( ) => {
918
+ it ( 'Should be able to navigate through highlights with grouping and paging enabled' , async ( ) => {
904
919
grid . groupBy ( {
905
920
fieldName : 'JobTitle' ,
906
921
dir : SortingDirection . Asc
907
922
} ) ;
908
923
grid . paging = true ;
909
924
grid . perPage = 6 ;
910
925
911
- fix . detectChanges ( ) ;
912
-
913
926
grid . findNext ( 'Software' ) ;
927
+ await wait ( ) ;
928
+ fix . detectChanges ( ) ;
914
929
915
930
let spans = fixNativeElement . querySelectorAll ( '.' + component . highlightClass ) ;
916
931
let highlight = fixNativeElement . querySelector ( '.' + component . activeClass ) ;
@@ -920,6 +935,7 @@ describe('IgxGrid - search API', () => {
920
935
expect ( grid . page ) . toBe ( 0 ) ;
921
936
922
937
grid . findPrev ( 'Software' ) ;
938
+ await wait ( ) ;
923
939
fix . detectChanges ( ) ;
924
940
925
941
spans = fixNativeElement . querySelectorAll ( '.' + component . highlightClass ) ;
@@ -931,6 +947,8 @@ describe('IgxGrid - search API', () => {
931
947
932
948
grid . findPrev ( 'Software' ) ;
933
949
grid . findPrev ( 'Software' ) ;
950
+ await wait ( ) ;
951
+ fix . detectChanges ( ) ;
934
952
935
953
spans = fixNativeElement . querySelectorAll ( '.' + component . highlightClass ) ;
936
954
highlight = fixNativeElement . querySelector ( '.' + component . activeClass ) ;
@@ -940,7 +958,7 @@ describe('IgxGrid - search API', () => {
940
958
expect ( grid . page ) . toBe ( 1 ) ;
941
959
} ) ;
942
960
943
- it ( 'Should be able to properly handle perPage changes with gouping and paging' , ( ) => {
961
+ it ( 'Should be able to properly handle perPage changes with gouping and paging' , async ( ) => {
944
962
grid . groupBy ( {
945
963
fieldName : 'JobTitle' ,
946
964
dir : SortingDirection . Asc
@@ -951,6 +969,7 @@ describe('IgxGrid - search API', () => {
951
969
grid . findNext ( 'Software' ) ;
952
970
grid . findNext ( 'Software' ) ;
953
971
grid . findNext ( 'Software' ) ;
972
+ await wait ( ) ;
954
973
fix . detectChanges ( ) ;
955
974
956
975
let spans = fixNativeElement . querySelectorAll ( '.' + component . highlightClass ) ;
@@ -971,6 +990,7 @@ describe('IgxGrid - search API', () => {
971
990
expect ( grid . page ) . toBe ( 0 ) ;
972
991
973
992
grid . page = 1 ;
993
+ await wait ( ) ;
974
994
fix . detectChanges ( ) ;
975
995
976
996
spans = fixNativeElement . querySelectorAll ( '.' + component . highlightClass ) ;
@@ -981,7 +1001,7 @@ describe('IgxGrid - search API', () => {
981
1001
expect ( grid . page ) . toBe ( 1 ) ;
982
1002
} ) ;
983
1003
984
- it ( 'Should be able to properly handle navigating through collapsed rows' , ( ) => {
1004
+ it ( 'Should be able to properly handle navigating through collapsed rows' , async ( ) => {
985
1005
grid . groupBy ( {
986
1006
fieldName : 'JobTitle' ,
987
1007
dir : SortingDirection . Asc
@@ -992,6 +1012,8 @@ describe('IgxGrid - search API', () => {
992
1012
grid . findNext ( 'software' ) ;
993
1013
994
1014
grid . toggleGroup ( grid . groupsRecords [ 0 ] ) ;
1015
+ await wait ( ) ;
1016
+ fix . detectChanges ( ) ;
995
1017
996
1018
let spans = fixNativeElement . querySelectorAll ( '.' + component . highlightClass ) ;
997
1019
let highlight = fixNativeElement . querySelector ( '.' + component . activeClass ) ;
@@ -1002,6 +1024,8 @@ describe('IgxGrid - search API', () => {
1002
1024
grid . findNext ( 'software' ) ;
1003
1025
grid . findNext ( 'software' ) ;
1004
1026
grid . findNext ( 'software' ) ;
1027
+ await wait ( ) ;
1028
+ fix . detectChanges ( ) ;
1005
1029
1006
1030
spans = fixNativeElement . querySelectorAll ( '.' + component . highlightClass ) ;
1007
1031
highlight = fixNativeElement . querySelector ( '.' + component . activeClass ) ;
@@ -1011,7 +1035,7 @@ describe('IgxGrid - search API', () => {
1011
1035
expect ( grid . isExpandedGroup ( grid . groupsRecords [ 0 ] ) ) . toBeTruthy ( ) ;
1012
1036
} ) ;
1013
1037
1014
- it ( 'Should be able to properly handle navigating through collapsed rows with paging' , ( ) => {
1038
+ it ( 'Should be able to properly handle navigating through collapsed rows with paging' , async ( ) => {
1015
1039
grid . groupBy ( {
1016
1040
fieldName : 'JobTitle' ,
1017
1041
dir : SortingDirection . Asc
@@ -1023,10 +1047,13 @@ describe('IgxGrid - search API', () => {
1023
1047
1024
1048
grid . findNext ( 'software' ) ;
1025
1049
grid . findNext ( 'software' ) ;
1050
+ await wait ( ) ;
1051
+ fix . detectChanges ( ) ;
1026
1052
1027
1053
grid . toggleGroup ( grid . groupsRecords [ 0 ] ) ;
1028
1054
grid . findNext ( 'software' ) ;
1029
1055
1056
+ await wait ( ) ;
1030
1057
fix . detectChanges ( ) ;
1031
1058
let spans = fixNativeElement . querySelectorAll ( '.' + component . highlightClass ) ;
1032
1059
let highlight = fixNativeElement . querySelector ( '.' + component . activeClass ) ;
@@ -1038,6 +1065,7 @@ describe('IgxGrid - search API', () => {
1038
1065
grid . findNext ( 'software' ) ;
1039
1066
grid . findNext ( 'software' ) ;
1040
1067
grid . findNext ( 'software' ) ;
1068
+ await wait ( ) ;
1041
1069
fix . detectChanges ( ) ;
1042
1070
1043
1071
spans = fixNativeElement . querySelectorAll ( '.' + component . highlightClass ) ;
0 commit comments