Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(cypress): Add E2E tests for promoting highlight annotations #623

Merged
merged 2 commits into from
Oct 9, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions test/integration/Highlight.e2e.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,29 @@ describe('Highlights', () => {
// Assert that annotation target is active
cy.get('.ba-HighlightTarget').should('have.class', 'is-active');
});

it('should create a new highlight via promotion on a document', () => {
// Show the preview
cy.showPreview(Cypress.env('FILE_ID_DOC'));

// Wait for the highlight layer to be present
cy.getByTestId('ba-Layer--highlight');

// Assert that only one highlight annotation created in the above test is present
cy.get('.ba-HighlightTarget').should('have.length', 1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can cypress tests be run individually? Seems like we should try to avoid relying on side effects of other tests if possible

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We would need to manually delete any existing annotations in a teardown step after each test and/or suite.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That or we could go back to that logic @mxiao6 had to count the annotations before and after so it's more of a relative check?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about combining them into one test?


// Select text to trigger promotion flow
cy.selectText({ block: 2 });
cy.getByTestId('ba-PopupHighlight-button').click();
// Add a highlight annotation on the document
cy.submitReply();

// Assert that one more highlight annotation is present on the document and is active
cy.get('.ba-HighlightTarget')
.should('have.length', 2)
.should('have.class', 'is-active');

// Assert highlight creation mode is not active
cy.getByTestId('bp-AnnotationsControls-highlightBtn').should('not.have.class', 'is-active');
});
});