@@ -913,53 +913,129 @@ describe('ReposTable', () => {
913
913
name : 'Repo name 1' ,
914
914
latestCommitAt : subDays ( new Date ( ) , 3 ) . toISOString ( ) ,
915
915
coverageAnalytics : {
916
- percentCovered : 0 ,
916
+ percentCovered : 10 ,
917
917
lines : 123 ,
918
918
} ,
919
919
active : true ,
920
920
updatedAt : '2020-08-25T16:36:19.67986800:00' ,
921
921
repositoryConfig : null ,
922
- coverageEnabled : false ,
922
+ coverageEnabled : true ,
923
923
bundleAnalysisEnabled : false ,
924
924
} ,
925
925
} ,
926
+ ]
927
+
928
+ let reposToReturn = myRepos . filter (
929
+ ( repo ) =>
930
+ ! info . variables . filters . term ||
931
+ repo . node . name . includes ( info . variables . filters . term )
932
+ )
933
+
934
+ if ( info . variables . owner === 'codecov' ) {
935
+ reposToReturn = demoRepo
936
+ }
937
+
938
+ return HttpResponse . json ( {
939
+ data : {
940
+ owner : {
941
+ repositories : {
942
+ edges : reposToReturn ,
943
+ pageInfo : {
944
+ hasNextPage : false ,
945
+ endCursor : '3' ,
946
+ } ,
947
+ } ,
948
+ } ,
949
+ } ,
950
+ } )
951
+ } )
952
+ )
953
+ } )
954
+
955
+ it ( 'shows demo repo and your repos when on your owner page' , async ( ) => {
956
+ render ( < ReposTable searchValue = "" owner = "owner1" mayIncludeDemo /> , {
957
+ wrapper : wrapper ( '' , '/github/owner1' , '/:provider/:owner' ) ,
958
+ } )
959
+ const demoLink = await screen . findAllByText ( / C o d e c o v d e m o / )
960
+ expect ( demoLink . length ) . toBe ( 1 )
961
+ const links = await screen . findAllByText ( / R e p o n a m e / )
962
+ expect ( links . length ) . toBe ( 1 )
963
+ } )
964
+
965
+ it ( 'shows demo repo when search term includes it' , async ( ) => {
966
+ render ( < ReposTable searchValue = "dem" owner = "owner1" mayIncludeDemo /> , {
967
+ wrapper : wrapper ( '' , '/github/owner1' , '/:provider/:owner' ) ,
968
+ } )
969
+ const repo = screen . queryByText ( / R e p o n a m e / )
970
+ expect ( repo ) . not . toBeInTheDocument ( )
971
+ const demoLink = await screen . findAllByText ( / C o d e c o v d e m o / )
972
+ expect ( demoLink . length ) . toBe ( 1 )
973
+ } )
974
+
975
+ it ( 'hides demo repo when user has 2 or more repos configured' , async ( ) => {
976
+ server . use (
977
+ graphql . query ( 'ReposForOwner' , async ( info ) => {
978
+ const demoRepo = [
926
979
{
927
980
node : {
928
- private : true ,
981
+ private : false ,
929
982
activated : true ,
983
+ author : {
984
+ username : 'codecov' ,
985
+ } ,
986
+ name : 'gazebo' ,
987
+ latestCommitAt : subDays ( new Date ( ) , 3 ) . toISOString ( ) ,
988
+ coverageAnalytics : {
989
+ percentCovered : 0 ,
990
+ lines : 123 ,
991
+ } ,
992
+ active : true ,
993
+ updatedAt : '2020-08-25T16:36:19.67986800:00' ,
994
+ repositoryConfig : null ,
995
+ coverageEnabled : true ,
996
+ bundleAnalysisEnabled : true ,
997
+ } ,
998
+ } ,
999
+ ]
1000
+
1001
+ const myRepos = [
1002
+ {
1003
+ node : {
1004
+ private : false ,
1005
+ activated : false ,
930
1006
author : {
931
1007
username : 'owner1' ,
932
1008
} ,
933
- name : 'Repo name 2 ' ,
934
- latestCommitAt : subDays ( new Date ( ) , 2 ) . toISOString ( ) ,
1009
+ name : 'Repo name 1 ' ,
1010
+ latestCommitAt : subDays ( new Date ( ) , 3 ) . toISOString ( ) ,
935
1011
coverageAnalytics : {
936
- percentCovered : 100 ,
1012
+ percentCovered : 10 ,
937
1013
lines : 123 ,
938
1014
} ,
939
1015
active : true ,
940
1016
updatedAt : '2020-08-25T16:36:19.67986800:00' ,
941
1017
repositoryConfig : null ,
942
- coverageEnabled : false ,
1018
+ coverageEnabled : true ,
943
1019
bundleAnalysisEnabled : false ,
944
1020
} ,
945
1021
} ,
946
1022
{
947
1023
node : {
948
- private : true ,
1024
+ private : false ,
949
1025
activated : false ,
950
1026
author : {
951
1027
username : 'owner1' ,
952
1028
} ,
953
- name : 'Repo name 3 ' ,
954
- latestCommitAt : subDays ( new Date ( ) , 5 ) . toISOString ( ) ,
1029
+ name : 'Repo name 1 ' ,
1030
+ latestCommitAt : subDays ( new Date ( ) , 3 ) . toISOString ( ) ,
955
1031
coverageAnalytics : {
956
- percentCovered : null ,
1032
+ percentCovered : 0 ,
957
1033
lines : 123 ,
958
1034
} ,
959
- active : false ,
1035
+ active : true ,
960
1036
updatedAt : '2020-08-25T16:36:19.67986800:00' ,
961
1037
repositoryConfig : null ,
962
- coverageEnabled : false ,
1038
+ coverageEnabled : true ,
963
1039
bundleAnalysisEnabled : false ,
964
1040
} ,
965
1041
} ,
@@ -990,26 +1066,13 @@ describe('ReposTable', () => {
990
1066
} )
991
1067
} )
992
1068
)
993
- } )
994
-
995
- it ( 'shows demo repo and your repos when on your owner page' , async ( ) => {
996
1069
render ( < ReposTable searchValue = "" owner = "owner1" mayIncludeDemo /> , {
997
1070
wrapper : wrapper ( '' , '/github/owner1' , '/:provider/:owner' ) ,
998
1071
} )
999
1072
const links = await screen . findAllByText ( / R e p o n a m e / )
1000
- expect ( links . length ) . toBe ( 3 )
1001
- const demoLink = await screen . findAllByText ( / C o d e c o v d e m o / )
1002
- expect ( demoLink . length ) . toBe ( 1 )
1003
- } )
1004
-
1005
- it ( 'shows demo repo when search term includes it' , async ( ) => {
1006
- render ( < ReposTable searchValue = "dem" owner = "owner1" mayIncludeDemo /> , {
1007
- wrapper : wrapper ( '' , '/github/owner1' , '/:provider/:owner' ) ,
1008
- } )
1009
- const repo = screen . queryByText ( / R e p o n a m e / )
1010
- expect ( repo ) . not . toBeInTheDocument ( )
1011
- const demoLink = await screen . findAllByText ( / C o d e c o v d e m o / )
1012
- expect ( demoLink . length ) . toBe ( 1 )
1073
+ expect ( links . length ) . toBe ( 2 )
1074
+ const demoLink = screen . queryAllByText ( / C o d e c o v d e m o / )
1075
+ expect ( demoLink . length ) . toBe ( 0 )
1013
1076
} )
1014
1077
} )
1015
1078
} )
0 commit comments