@@ -2861,4 +2861,96 @@ describe("Highlight Editor", () => {
28612861 ) ;
28622862 } ) ;
28632863 } ) ;
2864+
2865+ describe ( "Highlight (edit existing and scroll)" , ( ) => {
2866+ let pages ;
2867+
2868+ beforeEach ( async ( ) => {
2869+ pages = await loadAndWait (
2870+ "highlights.pdf" ,
2871+ ".annotationEditorLayer" ,
2872+ null ,
2873+ null ,
2874+ {
2875+ highlightEditorColors :
2876+ "yellow=#FFFF00,green=#00FF00,blue=#0000FF,pink=#FF00FF,red=#FF0102" ,
2877+ }
2878+ ) ;
2879+ } ) ;
2880+
2881+ afterEach ( async ( ) => {
2882+ await closePages ( pages ) ;
2883+ } ) ;
2884+
2885+ it ( "must check that no extra annotations are added while in editing mode" , async ( ) => {
2886+ await Promise . all (
2887+ pages . map ( async ( [ browserName , page ] ) => {
2888+ await switchToHighlight ( page ) ;
2889+
2890+ const editorSelector = getEditorSelector ( 7 ) ;
2891+ await page . waitForSelector ( editorSelector ) ;
2892+
2893+ const oneToOne = Array . from ( new Array ( 13 ) . keys ( ) , n => n + 2 ) . concat (
2894+ Array . from ( new Array ( 13 ) . keys ( ) , n => 13 - n )
2895+ ) ;
2896+ for ( const pageNumber of oneToOne ) {
2897+ await scrollIntoView (
2898+ page ,
2899+ `.page[data-page-number = "${ pageNumber } "]`
2900+ ) ;
2901+ }
2902+
2903+ await page . waitForSelector ( editorSelector ) ;
2904+
2905+ const count = await page . evaluate (
2906+ ( ) =>
2907+ document . querySelectorAll (
2908+ `.page[data-page-number = "1"] .annotationEditorLayer .highlightEditor`
2909+ ) . length
2910+ ) ;
2911+ expect ( count ) . withContext ( `In ${ browserName } ` ) . toEqual ( 8 ) ;
2912+ } )
2913+ ) ;
2914+ } ) ;
2915+
2916+ it ( "must check that no extra annotations are added while in reading mode" , async ( ) => {
2917+ await Promise . all (
2918+ pages . map ( async ( [ browserName , page ] ) => {
2919+ await switchToHighlight ( page ) ;
2920+
2921+ const editorSelector = getEditorSelector ( 7 ) ;
2922+ await page . waitForSelector ( editorSelector ) ;
2923+
2924+ const oneToThirteen = Array . from ( new Array ( 13 ) . keys ( ) , n => n + 2 ) ;
2925+ const thirteenToOne = Array . from ( new Array ( 13 ) . keys ( ) , n => 13 - n ) ;
2926+ for ( const pageNumber of oneToThirteen ) {
2927+ await scrollIntoView (
2928+ page ,
2929+ `.page[data-page-number = "${ pageNumber } "]`
2930+ ) ;
2931+ }
2932+
2933+ await switchToHighlight ( page , /* disable */ true ) ;
2934+
2935+ for ( const pageNumber of thirteenToOne ) {
2936+ await scrollIntoView (
2937+ page ,
2938+ `.page[data-page-number = "${ pageNumber } "]`
2939+ ) ;
2940+ }
2941+
2942+ await page . waitForSelector (
2943+ `.page[data-page-number = "1"] .annotationEditorLayer.disabled`
2944+ ) ;
2945+
2946+ await page . waitForFunction (
2947+ ( ) =>
2948+ document . querySelectorAll (
2949+ `.page[data-page-number = "1"] .annotationEditorLayer .highlightEditor`
2950+ ) . length === 0
2951+ ) ;
2952+ } )
2953+ ) ;
2954+ } ) ;
2955+ } ) ;
28642956} ) ;
0 commit comments