@@ -305,6 +305,11 @@ test.after.each(() => {
305
305
306
306
// This test sends a payload that is not an emergency label
307
307
test ( "recieves pull_request.labeled event, does nothing because not emergency label" , async function ( ) {
308
+ // mock the request to check if the user is a member of the emergency team
309
+ const mock = nock ( "https://api.github.com" )
310
+ . get ( `/orgs/robandpdx/teams/emergency/memberships/robandpdx?org=robandpdx&team_slug=emergency&username=robandpdx` )
311
+ . reply ( 200 , payloadMembershipResponse ) ;
312
+
308
313
await probot . receive ( {
309
314
name : "pull_request" ,
310
315
id : "1" ,
@@ -321,6 +326,7 @@ test("recieves pull_request.labeled event, does nothing because not emergency la
321
326
}
322
327
} ,
323
328
} ) ;
329
+ assert . equal ( mock . pendingMocks ( ) , [ ] ) ;
324
330
} ) ;
325
331
326
332
// This test will do all 4 things: approve, create issue, merge, and send slack notification
@@ -717,7 +723,7 @@ test("recieves pull_request.labeled event, approve (fails), create issue, merge"
717
723
await probot . receive ( payloadPrLabeled ) ;
718
724
} catch ( err ) {
719
725
assert . equal ( mock . pendingMocks ( ) , [ ] ) ;
720
- assert . equal ( err . errors [ 0 ] [ 0 ] . message , "request to https://api.github.com/repos/robandpdx/superbigmono/pulls/1/reviews failed, reason: something awful happened" ) ;
726
+ assert . equal ( err . errors [ 0 ] [ 0 ] . message , "something awful happened" ) ;
721
727
assert . equal ( err . errors [ 0 ] . length , 1 ) ;
722
728
return ;
723
729
}
@@ -754,7 +760,7 @@ test("recieves pull_request.labeled event, approve, create issue (fails), merge"
754
760
await probot . receive ( payloadPrLabeled ) ;
755
761
} catch ( err ) {
756
762
assert . equal ( mock . pendingMocks ( ) , [ ] ) ;
757
- assert . equal ( err . errors [ 0 ] [ 0 ] . message , "request to https://api.github.com/repos/robandpdx/superbigmono/issues failed, reason: something awful happened" ) ;
763
+ assert . equal ( err . errors [ 0 ] [ 0 ] . message , "something awful happened" ) ;
758
764
assert . equal ( err . errors [ 0 ] . length , 1 ) ;
759
765
return ;
760
766
}
@@ -791,7 +797,7 @@ test("recieves pull_request.labeled event, approve, create issue, merge (fails)"
791
797
await probot . receive ( payloadPrLabeled ) ;
792
798
} catch ( err ) {
793
799
assert . equal ( mock . pendingMocks ( ) , [ ] ) ;
794
- assert . equal ( err . errors [ 0 ] [ 0 ] . message , "request to https://api.github.com/repos/robandpdx/superbigmono/pulls/1/merge failed, reason: something awful happened" ) ;
800
+ assert . equal ( err . errors [ 0 ] [ 0 ] . message , "something awful happened" ) ;
795
801
assert . equal ( err . errors [ 0 ] . length , 1 ) ;
796
802
return ;
797
803
}
@@ -804,7 +810,7 @@ test("recieves pull_request.unlabeled event, reapply emergency label", async fun
804
810
const mock = nock ( "https://api.github.com" )
805
811
. post ( "/repos/robandpdx/superbigmono/issues/1/labels" ,
806
812
( requestBody ) => {
807
- assert . equal ( requestBody [ 0 ] , "emergency" ) ;
813
+ assert . equal ( requestBody . labels [ 0 ] , "emergency" ) ;
808
814
return true ;
809
815
}
810
816
)
@@ -828,7 +834,7 @@ test("recieves pull_request.unlabeled event, fail to reapply emergency label", a
828
834
const mock = nock ( "https://api.github.com" )
829
835
. post ( "/repos/robandpdx/superbigmono/issues/1/labels" ,
830
836
( requestBody ) => {
831
- assert . equal ( requestBody [ 0 ] , "emergency" ) ;
837
+ assert . equal ( requestBody . labels [ 0 ] , "emergency" ) ;
832
838
return true ;
833
839
}
834
840
)
@@ -838,7 +844,7 @@ test("recieves pull_request.unlabeled event, fail to reapply emergency label", a
838
844
await probot . receive ( payloadUnlabeled ) ;
839
845
} catch ( err ) {
840
846
assert . equal ( mock . pendingMocks ( ) , [ ] ) ;
841
- assert . equal ( err . errors [ 0 ] [ 0 ] . message , "request to https://api.github.com/repos/robandpdx/superbigmono/issues/1/labels failed, reason: something awful happened" ) ;
847
+ assert . equal ( err . errors [ 0 ] [ 0 ] . message , "something awful happened" ) ;
842
848
assert . equal ( err . errors [ 0 ] . length , 1 ) ;
843
849
return ;
844
850
}
@@ -859,7 +865,7 @@ test("recieves issue.unlabeled event, reapply emergency label", async function (
859
865
const mock = nock ( "https://api.github.com" )
860
866
. post ( "/repos/robandpdx/superbigmono/issues/1/labels" ,
861
867
( requestBody ) => {
862
- assert . equal ( requestBody [ 0 ] , "emergency" ) ;
868
+ assert . equal ( requestBody . labels [ 0 ] , "emergency" ) ;
863
869
return true ;
864
870
}
865
871
)
@@ -883,7 +889,7 @@ test("recieves issue.unlabeled event, fail to reapply emergency label", async fu
883
889
const mock = nock ( "https://api.github.com" )
884
890
. post ( "/repos/robandpdx/superbigmono/issues/1/labels" ,
885
891
( requestBody ) => {
886
- assert . equal ( requestBody [ 0 ] , "emergency" ) ;
892
+ assert . equal ( requestBody . labels [ 0 ] , "emergency" ) ;
887
893
return true ;
888
894
}
889
895
)
@@ -893,7 +899,7 @@ test("recieves issue.unlabeled event, fail to reapply emergency label", async fu
893
899
await probot . receive ( payloadIssueUnlabeled ) ;
894
900
} catch ( err ) {
895
901
assert . equal ( mock . pendingMocks ( ) , [ ] ) ;
896
- assert . equal ( err . errors [ 0 ] [ 0 ] . message , "request to https://api.github.com/repos/robandpdx/superbigmono/issues/1/labels failed, reason: something awful happened" ) ;
902
+ assert . equal ( err . errors [ 0 ] [ 0 ] . message , "something awful happened" ) ;
897
903
assert . equal ( err . errors [ 0 ] . length , 1 ) ;
898
904
return ;
899
905
}
@@ -913,7 +919,7 @@ test("recieves pull_request.opened event, applies emergency label", async functi
913
919
const mock = nock ( "https://api.github.com" )
914
920
. post ( "/repos/robandpdx/superbigmono/issues/1/labels" ,
915
921
( requestBody ) => {
916
- assert . equal ( requestBody [ 0 ] , "emergency" ) ;
922
+ assert . equal ( requestBody . labels [ 0 ] , "emergency" ) ;
917
923
return true ;
918
924
}
919
925
)
@@ -931,7 +937,7 @@ test("recieves pull_request.opened event, applies emergency label checking team
931
937
const mock = nock ( "https://api.github.com" )
932
938
. post ( "/repos/robandpdx/superbigmono/issues/1/labels" ,
933
939
( requestBody ) => {
934
- assert . equal ( requestBody [ 0 ] , "emergency" ) ;
940
+ assert . equal ( requestBody . labels [ 0 ] , "emergency" ) ;
935
941
return true ;
936
942
}
937
943
)
@@ -972,7 +978,7 @@ test("recieves pull_request.opened event, fails to apply emergency label", async
972
978
const mock = nock ( "https://api.github.com" )
973
979
. post ( "/repos/robandpdx/superbigmono/issues/1/labels" ,
974
980
( requestBody ) => {
975
- assert . equal ( requestBody [ 0 ] , "emergency" ) ;
981
+ assert . equal ( requestBody . labels [ 0 ] , "emergency" ) ;
976
982
return true ;
977
983
}
978
984
)
@@ -982,7 +988,7 @@ test("recieves pull_request.opened event, fails to apply emergency label", async
982
988
await probot . receive ( payloadPrOpened ) ;
983
989
} catch ( err ) {
984
990
assert . equal ( mock . pendingMocks ( ) , [ ] ) ;
985
- assert . equal ( err . errors [ 0 ] [ 0 ] . message , "request to https://api.github.com/repos/robandpdx/superbigmono/issues/1/labels failed, reason: something awful happened" ) ;
991
+ assert . equal ( err . errors [ 0 ] [ 0 ] . message , "something awful happened" ) ;
986
992
assert . equal ( err . errors [ 0 ] . length , 1 ) ;
987
993
return ;
988
994
}
@@ -1000,7 +1006,7 @@ test("recieves issue_comment.created event, applies emergency label", async func
1000
1006
const mock = nock ( "https://api.github.com" )
1001
1007
. post ( "/repos/robandpdx/superbigmono/issues/1/labels" ,
1002
1008
( requestBody ) => {
1003
- assert . equal ( requestBody [ 0 ] , "emergency" ) ;
1009
+ assert . equal ( requestBody . labels [ 0 ] , "emergency" ) ;
1004
1010
return true ;
1005
1011
}
1006
1012
)
@@ -1018,7 +1024,7 @@ test("recieves issue_comment.created event, applies emergency label", async func
1018
1024
const mock = nock ( "https://api.github.com" )
1019
1025
. post ( "/repos/robandpdx/superbigmono/issues/1/labels" ,
1020
1026
( requestBody ) => {
1021
- assert . equal ( requestBody [ 0 ] , "emergency" ) ;
1027
+ assert . equal ( requestBody . labels [ 0 ] , "emergency" ) ;
1022
1028
return true ;
1023
1029
}
1024
1030
)
@@ -1102,7 +1108,7 @@ test("recieves issue_comment.created event, failes to apply emergency label", as
1102
1108
const mock = nock ( "https://api.github.com" )
1103
1109
. post ( "/repos/robandpdx/superbigmono/issues/1/labels" ,
1104
1110
( requestBody ) => {
1105
- assert . equal ( requestBody [ 0 ] , "emergency" ) ;
1111
+ assert . equal ( requestBody . labels [ 0 ] , "emergency" ) ;
1106
1112
return true ;
1107
1113
}
1108
1114
)
@@ -1112,7 +1118,7 @@ test("recieves issue_comment.created event, failes to apply emergency label", as
1112
1118
await probot . receive ( payloadPrComment ) ;
1113
1119
} catch ( err ) {
1114
1120
assert . equal ( mock . pendingMocks ( ) , [ ] ) ;
1115
- assert . equal ( err . errors [ 0 ] [ 0 ] . message , "request to https://api.github.com/repos/robandpdx/superbigmono/issues/1/labels failed, reason: something awful happened" ) ;
1121
+ assert . equal ( err . errors [ 0 ] [ 0 ] . message , "something awful happened" ) ;
1116
1122
assert . equal ( err . errors [ 0 ] . length , 1 ) ;
1117
1123
return ;
1118
1124
}
0 commit comments