@@ -2848,4 +2848,146 @@ describe("Highlight Editor", () => {
28482848 } ) ;
28492849 } ) ;
28502850 } ) ;
2851+
2852+ describe ( "Show all disabled status must be persistent" , ( ) => {
2853+ let pages ;
2854+
2855+ beforeEach ( async ( ) => {
2856+ pages = await loadAndWait ( "tracemonkey.pdf" , ".annotationEditorLayer" ) ;
2857+ } ) ;
2858+
2859+ afterEach ( async ( ) => {
2860+ await closePages ( pages ) ;
2861+ } ) ;
2862+
2863+ it ( "must preserve the status when closing and opening any editor" , async ( ) => {
2864+ await Promise . all (
2865+ pages . map ( async ( [ browserName , page ] ) => {
2866+ await switchToHighlight ( page ) ;
2867+ await page . waitForSelector ( ".annotationEditorLayer.highlightEditing" ) ;
2868+
2869+ await highlightSpan ( page , 1 , "Abstract" ) ;
2870+ const firstEditorSelector = getEditorSelector ( 0 ) ;
2871+ await page . waitForSelector ( firstEditorSelector ) ;
2872+
2873+ const showAllButton = "#editorHighlightShowAll" ;
2874+ await page . click ( showAllButton ) ;
2875+ await page . waitForSelector ( `${ firstEditorSelector } .hidden` ) ;
2876+
2877+ const modeChangedHandle1 = await waitForAnnotationModeChanged ( page ) ;
2878+ await page . click ( "#editorHighlightButton" ) ;
2879+ await awaitPromise ( modeChangedHandle1 ) ;
2880+
2881+ const modeChangedHandle2 = await waitForAnnotationModeChanged ( page ) ;
2882+ await page . click ( "#editorInkButton" ) ;
2883+ await awaitPromise ( modeChangedHandle2 ) ;
2884+ await page . waitForSelector ( ".annotationEditorLayer.inkEditing" ) ;
2885+
2886+ const modeChangedHandle3 = await waitForAnnotationModeChanged ( page ) ;
2887+ await page . click ( "#editorHighlightButton" ) ;
2888+ await awaitPromise ( modeChangedHandle3 ) ;
2889+ await page . waitForSelector ( ".annotationEditorLayer.highlightEditing" ) ;
2890+
2891+ const isShowAllDisabled = await page . evaluate ( ( ) => {
2892+ const btn = document . querySelector ( "#editorHighlightShowAll" ) ;
2893+ return btn . getAttribute ( "aria-pressed" ) === "false" ;
2894+ } ) ;
2895+
2896+ expect ( isShowAllDisabled )
2897+ . withContext (
2898+ `In ${ browserName } : Show all button should still be disabled`
2899+ )
2900+ . toBe ( true ) ;
2901+
2902+ const hasHiddenClass = await page . evaluate ( selector => {
2903+ const highlight = document . querySelector ( selector ) ;
2904+ return highlight ? highlight . classList . contains ( "hidden" ) : false ;
2905+ } , firstEditorSelector ) ;
2906+
2907+ expect ( hasHiddenClass )
2908+ . withContext (
2909+ `In ${ browserName } : Highlight should have hidden CSS class`
2910+ )
2911+ . toBe ( true ) ;
2912+ } )
2913+ ) ;
2914+ } ) ;
2915+
2916+ it ( "must preserve the status when highlighting from edit toolbar and re-opening the editor" , async ( ) => {
2917+ await Promise . all (
2918+ pages . map ( async ( [ browserName , page ] ) => {
2919+ await switchToHighlight ( page ) ;
2920+ await page . waitForSelector ( ".annotationEditorLayer.highlightEditing" ) ;
2921+
2922+ await highlightSpan ( page , 1 , "Abstract" ) ;
2923+ const firstEditorSelector = getEditorSelector ( 0 ) ;
2924+ await page . waitForSelector ( firstEditorSelector ) ;
2925+
2926+ const showAllButton = "#editorHighlightShowAll" ;
2927+ await page . click ( showAllButton ) ;
2928+ await page . waitForSelector ( `${ firstEditorSelector } .hidden` ) ;
2929+
2930+ const modeChangedHandle = await waitForAnnotationModeChanged ( page ) ;
2931+ await page . click ( "#editorHighlightButton" ) ;
2932+ await awaitPromise ( modeChangedHandle ) ;
2933+
2934+ const textSpan = await page . $ (
2935+ `.page[data-page-number = "1"] .textLayer span`
2936+ ) ;
2937+ const spanRect = await page . evaluate ( el => {
2938+ const rect = el . getBoundingClientRect ( ) ;
2939+ return {
2940+ x : rect . x + rect . width / 2 ,
2941+ y : rect . y + rect . height / 2 ,
2942+ } ;
2943+ } , textSpan ) ;
2944+
2945+ await page . mouse . click ( spanRect . x , spanRect . y ) ;
2946+ await page . mouse . click ( spanRect . x , spanRect . y ) ;
2947+
2948+ await page . waitForSelector ( ".editToolbar" ) ;
2949+ const highlightFromToolbar = await page . $ (
2950+ ".editToolbar .highlightButton"
2951+ ) ;
2952+ if ( highlightFromToolbar ) {
2953+ await highlightFromToolbar . click ( ) ;
2954+ const secondEditorSelector = getEditorSelector ( 1 ) ;
2955+ await page . waitForSelector ( secondEditorSelector ) ;
2956+ }
2957+
2958+ const modeChangedHandle2 = await waitForAnnotationModeChanged ( page ) ;
2959+ await page . click ( "#editorHighlightButton" ) ;
2960+ await awaitPromise ( modeChangedHandle2 ) ;
2961+
2962+ const modeChangedHandle3 = await waitForAnnotationModeChanged ( page ) ;
2963+ await page . click ( "#editorHighlightButton" ) ;
2964+ await awaitPromise ( modeChangedHandle3 ) ;
2965+
2966+ const isShowAllDisabled = await page . evaluate ( ( ) => {
2967+ const btn = document . querySelector ( "#editorHighlightShowAll" ) ;
2968+ return btn . getAttribute ( "aria-pressed" ) === "false" ;
2969+ } ) ;
2970+
2971+ expect ( isShowAllDisabled )
2972+ . withContext (
2973+ `In ${ browserName } : Show all button should still be disabled`
2974+ )
2975+ . toBe ( true ) ;
2976+
2977+ await page . waitForSelector ( `${ firstEditorSelector } .hidden` ) ;
2978+
2979+ const hasHiddenClass = await page . evaluate ( selector => {
2980+ const highlight = document . querySelector ( selector ) ;
2981+ return highlight ? highlight . classList . contains ( "hidden" ) : false ;
2982+ } , firstEditorSelector ) ;
2983+
2984+ expect ( hasHiddenClass )
2985+ . withContext (
2986+ `In ${ browserName } : Highlight should have hidden CSS class`
2987+ )
2988+ . toBe ( true ) ;
2989+ } )
2990+ ) ;
2991+ } ) ;
2992+ } ) ;
28512993} ) ;
0 commit comments