@@ -1773,6 +1773,35 @@ describe("PullRequestDetail", () => {
17731773 expect ( lastFrame ( ) ) . toBe ( before ) ;
17741774 } ) ;
17751775
1776+ it ( "t key does nothing on small diff footer" , ( ) => {
1777+ const { stdin, lastFrame } = render (
1778+ < PullRequestDetail
1779+ pullRequest = { pullRequest as any }
1780+ differences = { differences as any }
1781+ commentThreads = { [ ] }
1782+ diffTexts = { diffTexts }
1783+ onBack = { vi . fn ( ) }
1784+ onHelp = { vi . fn ( ) }
1785+ onShowActivity = { vi . fn ( ) }
1786+ comment = { { onPost : vi . fn ( ) , isProcessing : false , error : null , onClearError : vi . fn ( ) } }
1787+ inlineComment = { defaultInlineCommentProps }
1788+ reply = { defaultReplyProps }
1789+ approval = { defaultApprovalProps }
1790+ merge = { defaultMergeProps }
1791+ close = { defaultCloseProps }
1792+ commitView = { defaultCommitProps }
1793+ editComment = { defaultEditCommentProps }
1794+ deleteComment = { defaultDeleteCommentProps }
1795+ reaction = { defaultReactionProps }
1796+ /> ,
1797+ ) ;
1798+
1799+ stdin . write ( "G" ) ;
1800+ const before = lastFrame ( ) ;
1801+ stdin . write ( "t" ) ;
1802+ expect ( lastFrame ( ) ) . toBe ( before ) ;
1803+ } ) ;
1804+
17761805 it ( "t key does nothing on non-diff line" , ( ) => {
17771806 const { stdin, lastFrame } = render (
17781807 < PullRequestDetail
@@ -5377,6 +5406,40 @@ describe("PullRequestDetail", () => {
53775406 stdin . write ( "C" ) ; // try to inline comment
53785407 expect ( lastFrame ( ) ) . not . toContain ( "Inline comment on" ) ;
53795408 } ) ;
5409+
5410+ it ( "f and g keys are disabled in commit view" , async ( ) => {
5411+ const { lastFrame, stdin } = render (
5412+ < PullRequestDetail
5413+ pullRequest = { pullRequest as any }
5414+ differences = { differences as any }
5415+ commentThreads = { [ ] }
5416+ diffTexts = { diffTexts }
5417+ onBack = { vi . fn ( ) }
5418+ onHelp = { vi . fn ( ) }
5419+ onShowActivity = { vi . fn ( ) }
5420+ comment = { { onPost : vi . fn ( ) , isProcessing : false , error : null , onClearError : vi . fn ( ) } }
5421+ inlineComment = { defaultInlineCommentProps }
5422+ reply = { defaultReplyProps }
5423+ approval = { defaultApprovalProps }
5424+ merge = { defaultMergeProps }
5425+ close = { defaultCloseProps }
5426+ commitView = { { ...defaultCommitProps , commits : sampleCommits , commitsAvailable : true } }
5427+ editComment = { defaultEditCommentProps }
5428+ deleteComment = { defaultDeleteCommentProps }
5429+ reaction = { defaultReactionProps }
5430+ /> ,
5431+ ) ;
5432+ stdin . write ( "\t" ) ; // switch to commit view
5433+ await vi . waitFor ( ( ) => {
5434+ expect ( lastFrame ( ) ) . toContain ( "[Commit 1/3]" ) ;
5435+ } ) ;
5436+ const before = lastFrame ( ) ;
5437+ stdin . write ( "f" ) ;
5438+ stdin . write ( "g" ) ;
5439+ expect ( lastFrame ( ) ) . toBe ( before ) ;
5440+ expect ( lastFrame ( ) ) . not . toContain ( "Files" ) ;
5441+ expect ( lastFrame ( ) ) . not . toContain ( "React to comment:" ) ;
5442+ } ) ;
53805443 } ) ;
53815444
53825445 describe ( "commit view - loading indicator" , ( ) => {
@@ -7542,6 +7605,50 @@ describe("PullRequestDetail", () => {
75427605 } ) ;
75437606 } ) ;
75447607
7608+ it ( "moves file list selection back up with k and closes with q" , async ( ) => {
7609+ const { stdin, lastFrame } = render (
7610+ < PullRequestDetail
7611+ pullRequest = { pullRequest as any }
7612+ differences = { twoFileDifferences as any }
7613+ commentThreads = { [ ] }
7614+ diffTexts = { twoFileDiffTexts }
7615+ onBack = { vi . fn ( ) }
7616+ onHelp = { vi . fn ( ) }
7617+ onShowActivity = { vi . fn ( ) }
7618+ comment = { { onPost : vi . fn ( ) , isProcessing : false , error : null , onClearError : vi . fn ( ) } }
7619+ inlineComment = { defaultInlineCommentProps }
7620+ reply = { defaultReplyProps }
7621+ approval = { defaultApprovalProps }
7622+ merge = { defaultMergeProps }
7623+ close = { defaultCloseProps }
7624+ commitView = { defaultCommitProps }
7625+ editComment = { defaultEditCommentProps }
7626+ deleteComment = { defaultDeleteCommentProps }
7627+ reaction = { defaultReactionProps }
7628+ /> ,
7629+ ) ;
7630+
7631+ stdin . write ( "f" ) ;
7632+ await vi . waitFor ( ( ) => {
7633+ expect ( lastFrame ( ) ) . toContain ( "Files" ) ;
7634+ } ) ;
7635+
7636+ stdin . write ( "j" ) ;
7637+ await vi . waitFor ( ( ) => {
7638+ expect ( lastFrame ( ) ) . toMatch ( / > .* s r c \/ b e t a \. t s / ) ;
7639+ } ) ;
7640+
7641+ stdin . write ( "k" ) ;
7642+ await vi . waitFor ( ( ) => {
7643+ expect ( lastFrame ( ) ) . toMatch ( / > .* s r c \/ a l p h a \. t s / ) ;
7644+ } ) ;
7645+
7646+ stdin . write ( "q" ) ;
7647+ await vi . waitFor ( ( ) => {
7648+ expect ( lastFrame ( ) ) . not . toContain ( "Files (2)" ) ;
7649+ } ) ;
7650+ } ) ;
7651+
75457652 it ( "closes file list with Esc" , async ( ) => {
75467653 const { stdin, lastFrame } = render (
75477654 < PullRequestDetail
@@ -7753,4 +7860,98 @@ describe("PullRequestDetail", () => {
77537860 expect ( output ) . toContain ( "baz" ) ;
77547861 } ) ;
77557862 } ) ;
7863+
7864+ it ( "ignores navigation keys when there are no display lines" , ( ) => {
7865+ const { stdin, lastFrame } = render (
7866+ < PullRequestDetail
7867+ pullRequest = { pullRequest as any }
7868+ differences = { [ ] }
7869+ commentThreads = { [ ] }
7870+ diffTexts = { new Map ( ) }
7871+ onBack = { vi . fn ( ) }
7872+ onHelp = { vi . fn ( ) }
7873+ onShowActivity = { vi . fn ( ) }
7874+ comment = { { onPost : vi . fn ( ) , isProcessing : false , error : null , onClearError : vi . fn ( ) } }
7875+ inlineComment = { defaultInlineCommentProps }
7876+ reply = { defaultReplyProps }
7877+ approval = { defaultApprovalProps }
7878+ merge = { defaultMergeProps }
7879+ close = { defaultCloseProps }
7880+ commitView = { defaultCommitProps }
7881+ editComment = { defaultEditCommentProps }
7882+ deleteComment = { defaultDeleteCommentProps }
7883+ reaction = { defaultReactionProps }
7884+ /> ,
7885+ ) ;
7886+
7887+ const before = lastFrame ( ) ;
7888+ stdin . write ( "G" ) ;
7889+ stdin . write ( "n" ) ;
7890+ stdin . write ( "N" ) ;
7891+ stdin . write ( "g" ) ;
7892+ expect ( lastFrame ( ) ) . toBe ( before ) ;
7893+ } ) ;
7894+
7895+ it ( "does not open ReactionPicker on a folded thread indicator" , async ( ) => {
7896+ const foldedThreads = [
7897+ {
7898+ location : null ,
7899+ comments : [
7900+ {
7901+ commentId : "comment-root" ,
7902+ authorArn : "arn:aws:iam::123456789012:user/taro" ,
7903+ content : "Root comment" ,
7904+ } ,
7905+ {
7906+ commentId : "comment-reply-1" ,
7907+ inReplyTo : "comment-root" ,
7908+ authorArn : "arn:aws:iam::123456789012:user/hanako" ,
7909+ content : "Reply 1" ,
7910+ } ,
7911+ {
7912+ commentId : "comment-reply-2" ,
7913+ inReplyTo : "comment-root" ,
7914+ authorArn : "arn:aws:iam::123456789012:user/jiro" ,
7915+ content : "Reply 2" ,
7916+ } ,
7917+ {
7918+ commentId : "comment-reply-3" ,
7919+ inReplyTo : "comment-root" ,
7920+ authorArn : "arn:aws:iam::123456789012:user/saburo" ,
7921+ content : "Reply 3" ,
7922+ } ,
7923+ ] ,
7924+ } ,
7925+ ] ;
7926+
7927+ const { stdin, lastFrame } = render (
7928+ < PullRequestDetail
7929+ pullRequest = { pullRequest as any }
7930+ differences = { [ ] }
7931+ commentThreads = { foldedThreads as any }
7932+ diffTexts = { new Map ( ) }
7933+ onBack = { vi . fn ( ) }
7934+ onHelp = { vi . fn ( ) }
7935+ onShowActivity = { vi . fn ( ) }
7936+ comment = { { onPost : vi . fn ( ) , isProcessing : false , error : null , onClearError : vi . fn ( ) } }
7937+ inlineComment = { defaultInlineCommentProps }
7938+ reply = { defaultReplyProps }
7939+ approval = { defaultApprovalProps }
7940+ merge = { defaultMergeProps }
7941+ close = { defaultCloseProps }
7942+ commitView = { defaultCommitProps }
7943+ editComment = { defaultEditCommentProps }
7944+ deleteComment = { defaultDeleteCommentProps }
7945+ reaction = { defaultReactionProps }
7946+ /> ,
7947+ ) ;
7948+
7949+ stdin . write ( "G" ) ;
7950+ await vi . waitFor ( ( ) => {
7951+ expect ( lastFrame ( ) ) . toMatch ( / > .* \[ \+ 3 r e p l i e s \] / ) ;
7952+ } ) ;
7953+
7954+ stdin . write ( "g" ) ;
7955+ expect ( lastFrame ( ) ) . not . toContain ( "React to comment:" ) ;
7956+ } ) ;
77567957} ) ;
0 commit comments