@@ -25,6 +25,8 @@ const {
2525 jenkinsCI,
2626 requestingChangesReviews,
2727 noReviewers,
28+ commentsWithFastTrack,
29+ commentsWithFastTrackInsuffientApprovals,
2830 commentsWithCI,
2931 commentsWithFailedCI,
3032 commentsWithLGTM,
@@ -533,6 +535,149 @@ describe('PRChecker', () => {
533535 cli . assertCalledWith ( expectedLogs ) ;
534536 } ) ;
535537
538+ it ( 'should error with 1 fast-track approval from the pr author' , ( ) => {
539+ const cli = new TestCLI ( ) ;
540+
541+ const expectedLogs = {
542+ ok :
543+ [ [ 'Approvals: 4' ] ,
544+ [ '- Foo User (@foo): https://github.com/nodejs/node/pull/16438#pullrequestreview-71480624' ] ,
545+ [ '- Quux User (@Quux): LGTM' ] ,
546+ [ '- Baz User (@Baz): https://github.com/nodejs/node/pull/16438#pullrequestreview-71488236' ] ,
547+ [ '- Bar User (@bar) (TSC): lgtm' ] ] ,
548+ info :
549+ [ [ 'This PR was created on Fri, 30 Nov 2018 17:50:44 GMT' ] ,
550+ [ 'This PR is being fast-tracked' ] ] ,
551+ error :
552+ [ [ 'The fast-track request requires at' +
553+ " least two collaborators' approvals (👍)." ] ]
554+ } ;
555+
556+ const pr = Object . assign ( { } , firstTimerPR , {
557+ author : {
558+ login : 'bar'
559+ } ,
560+ createdAt : LT_48H ,
561+ labels : {
562+ nodes : [
563+ { name : 'fast-track' }
564+ ]
565+ }
566+ } ) ;
567+
568+ const data = {
569+ pr,
570+ reviewers : allGreenReviewers ,
571+ comments : commentsWithFastTrack ,
572+ reviews : approvingReviews ,
573+ commits : [ ] ,
574+ collaborators,
575+ authorIsNew : ( ) => true ,
576+ getThread ( ) {
577+ return PRData . prototype . getThread . call ( this ) ;
578+ }
579+ } ;
580+ const checker = new PRChecker ( cli , data , { } , argv ) ;
581+
582+ cli . clearCalls ( ) ;
583+ const status = checker . checkReviewsAndWait ( new Date ( NOW ) ) ;
584+ assert ( ! status ) ;
585+ cli . assertCalledWith ( expectedLogs ) ;
586+ } ) ;
587+
588+ it ( 'should error when insufficient fast-track approvals' , ( ) => {
589+ const cli = new TestCLI ( ) ;
590+
591+ const expectedLogs = {
592+ ok :
593+ [ [ 'Approvals: 4' ] ,
594+ [ '- Foo User (@foo): https://github.com/nodejs/node/pull/16438#pullrequestreview-71480624' ] ,
595+ [ '- Quux User (@Quux): LGTM' ] ,
596+ [ '- Baz User (@Baz): https://github.com/nodejs/node/pull/16438#pullrequestreview-71488236' ] ,
597+ [ '- Bar User (@bar) (TSC): lgtm' ] ] ,
598+ info :
599+ [ [ 'This PR was created on Fri, 30 Nov 2018 17:50:44 GMT' ] ,
600+ [ 'This PR is being fast-tracked' ] ] ,
601+ error :
602+ [ [ 'The fast-track request requires at' +
603+ " least one collaborator's approval (👍)." ] ]
604+ } ;
605+
606+ const pr = Object . assign ( { } , firstTimerPR , {
607+ createdAt : LT_48H ,
608+ labels : {
609+ nodes : [
610+ { name : 'fast-track' }
611+ ]
612+ }
613+ } ) ;
614+
615+ const data = {
616+ pr,
617+ reviewers : allGreenReviewers ,
618+ comments : commentsWithFastTrackInsuffientApprovals ,
619+ reviews : approvingReviews ,
620+ commits : [ ] ,
621+ collaborators,
622+ authorIsNew : ( ) => true ,
623+ getThread ( ) {
624+ return PRData . prototype . getThread . call ( this ) ;
625+ }
626+ } ;
627+ const checker = new PRChecker ( cli , data , { } , argv ) ;
628+
629+ cli . clearCalls ( ) ;
630+ const status = checker . checkReviewsAndWait ( new Date ( NOW ) ) ;
631+ assert ( ! status ) ;
632+ cli . assertCalledWith ( expectedLogs ) ;
633+ } ) ;
634+
635+ it ( 'should error when missing fast-track request comment' , ( ) => {
636+ const cli = new TestCLI ( ) ;
637+
638+ const expectedLogs = {
639+ ok :
640+ [ [ 'Approvals: 4' ] ,
641+ [ '- Foo User (@foo): https://github.com/nodejs/node/pull/16438#pullrequestreview-71480624' ] ,
642+ [ '- Quux User (@Quux): LGTM' ] ,
643+ [ '- Baz User (@Baz): https://github.com/nodejs/node/pull/16438#pullrequestreview-71488236' ] ,
644+ [ '- Bar User (@bar) (TSC): lgtm' ] ] ,
645+ info :
646+ [ [ 'This PR was created on Fri, 30 Nov 2018 17:50:44 GMT' ] ,
647+ [ 'This PR is being fast-tracked' ] ] ,
648+ error :
649+ [ [ 'Unable to find the fast-track request comment.' ] ]
650+ } ;
651+
652+ const pr = Object . assign ( { } , firstTimerPR , {
653+ createdAt : LT_48H ,
654+ labels : {
655+ nodes : [
656+ { name : 'fast-track' }
657+ ]
658+ }
659+ } ) ;
660+
661+ const data = {
662+ pr,
663+ reviewers : allGreenReviewers ,
664+ comments : commentsWithLGTM ,
665+ reviews : approvingReviews ,
666+ commits : [ ] ,
667+ collaborators,
668+ authorIsNew : ( ) => true ,
669+ getThread ( ) {
670+ return PRData . prototype . getThread . call ( this ) ;
671+ }
672+ } ;
673+ const checker = new PRChecker ( cli , data , { } , argv ) ;
674+
675+ cli . clearCalls ( ) ;
676+ const status = checker . checkReviewsAndWait ( new Date ( NOW ) ) ;
677+ assert ( ! status ) ;
678+ cli . assertCalledWith ( expectedLogs ) ;
679+ } ) ;
680+
536681 it ( 'should warn about approvals and CI for fast-tracked PR' , ( ) => {
537682 const cli = new TestCLI ( ) ;
538683
0 commit comments