1616import {
1717 applyFunctionToEditor ,
1818 awaitPromise ,
19- cleanupEditing ,
2019 clearEditors ,
2120 clearInput ,
2221 closePages ,
@@ -31,7 +30,6 @@ import {
3130 getRect ,
3231 getSerialized ,
3332 isCanvasMonochrome ,
34- isVisible ,
3533 kbBigMoveDown ,
3634 kbBigMoveRight ,
3735 kbUndo ,
@@ -101,7 +99,7 @@ describe("Stamp Editor", () => {
10199 describe ( "Basic operations" , ( ) => {
102100 let pages ;
103101
104- beforeAll ( async ( ) => {
102+ beforeEach ( async ( ) => {
105103 pages = await loadAndWait ( "empty.pdf" , ".annotationEditorLayer" , null , {
106104 eventBusSetup : eventBus => {
107105 eventBus . on ( "annotationeditoruimanager" , ( { uiManager } ) => {
@@ -112,10 +110,6 @@ describe("Stamp Editor", () => {
112110 } ) ;
113111
114112 afterEach ( async ( ) => {
115- await cleanupEditing ( pages , switchToStamp ) ;
116- } ) ;
117-
118- afterAll ( async ( ) => {
119113 await closePages ( pages ) ;
120114 } ) ;
121115
@@ -203,7 +197,7 @@ describe("Stamp Editor", () => {
203197 describe ( "Resize" , ( ) => {
204198 let pages ;
205199
206- beforeAll ( async ( ) => {
200+ beforeEach ( async ( ) => {
207201 pages = await loadAndWait ( "empty.pdf" , ".annotationEditorLayer" , 50 , {
208202 eventBusSetup : eventBus => {
209203 eventBus . on ( "annotationeditoruimanager" , ( { uiManager } ) => {
@@ -213,12 +207,8 @@ describe("Stamp Editor", () => {
213207 } ) ;
214208 } ) ;
215209
216- afterAll ( async ( ) => {
217- await closePages ( pages ) ;
218- } ) ;
219-
220210 afterEach ( async ( ) => {
221- await cleanupEditing ( pages , switchToStamp ) ;
211+ await closePages ( pages ) ;
222212 } ) ;
223213
224214 it ( "must check that an added image stay within the page" , async ( ) => {
@@ -325,11 +315,11 @@ describe("Stamp Editor", () => {
325315 describe ( "Alt text dialog" , ( ) => {
326316 let pages ;
327317
328- beforeAll ( async ( ) => {
318+ beforeEach ( async ( ) => {
329319 pages = await loadAndWait ( "empty.pdf" , ".annotationEditorLayer" , 50 ) ;
330320 } ) ;
331321
332- afterAll ( async ( ) => {
322+ afterEach ( async ( ) => {
333323 await closePages ( pages ) ;
334324 } ) ;
335325
@@ -500,11 +490,11 @@ describe("Stamp Editor", () => {
500490 describe ( "Resize an image with the keyboard" , ( ) => {
501491 let pages ;
502492
503- beforeAll ( async ( ) => {
493+ beforeEach ( async ( ) => {
504494 pages = await loadAndWait ( "empty.pdf" , ".annotationEditorLayer" , 50 ) ;
505495 } ) ;
506496
507- afterAll ( async ( ) => {
497+ afterEach ( async ( ) => {
508498 await closePages ( pages ) ;
509499 } ) ;
510500
@@ -631,12 +621,12 @@ describe("Stamp Editor", () => {
631621 describe ( "Copy/paste from a tab to an other" , ( ) => {
632622 let pages1 , pages2 ;
633623
634- beforeAll ( async ( ) => {
624+ beforeEach ( async ( ) => {
635625 pages1 = await loadAndWait ( "empty.pdf" , ".annotationEditorLayer" ) ;
636626 pages2 = await loadAndWait ( "empty.pdf" , ".annotationEditorLayer" ) ;
637627 } ) ;
638628
639- afterAll ( async ( ) => {
629+ afterEach ( async ( ) => {
640630 await closePages ( pages1 ) ;
641631 await closePages ( pages2 ) ;
642632 } ) ;
@@ -665,11 +655,11 @@ describe("Stamp Editor", () => {
665655 describe ( "Undo a stamp" , ( ) => {
666656 let pages ;
667657
668- beforeAll ( async ( ) => {
658+ beforeEach ( async ( ) => {
669659 pages = await loadAndWait ( "tracemonkey.pdf" , ".annotationEditorLayer" ) ;
670660 } ) ;
671661
672- afterAll ( async ( ) => {
662+ afterEach ( async ( ) => {
673663 await closePages ( pages ) ;
674664 } ) ;
675665
@@ -697,11 +687,11 @@ describe("Stamp Editor", () => {
697687 describe ( "Delete a stamp and undo it on another page" , ( ) => {
698688 let pages ;
699689
700- beforeAll ( async ( ) => {
690+ beforeEach ( async ( ) => {
701691 pages = await loadAndWait ( "tracemonkey.pdf" , ".annotationEditorLayer" ) ;
702692 } ) ;
703693
704- afterAll ( async ( ) => {
694+ afterEach ( async ( ) => {
705695 await closePages ( pages ) ;
706696 } ) ;
707697
@@ -742,11 +732,11 @@ describe("Stamp Editor", () => {
742732 describe ( "Delete a stamp, scroll and undo it" , ( ) => {
743733 let pages ;
744734
745- beforeAll ( async ( ) => {
735+ beforeEach ( async ( ) => {
746736 pages = await loadAndWait ( "tracemonkey.pdf" , ".annotationEditorLayer" ) ;
747737 } ) ;
748738
749- afterAll ( async ( ) => {
739+ afterEach ( async ( ) => {
750740 await closePages ( pages ) ;
751741 } ) ;
752742
@@ -782,11 +772,11 @@ describe("Stamp Editor", () => {
782772 describe ( "Resize a stamp" , ( ) => {
783773 let pages ;
784774
785- beforeAll ( async ( ) => {
775+ beforeEach ( async ( ) => {
786776 pages = await loadAndWait ( "empty.pdf" , ".annotationEditorLayer" ) ;
787777 } ) ;
788778
789- afterAll ( async ( ) => {
779+ afterEach ( async ( ) => {
790780 await closePages ( pages ) ;
791781 } ) ;
792782
@@ -832,7 +822,7 @@ describe("Stamp Editor", () => {
832822 describe ( "Add a stamp in odd spread mode" , ( ) => {
833823 let pages ;
834824
835- beforeAll ( async ( ) => {
825+ beforeEach ( async ( ) => {
836826 pages = await loadAndWait (
837827 "empty.pdf" ,
838828 ".annotationEditorLayer" ,
@@ -844,7 +834,7 @@ describe("Stamp Editor", () => {
844834 ) ;
845835 } ) ;
846836
847- afterAll ( async ( ) => {
837+ afterEach ( async ( ) => {
848838 await closePages ( pages ) ;
849839 } ) ;
850840
@@ -873,11 +863,11 @@ describe("Stamp Editor", () => {
873863 describe ( "Copy and paste a stamp with an alt text" , ( ) => {
874864 let pages ;
875865
876- beforeAll ( async ( ) => {
866+ beforeEach ( async ( ) => {
877867 pages = await loadAndWait ( "empty.pdf" , ".annotationEditorLayer" ) ;
878868 } ) ;
879869
880- afterAll ( async ( ) => {
870+ afterEach ( async ( ) => {
881871 await closePages ( pages ) ;
882872 } ) ;
883873
@@ -918,7 +908,7 @@ describe("Stamp Editor", () => {
918908 describe ( "New alt-text flow" , ( ) => {
919909 let pages ;
920910
921- beforeAll ( async ( ) => {
911+ beforeEach ( async ( ) => {
922912 pages = await loadAndWait (
923913 "empty.pdf" ,
924914 ".annotationEditorLayer" ,
@@ -942,23 +932,6 @@ describe("Stamp Editor", () => {
942932 } ) ;
943933
944934 afterEach ( async ( ) => {
945- for ( const [ , page ] of pages ) {
946- if ( await isVisible ( page , "#newAltTextDialog" ) ) {
947- await page . keyboard . press ( "Escape" ) ;
948- await page . waitForSelector ( "#newAltTextDisclaimer" , {
949- visible : false ,
950- } ) ;
951- }
952- await page . evaluate ( ( ) => {
953- window . uiManager . reset ( ) ;
954- window . telemetry = [ ] ;
955- } ) ;
956- // Disable editing mode.
957- await switchToStamp ( page , /* disable */ true ) ;
958- }
959- } ) ;
960-
961- afterAll ( async ( ) => {
962935 await closePages ( pages ) ;
963936 } ) ;
964937
@@ -1296,7 +1269,7 @@ describe("Stamp Editor", () => {
12961269 describe ( "New alt-text flow (bug 1920515)" , ( ) => {
12971270 let pages ;
12981271
1299- beforeAll ( async ( ) => {
1272+ beforeEach ( async ( ) => {
13001273 pages = await loadAndWait (
13011274 "empty.pdf" ,
13021275 ".annotationEditorLayer" ,
@@ -1318,22 +1291,6 @@ describe("Stamp Editor", () => {
13181291 } ) ;
13191292
13201293 afterEach ( async ( ) => {
1321- for ( const [ , page ] of pages ) {
1322- if ( await isVisible ( page , "#newAltTextDialog" ) ) {
1323- await page . keyboard . press ( "Escape" ) ;
1324- await page . waitForSelector ( "#newAltTextDisclaimer" , {
1325- visible : false ,
1326- } ) ;
1327- }
1328- await page . evaluate ( ( ) => {
1329- window . uiManager . reset ( ) ;
1330- } ) ;
1331- // Disable editing mode.
1332- await switchToStamp ( page , /* disable */ true ) ;
1333- }
1334- } ) ;
1335-
1336- afterAll ( async ( ) => {
13371294 await closePages ( pages ) ;
13381295 } ) ;
13391296
@@ -1364,11 +1321,11 @@ describe("Stamp Editor", () => {
13641321 describe ( "No auto-resize" , ( ) => {
13651322 let pages ;
13661323
1367- beforeAll ( async ( ) => {
1324+ beforeEach ( async ( ) => {
13681325 pages = await loadAndWait ( "empty.pdf" , ".annotationEditorLayer" , 67 ) ;
13691326 } ) ;
13701327
1371- afterAll ( async ( ) => {
1328+ afterEach ( async ( ) => {
13721329 await closePages ( pages ) ;
13731330 } ) ;
13741331
@@ -1410,11 +1367,11 @@ describe("Stamp Editor", () => {
14101367 describe ( "A stamp musn't be on top of the secondary toolbar" , ( ) => {
14111368 let pages ;
14121369
1413- beforeAll ( async ( ) => {
1370+ beforeEach ( async ( ) => {
14141371 pages = await loadAndWait ( "empty.pdf" , ".annotationEditorLayer" , 600 ) ;
14151372 } ) ;
14161373
1417- afterAll ( async ( ) => {
1374+ afterEach ( async ( ) => {
14181375 await closePages ( pages ) ;
14191376 } ) ;
14201377
@@ -1453,11 +1410,11 @@ describe("Stamp Editor", () => {
14531410 describe ( "Stamp (move existing)" , ( ) => {
14541411 let pages ;
14551412
1456- beforeAll ( async ( ) => {
1413+ beforeEach ( async ( ) => {
14571414 pages = await loadAndWait ( "stamps.pdf" , getAnnotationSelector ( "25R" ) ) ;
14581415 } ) ;
14591416
1460- afterAll ( async ( ) => {
1417+ afterEach ( async ( ) => {
14611418 await closePages ( pages ) ;
14621419 } ) ;
14631420
@@ -1491,11 +1448,11 @@ describe("Stamp Editor", () => {
14911448 describe ( "Stamp (change alt-text)" , ( ) => {
14921449 let pages ;
14931450
1494- beforeAll ( async ( ) => {
1451+ beforeEach ( async ( ) => {
14951452 pages = await loadAndWait ( "stamps.pdf" , getAnnotationSelector ( "58R" ) ) ;
14961453 } ) ;
14971454
1498- afterAll ( async ( ) => {
1455+ afterEach ( async ( ) => {
14991456 await closePages ( pages ) ;
15001457 } ) ;
15011458
@@ -1551,11 +1508,11 @@ describe("Stamp Editor", () => {
15511508 describe ( "Stamp (delete existing and undo)" , ( ) => {
15521509 let pages ;
15531510
1554- beforeAll ( async ( ) => {
1511+ beforeEach ( async ( ) => {
15551512 pages = await loadAndWait ( "stamps.pdf" , getAnnotationSelector ( "37R" ) ) ;
15561513 } ) ;
15571514
1558- afterAll ( async ( ) => {
1515+ afterEach ( async ( ) => {
15591516 await closePages ( pages ) ;
15601517 } ) ;
15611518
@@ -1599,11 +1556,11 @@ describe("Stamp Editor", () => {
15991556 describe ( "Drag a stamp annotation and click on a touchscreen" , ( ) => {
16001557 let pages ;
16011558
1602- beforeAll ( async ( ) => {
1559+ beforeEach ( async ( ) => {
16031560 pages = await loadAndWait ( "empty.pdf" , ".annotationEditorLayer" ) ;
16041561 } ) ;
16051562
1606- afterAll ( async ( ) => {
1563+ afterEach ( async ( ) => {
16071564 await closePages ( pages ) ;
16081565 } ) ;
16091566
@@ -1725,11 +1682,11 @@ describe("Stamp Editor", () => {
17251682 describe ( "Switch to edit mode a pdf with an existing stamp annotation on an invisible and rendered page" , ( ) => {
17261683 let pages ;
17271684
1728- beforeAll ( async ( ) => {
1685+ beforeEach ( async ( ) => {
17291686 pages = await loadAndWait ( "issue19239.pdf" , ".annotationEditorLayer" ) ;
17301687 } ) ;
17311688
1732- afterAll ( async ( ) => {
1689+ afterEach ( async ( ) => {
17331690 await closePages ( pages ) ;
17341691 } ) ;
17351692
@@ -1755,11 +1712,11 @@ describe("Stamp Editor", () => {
17551712 describe ( "Switch to edit mode a pdf with an existing stamp annotation on an invisible and unrendered page" , ( ) => {
17561713 let pages ;
17571714
1758- beforeAll ( async ( ) => {
1715+ beforeEach ( async ( ) => {
17591716 pages = await loadAndWait ( "issue19239.pdf" , ".annotationEditorLayer" ) ;
17601717 } ) ;
17611718
1762- afterAll ( async ( ) => {
1719+ afterEach ( async ( ) => {
17631720 await closePages ( pages ) ;
17641721 } ) ;
17651722
@@ -1794,11 +1751,11 @@ describe("Stamp Editor", () => {
17941751
17951752 let pages ;
17961753
1797- beforeAll ( async ( ) => {
1754+ beforeEach ( async ( ) => {
17981755 pages = await loadAndWait ( "issue19239.pdf" , annotationSelector ) ;
17991756 } ) ;
18001757
1801- afterAll ( async ( ) => {
1758+ afterEach ( async ( ) => {
18021759 await closePages ( pages ) ;
18031760 } ) ;
18041761
@@ -1825,11 +1782,11 @@ describe("Stamp Editor", () => {
18251782
18261783 let pages ;
18271784
1828- beforeAll ( async ( ) => {
1785+ beforeEach ( async ( ) => {
18291786 pages = await loadAndWait ( "red_stamp.pdf" , annotationSelector , 20 ) ;
18301787 } ) ;
18311788
1832- afterAll ( async ( ) => {
1789+ afterEach ( async ( ) => {
18331790 await closePages ( pages ) ;
18341791 } ) ;
18351792
0 commit comments