@@ -18,27 +18,24 @@ describe('Regions', () => {
1818 // Enter region creation mode
1919 cy . getByTestId ( 'bp-AnnotationsControls-regionBtn' ) . click ( ) ;
2020
21- // Draw a 50x50 region on the first page starting at x50, y50
22- cy . getByTestId ( 'ba-RegionCreator' )
23- . first ( )
24- . trigger ( 'mousedown' , {
25- buttons : 1 ,
26- clientX : 50 ,
27- clientY : 50 ,
28- } )
29- . trigger ( 'mousemove' , {
30- buttons : 1 ,
31- clientX : 100 ,
32- clientY : 100 ,
33- } )
34- . trigger ( 'mouseup' ) ;
35-
36- // Type a message in the reply form and save the new annotation
37- cy . getByTestId ( 'ba-ReplyField-editor' ) . type ( 'This is an automated test annotation.' ) ;
38- cy . getByTestId ( 'ba-Popup-submit' ) . click ( ) ;
39-
40- // Assert that at least one annotation is present on the image
41- cy . get ( '[data-testid^="ba-AnnotationTarget"]' ) ;
21+ // Add a region annotation on the document
22+ cy . drawRegion ( ) ;
23+ cy . submitReply ( ) ;
24+
25+ // Assert that at least one annotation is present on the document and is active
26+ cy . get ( '[data-testid^="ba-AnnotationTarget"]' ) . should ( 'have.class' , 'is-active' ) ;
27+
28+ // Exit region creation mode
29+ cy . getByTestId ( 'bp-AnnotationsControls-regionBtn' ) . click ( ) ;
30+
31+ // Assert that annotation target is not active
32+ cy . get ( '[data-testid^="ba-AnnotationTarget"]' ) . should ( 'not.have.class' , 'is-active' ) ;
33+
34+ // Select annotation target
35+ cy . get ( '[data-testid^="ba-AnnotationTarget"]' ) . click ( ) ;
36+
37+ // Assert that annotation target is active
38+ cy . get ( '[data-testid^="ba-AnnotationTarget"]' ) . should ( 'have.class' , 'is-active' ) ;
4239 } ) ;
4340
4441 it ( 'should create a new region on an image' , ( ) => {
@@ -55,27 +52,12 @@ describe('Regions', () => {
5552 // Enter region creation mode
5653 cy . getByTestId ( 'bp-AnnotationsControls-regionBtn' ) . click ( ) ;
5754
58- // Draw a 100x100 region on the image starting at (200, 200)
59- cy . getByTestId ( 'ba-RegionCreator' )
60- . first ( )
61- . trigger ( 'mousedown' , {
62- buttons : 1 ,
63- clientX : 200 ,
64- clientY : 200 ,
65- } )
66- . trigger ( 'mousemove' , {
67- buttons : 1 ,
68- clientX : 300 ,
69- clientY : 300 ,
70- } )
71- . trigger ( 'mouseup' ) ;
72-
73- // Type a message in the reply form and save the new annotation
74- cy . getByTestId ( 'ba-ReplyField-editor' ) . type ( 'This is an automated test annotation.' ) ;
75- cy . getByTestId ( 'ba-Popup-submit' ) . click ( ) ;
76-
77- // Assert that at least one annotation is present on the image
78- cy . get ( '[data-testid^="ba-AnnotationTarget"]' ) ;
55+ // Add a region annotation on the image
56+ cy . drawRegion ( ) ;
57+ cy . submitReply ( ) ;
58+
59+ // Assert that at least one annotation is present on the image and is active
60+ cy . get ( '[data-testid^="ba-AnnotationTarget"]' ) . should ( 'have.class' , 'is-active' ) ;
7961 } ) ;
8062
8163 it ( 'should hide region button for rotated image' , ( ) => {
0 commit comments