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

Chore: adding e2e tests for Thumbnails #915

Merged

Conversation

ConradJChan
Copy link
Contributor

@ConradJChan ConradJChan commented Feb 5, 2019

Modified the test fixture index.html to have an explicit load preview button instead of loading it when submitting the token or file id. This is to make it easier when using it during e2e Cypress testing to invoke it with preview options.

@boxcla
Copy link

boxcla commented Feb 5, 2019

Verified that @ConradJChan has signed the CLA. Thanks for the pull request!

@@ -50,7 +50,7 @@
<button class="bp-btn-plain bp-btn-loading-download bp-is-invisible"></button>
</div>
</div>
<div class="bp-content">
<div class="bp-content" data-testid="bp-content">
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we stripping out data-testid like in elements?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah we are, so this will get stripped out but html elements created via javascript won't. But when talking to @jstoffan this wasn't an issue because stripping these out is mainly to decrease bloat in the bundle.


/* eslint-disable */
const getThumbnail = (pageNum) => cy.get(`.bp-thumbnail[data-bp-page-num=${pageNum}]`);
const showDocumentPreview = (enableThumbnailsSidebar) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Passing in an object with a named enableThumbnailsSidebar property makes this a bit easier to read.

@@ -4,11 +4,17 @@ Cypress.Commands.add('getPreviewPage', (pageNum) => {
cy
.get(`.page[data-page-number=${pageNum}]`)
.as('previewPage')
.find('[data-testid="page-loading-indicator"]')
// Adding 10s timeout here because there's no reliable way to wait for
Copy link
Collaborator

Choose a reason for hiding this comment

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

Using the loading indicator seems reliable, but the document just might take longer to load/render than the default timeout allows.

@@ -19,6 +25,8 @@ Cypress.Commands.add('showPreview', (token, fileId, options) => {
cy.window().then((win) => {
win.loadPreview(options);
});
} else {
cy.getByTestId('load-preview').click();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this needed or can we just remove the if (options) check above and allow win.loadPreview(options) to be used for all showPreview invocations. It seems like it would be the same effect.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah that's cleaner let me change that

@@ -4,22 +4,26 @@ Cypress.Commands.add('getPreviewPage', (pageNum) => {
cy
.get(`.page[data-page-number=${pageNum}]`)
.as('previewPage')
.find('[data-testid="page-loading-indicator"]')
// Adding 10s timeout here because sometimes it takes more than the Cypress
Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks like the duration in the comment is outdated. Probably easier to just remove it?

@ConradJChan ConradJChan merged commit 9ed2d2b into box:thumbnails-sidebar Feb 6, 2019
@ConradJChan ConradJChan deleted the thumbnails-e2e-tests branch February 6, 2019 02:29
ConradJChan pushed a commit to ConradJChan/box-content-preview that referenced this pull request Feb 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants