@@ -27,11 +27,13 @@ import {
2727 switchToEditor ,
2828 waitAndClick ,
2929 waitForSerialized ,
30+ waitForTimeout ,
3031} from "./test_utils.mjs" ;
3132
3233const switchToHighlight = switchToEditor . bind ( null , "Highlight" ) ;
3334const switchToStamp = switchToEditor . bind ( null , "Stamp" ) ;
3435const switchToComment = switchToEditor . bind ( null , "Comment" ) ;
36+ const switchToFreeText = switchToEditor . bind ( null , "FreeText" ) ;
3537
3638const highlightSpan = async ( page , pageIndex , text ) => {
3739 const rect = await getSpanRectFromText ( page , pageIndex , text ) ;
@@ -838,4 +840,55 @@ describe("Comment", () => {
838840 ) ;
839841 } ) ;
840842 } ) ;
843+
844+ describe ( "FreeText annotation doesn't have a popup (bug 1995028)" , ( ) => {
845+ let pages ;
846+
847+ beforeEach ( async ( ) => {
848+ pages = await loadAndWait (
849+ "empty.pdf" ,
850+ ".annotationEditorLayer" ,
851+ "page-fit" ,
852+ null ,
853+ { enableComment : true }
854+ ) ;
855+ } ) ;
856+
857+ afterEach ( async ( ) => {
858+ await closePages ( pages ) ;
859+ } ) ;
860+
861+ it ( "must check that comment button isn't in the annotation toolbar" , async ( ) => {
862+ await Promise . all (
863+ pages . map ( async ( [ browserName , page ] ) => {
864+ await switchToFreeText ( page ) ;
865+
866+ const rect = await getRect ( page , ".annotationEditorLayer" ) ;
867+ const editorSelector = getEditorSelector ( 0 ) ;
868+ const data = "Hello PDF.js World !!" ;
869+ await page . mouse . click ( rect . x + 100 , rect . y + 100 ) ;
870+ await page . waitForSelector ( editorSelector , { visible : true } ) ;
871+ await page . type ( `${ editorSelector } .internal` , data ) ;
872+ await page . keyboard . press ( "Escape" ) ;
873+
874+ await page . waitForSelector ( `${ editorSelector } .editToolbar` , {
875+ visible : true ,
876+ } ) ;
877+
878+ // We want to be sure that the comment button isn't rendered.
879+ // eslint-disable-next-line no-restricted-syntax
880+ await waitForTimeout ( 100 ) ;
881+
882+ const hasCommentButton = await page . evaluate (
883+ selector =>
884+ ! ! document . querySelector (
885+ `${ selector } .editToolbar button.comment`
886+ ) ,
887+ editorSelector
888+ ) ;
889+ expect ( hasCommentButton ) . withContext ( `In ${ browserName } ` ) . toBe ( false ) ;
890+ } )
891+ ) ;
892+ } ) ;
893+ } ) ;
841894} ) ;
0 commit comments