|
| 1 | +/// <reference types="Cypress" /> |
| 2 | +describe('Discoverability', () => { |
| 3 | + beforeEach(() => { |
| 4 | + cy.visit('/'); |
| 5 | + }); |
| 6 | + |
| 7 | + it('should be able to draw a region without entering the mode', () => { |
| 8 | + // Show the preview |
| 9 | + cy.showPreview(Cypress.env('FILE_ID_DOC_SANITY')); |
| 10 | + |
| 11 | + // Wait for the region layer to be present |
| 12 | + cy.getByTestId('ba-Layer--region'); |
| 13 | + |
| 14 | + // Add a region annotation on the document |
| 15 | + cy.drawRegion(); |
| 16 | + cy.getByTestId('ba-Popup-cancel').click(); |
| 17 | + |
| 18 | + // Assert that annotation target is not active |
| 19 | + cy.get('.ba-RegionAnnotation').should('not.have.class', 'is-active'); |
| 20 | + |
| 21 | + // Select annotation target |
| 22 | + cy.get('.ba-RegionAnnotation').click(); |
| 23 | + |
| 24 | + // Assert that annotation target is active |
| 25 | + cy.get('.ba-RegionAnnotation').should('have.class', 'is-active'); |
| 26 | + }); |
| 27 | + |
| 28 | + it('should be able to promote a highlight without entering the mode', () => { |
| 29 | + // Show the preview |
| 30 | + cy.showPreview(Cypress.env('FILE_ID_DOC_SANITY')); |
| 31 | + |
| 32 | + // Wait for the region layer to be present |
| 33 | + cy.getByTestId('ba-Layer--highlight'); |
| 34 | + |
| 35 | + // Add a highlight annotation on the document |
| 36 | + cy.selectText(); |
| 37 | + cy.getByTestId('ba-PopupHighlight-button').click(); |
| 38 | + cy.getByTestId('ba-Popup-cancel').click(); |
| 39 | + |
| 40 | + // Assert that annotation target is not active |
| 41 | + cy.get('.ba-HighlightTarget').should('not.have.class', 'is-active'); |
| 42 | + |
| 43 | + // Select annotation target |
| 44 | + cy.get('.ba-HighlightTarget-rect') |
| 45 | + .first() |
| 46 | + .click(); |
| 47 | + |
| 48 | + // Assert that annotation target is active |
| 49 | + cy.get('.ba-HighlightTarget').should('have.class', 'is-active'); |
| 50 | + }); |
| 51 | + |
| 52 | + it('should leave region mode if zooming in on an image', () => { |
| 53 | + // Show the preview |
| 54 | + cy.showPreview(Cypress.env('FILE_ID_IMAGE_SANITY')); |
| 55 | + |
| 56 | + // Wait for annotations to load |
| 57 | + cy.get('.bp-image').should('have.class', 'ba-annotations-loaded'); |
| 58 | + |
| 59 | + // Check that after zooming in, the region annotation button is no longer active |
| 60 | + cy.getByTestId('bp-AnnotationsControls-regionBtn').should('have.class', 'bp-is-active'); |
| 61 | + cy.getByTestId('bp-ZoomControls-in').click(); |
| 62 | + cy.getByTestId('bp-AnnotationsControls-regionBtn').should('not.have.class', 'bp-is-active'); |
| 63 | + }); |
| 64 | + |
| 65 | + it('should remain in region mode after initial zoom occurs on an image', () => { |
| 66 | + // Show the preview |
| 67 | + cy.showPreview(Cypress.env('FILE_ID_IMAGE_SANITY')); |
| 68 | + |
| 69 | + // Wait for annotations to load |
| 70 | + cy.get('.bp-image').should('have.class', 'ba-annotations-loaded'); |
| 71 | + |
| 72 | + // Check that after zooming in, the region annotation button is no longer active |
| 73 | + cy.getByTestId('bp-AnnotationsControls-regionBtn').should('have.class', 'bp-is-active'); |
| 74 | + cy.getByTestId('bp-ZoomControls-in').click(); |
| 75 | + cy.getByTestId('bp-AnnotationsControls-regionBtn') |
| 76 | + .should('not.have.class', 'bp-is-active') |
| 77 | + .click() |
| 78 | + .should('have.class', 'bp-is-active'); |
| 79 | + |
| 80 | + cy.getByTestId('bp-ZoomControls-out').click(); |
| 81 | + cy.getByTestId('bp-AnnotationsControls-regionBtn').should('have.class', 'bp-is-active'); |
| 82 | + }); |
| 83 | +}); |
0 commit comments