@@ -169,6 +169,14 @@ describe("TaurusViewer E2E Test Suite", () => {
169169 } ) ;
170170 }
171171
172+ async function pdfScrollTop ( ) : Promise < number > {
173+ return browser . execute ( ( ) => {
174+ const first = document . querySelector ( '[data-page-index="0"]' ) ;
175+ const container = first ?. closest ( ".overflow-auto" ) as HTMLElement | null ;
176+ return container ?. scrollTop ?? - 1 ;
177+ } ) ;
178+ }
179+
172180 async function getContainerPosition ( ) : Promise < number > {
173181 return browser . execute ( ( ) => {
174182 const v = document . querySelector ( "foliate-view" ) as any ;
@@ -652,4 +660,85 @@ describe("TaurusViewer E2E Test Suite", () => {
652660 } ,
653661 ) ;
654662 } ) ;
663+
664+ it ( "should open the command palette via the palette button" , async ( ) => {
665+ const paletteBtn = await $ ( 'button[aria-label="Open command palette"]' ) ;
666+ await paletteBtn . click ( ) ;
667+ const paletteInput = await $ ( 'input[placeholder="Search open tabs or library documents..."]' ) ;
668+ await expect ( paletteInput ) . toBeDisplayed ( ) ;
669+ } ) ;
670+
671+ it ( "should open help via the help button and scroll it instead of the document" , async ( ) => {
672+ await openPdf ( ) ;
673+ // Scroll the document a little so its position can be compared later.
674+ await browser . keys ( [ "j" ] ) ;
675+ await browser . waitUntil (
676+ async ( ) => ( await pdfScrollTop ( ) ) > 0 ,
677+ { timeout : 5000 , timeoutMsg : "j did not scroll the PDF document" } ,
678+ ) ;
679+ const documentScrollBefore = await pdfScrollTop ( ) ;
680+
681+ const helpBtn = await $ ( 'button[aria-label="Help"]' ) ;
682+ await helpBtn . click ( ) ;
683+ await $ ( "*=Keyboard shortcuts" ) . waitForDisplayed ( { timeout : 5000 } ) ;
684+
685+ // G scrolls the help content to its bottom.
686+ await browser . keys ( [ "G" ] ) ;
687+ await browser . waitUntil (
688+ async ( ) =>
689+ ( await browser . execute ( ( ) => {
690+ const el = document . querySelector ( "[data-help-scroll]" ) ;
691+ return el ? ( el as HTMLElement ) . scrollTop : - 1 ;
692+ } ) ) > 0 ,
693+ { timeout : 5000 , timeoutMsg : "G did not scroll the help content" } ,
694+ ) ;
695+
696+ // The document must not have moved while the help modal was open.
697+ expect ( await pdfScrollTop ( ) ) . toBe ( documentScrollBefore ) ;
698+
699+ // Close help and confirm the document scrolls again.
700+ await browser . keys ( [ "Escape" ] ) ;
701+ await browser . waitUntil (
702+ async ( ) => ! ( await $ ( "*=Keyboard shortcuts" ) . isExisting ( ) ) ,
703+ { timeout : 5000 , timeoutMsg : "help modal did not close on Escape" } ,
704+ ) ;
705+ await browser . keys ( [ "j" ] ) ;
706+ await browser . waitUntil (
707+ async ( ) => ( await pdfScrollTop ( ) ) > documentScrollBefore ,
708+ { timeout : 5000 , timeoutMsg : "document did not resume scrolling after help closed" } ,
709+ ) ;
710+ } ) ;
711+
712+ it ( "should jump to the first/last page with g/G in PDF PAGES mode" , async ( ) => {
713+ await openPdf ( ) ;
714+ await browser . keys ( [ "s" ] ) ;
715+ await browser . waitUntil (
716+ async ( ) => ( await statusBarText ( ) ) . includes ( "pages" ) ,
717+ { timeout : 5000 , timeoutMsg : "s did not switch to PAGES mode" } ,
718+ ) ;
719+ await browser . keys ( [ "G" ] ) ;
720+ await browser . waitUntil (
721+ async ( ) => ( await statusBarText ( ) ) . includes ( "Page 12 / 12" ) ,
722+ { timeout : 10000 , timeoutMsg : "G did not jump to the last page in PAGES mode" } ,
723+ ) ;
724+ await browser . keys ( [ "g" ] ) ;
725+ await browser . waitUntil (
726+ async ( ) => ( await statusBarText ( ) ) . includes ( "Page 1 / 12" ) ,
727+ { timeout : 10000 , timeoutMsg : "g did not jump to the first page in PAGES mode" } ,
728+ ) ;
729+ } ) ;
730+
731+ it ( "should go to the top/bottom of a PDF with g/G in SCROLL mode" , async ( ) => {
732+ await openPdf ( ) ;
733+ await browser . keys ( [ "G" ] ) ;
734+ await browser . waitUntil (
735+ async ( ) => ( await statusBarText ( ) ) . includes ( "Page 12 / 12" ) ,
736+ { timeout : 10000 , timeoutMsg : "G did not scroll to the document bottom" } ,
737+ ) ;
738+ await browser . keys ( [ "g" ] ) ;
739+ await browser . waitUntil (
740+ async ( ) => ( await statusBarText ( ) ) . includes ( "Page 1 / 12" ) ,
741+ { timeout : 10000 , timeoutMsg : "g did not scroll to the document top" } ,
742+ ) ;
743+ } ) ;
655744} ) ;
0 commit comments