-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jeremy Press
committed
Mar 25, 2019
1 parent
0139cd9
commit c295026
Showing
2 changed files
with
67 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// <reference types="Cypress" /> | ||
describe('Previewing a file with Deleted Representations', () => { | ||
const token = Cypress.env('ACCESS_TOKEN'); | ||
|
||
const fileIdDoc = Cypress.env('FILE_ID_DOC'); | ||
const presentationIdDoc = Cypress.env('FILE_ID_PRESENTATION'); | ||
|
||
const REPS_ERROR = 'error_deleted_reps'; | ||
|
||
const helpers = { | ||
checkDeletedRepError: () => { | ||
cy.window().then((win) => { | ||
win.preview.addListener('preview_error', (data) => { | ||
cy.expect(data.error.code).to.equal(REPS_ERROR); | ||
}) | ||
}); | ||
} | ||
} | ||
|
||
beforeEach(() => { | ||
cy.server(); | ||
// Make the representation content call to always return a 202 with no body | ||
|
||
// Mocking requests for non original reps | ||
cy.route({ | ||
method: 'GET', | ||
url: '**/internal_files/**', | ||
status: 202, | ||
response: {} | ||
}).as('bar'); | ||
|
||
// Mocking requests for original reps | ||
cy.route({ | ||
method: 'GET', | ||
url: '**/content?**', | ||
status: 202, | ||
response: {} | ||
}).as('bas'); | ||
|
||
cy.visit('/', { | ||
onBeforeLoad (win) { | ||
// Workaround for fetch detection in cypress mocking. https://github.com/cypress-io/cypress/issues/95 | ||
delete win.fetch //eslint-disable-line | ||
} | ||
}) | ||
}); | ||
|
||
describe('Document Viewers', () => { | ||
it('Should correctly handle a document with deleted reps', () => { | ||
helpers.checkDeletedRepError(); | ||
|
||
cy.showPreview(token, fileIdDoc, { showAnnotations: false }); | ||
|
||
}); | ||
|
||
it('Should correctly handle a presentation with deleted reps', () => { | ||
helpers.checkDeletedRepError(); | ||
|
||
cy.showPreview(token, presentationIdDoc, { showAnnotations: false }); | ||
}); | ||
}); | ||
}); |