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

Fix: Fail gracefully when previewing a doc with deleted reps #962

Merged
merged 6 commits into from
Mar 25, 2019
Merged

Fix: Fail gracefully when previewing a doc with deleted reps #962

merged 6 commits into from
Mar 25, 2019

Conversation

jeremypress
Copy link
Contributor

@jeremypress jeremypress commented Mar 21, 2019

todo

  • tests

@boxcla
Copy link

boxcla commented Mar 21, 2019

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

@jeremypress jeremypress changed the title Fix: Fail gracefully when previewing a doc with deleted reps Fix: Fail gracefully when previewing a doc with deleted reps Mar 21, 2019
jstoffan
jstoffan previously approved these changes Mar 21, 2019
// Display a generic error message but log the real one
const error = new PreviewError(ERROR_CODE.CONTENT_DOWNLOAD, __('error_document'), {}, err.message);
const error =
status === 202
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does pdf.js recognize 202 as an error code or is this placeholder?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's recognized as a success, but then PDF.js will throw a MissingPDFException, which includes the HTTP status code that led to the error.

ERROR_CODE.DELETED_REPS,
__('error_refresh'),
{ isRepDeleted: true },
err.message
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we destructure message, as well?

ConradJChan
ConradJChan previously approved these changes Mar 25, 2019
url: '**/internal_files/**',
status: 202,
response: {}
}).as('bar');
Copy link
Contributor

Choose a reason for hiding this comment

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

Are these aliases used elsewhere?


describe('Document Viewers', () => {
it('Should correctly handle a document with deleted reps', () => {
helpers.checkDeletedRepError();
Copy link
Contributor

Choose a reason for hiding this comment

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

How does this guarantee that the assertion on error happens?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

if this assertion fails, an uncaught exception will be thrown and the test will time out.

ConradJChan
ConradJChan previously approved these changes Mar 25, 2019
jstoffan
jstoffan previously approved these changes Mar 25, 2019

});

it('Should correctly handle a presentation with deleted reps', () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Consider using leche or forEach to cut down on duplication between file types.

it('Should correctly handle a presentation with deleted reps', () => {
helpers.checkDeletedRepError();

cy.showPreview(token, presentationIdDoc, { showAnnotations: false });
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you add a comment as to why annotations is disabled.

@jeremypress jeremypress merged commit d8cd848 into box:master Mar 25, 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