@@ -151,7 +151,6 @@ function createFileScrollBootstrap(): AppBootstrap {
151151 } ;
152152}
153153
154-
155154async function flush ( setup : Awaited < ReturnType < typeof testRender > > ) {
156155 await act ( async ( ) => {
157156 await setup . renderOnce ( ) ;
@@ -413,6 +412,117 @@ describe("App interactions", () => {
413412 }
414413 } ) ;
415414
415+ test ( "filtering away the selected file reselects the first visible match" , async ( ) => {
416+ const setup = await testRender ( < App bootstrap = { createBootstrap ( ) } /> , { width : 240 , height : 24 } ) ;
417+
418+ try {
419+ await flush ( setup ) ;
420+
421+ await act ( async ( ) => {
422+ await setup . mockInput . pressTab ( ) ;
423+ } ) ;
424+ await flush ( setup ) ;
425+ await act ( async ( ) => {
426+ await setup . mockInput . typeText ( "beta" ) ;
427+ } ) ;
428+ await flush ( setup ) ;
429+
430+ let frame = setup . captureCharFrame ( ) ;
431+ expect ( frame ) . toContain ( "filter:" ) ;
432+ expect ( frame ) . toContain ( "beta" ) ;
433+ expect ( frame ) . toContain ( "M beta.ts" ) ;
434+ expect ( frame ) . not . toContain ( "M alpha.ts" ) ;
435+ expect ( frame ) . toContain ( "beta.ts" ) ;
436+ expect ( frame ) . not . toContain ( "Annotation for alpha.ts" ) ;
437+
438+ await act ( async ( ) => {
439+ await setup . mockInput . pressTab ( ) ;
440+ } ) ;
441+ await flush ( setup ) ;
442+
443+ frame = setup . captureCharFrame ( ) ;
444+ expect ( frame ) . toContain ( "filter=beta" ) ;
445+ expect ( frame ) . toContain ( "beta.ts" ) ;
446+ } finally {
447+ await act ( async ( ) => {
448+ setup . renderer . destroy ( ) ;
449+ } ) ;
450+ }
451+ } ) ;
452+
453+ test ( "menu navigation wraps across the first and last top-level menus" , async ( ) => {
454+ const setup = await testRender ( < App bootstrap = { createBootstrap ( ) } /> , { width : 220 , height : 24 } ) ;
455+
456+ try {
457+ await flush ( setup ) ;
458+
459+ await act ( async ( ) => {
460+ setup . mockInput . pressKey ( "F10" ) ;
461+ } ) ;
462+ await flush ( setup ) ;
463+
464+ let frame = setup . captureCharFrame ( ) ;
465+ expect ( frame ) . toContain ( "Focus files" ) ;
466+ expect ( frame ) . not . toContain ( "Keyboard help" ) ;
467+
468+ await act ( async ( ) => {
469+ await setup . mockInput . pressArrow ( "left" ) ;
470+ } ) ;
471+ await flush ( setup ) ;
472+
473+ frame = setup . captureCharFrame ( ) ;
474+ expect ( frame ) . toContain ( "Keyboard help" ) ;
475+ expect ( frame ) . not . toContain ( "Focus files" ) ;
476+
477+ await act ( async ( ) => {
478+ await setup . mockInput . pressArrow ( "right" ) ;
479+ } ) ;
480+ await flush ( setup ) ;
481+
482+ frame = setup . captureCharFrame ( ) ;
483+ expect ( frame ) . toContain ( "Focus files" ) ;
484+ expect ( frame ) . not . toContain ( "Keyboard help" ) ;
485+ } finally {
486+ await act ( async ( ) => {
487+ setup . renderer . destroy ( ) ;
488+ } ) ;
489+ }
490+ } ) ;
491+
492+ test ( "sidebar visibility can toggle off and back on" , async ( ) => {
493+ const setup = await testRender ( < App bootstrap = { createBootstrap ( ) } /> , { width : 240 , height : 24 } ) ;
494+
495+ try {
496+ await flush ( setup ) ;
497+
498+ let frame = setup . captureCharFrame ( ) ;
499+ expect ( frame ) . toContain ( "M alpha.ts" ) ;
500+
501+ await act ( async ( ) => {
502+ await setup . mockInput . typeText ( "s" ) ;
503+ } ) ;
504+ await flush ( setup ) ;
505+
506+ frame = setup . captureCharFrame ( ) ;
507+ expect ( frame ) . not . toContain ( "M alpha.ts" ) ;
508+ expect ( frame ) . toContain ( "alpha.ts" ) ;
509+ expect ( frame ) . not . toContain ( "drag divider resize" ) ;
510+
511+ await act ( async ( ) => {
512+ await setup . mockInput . typeText ( "s" ) ;
513+ } ) ;
514+ await flush ( setup ) ;
515+
516+ frame = setup . captureCharFrame ( ) ;
517+ expect ( frame ) . toContain ( "M alpha.ts" ) ;
518+ expect ( frame ) . toContain ( "drag divider resize" ) ;
519+ } finally {
520+ await act ( async ( ) => {
521+ setup . renderer . destroy ( ) ;
522+ } ) ;
523+ }
524+ } ) ;
525+
416526 test ( "quit shortcuts route through the provided onQuit handler in regular and pager modes" , async ( ) => {
417527 const regularQuit = mock ( ( ) => undefined ) ;
418528 const regularSetup = await testRender ( < App bootstrap = { createBootstrap ( ) } onQuit = { regularQuit } /> , { width : 220 , height : 24 } ) ;
0 commit comments