-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: adding e2e test instead for download errors
- Loading branch information
Priyajeet Hora
committed
Oct 10, 2019
1 parent
a7da11e
commit 9f36375
Showing
2 changed files
with
40 additions
and
0 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,39 @@ | ||
// <reference types='Cypress' /> | ||
describe('Download disabled while preview is already open', () => { | ||
const token = Cypress.env('ACCESS_TOKEN'); | ||
const fileIdBad = Cypress.env('FILE_ID_BAD'); | ||
|
||
beforeEach(() => { | ||
cy.visit('/'); | ||
}); | ||
|
||
it('should give generic download error when trying to download and its forbidden', () => { | ||
cy.showPreview(token, fileIdBad, { showDownload: true }); | ||
cy.route({ | ||
method: 'GET', | ||
url: `**/files/${fileIdBad}?fields=download_url`, | ||
status: 403, | ||
response: {}, | ||
}); | ||
|
||
cy.getByTestId('preview-error-download-btn').should('be.visible'); | ||
cy.getByTestId('preview-error-download-btn').click(); | ||
cy.contains('Sorry! You can’t download this file.'); | ||
}); | ||
|
||
it('should give shield error when trying to download and access policy prevents download', () => { | ||
cy.showPreview(token, fileIdBad, { showDownload: true }); | ||
cy.route({ | ||
method: 'GET', | ||
url: `**/files/${fileIdBad}?fields=download_url`, | ||
status: 403, | ||
response: { | ||
code: 'forbidden_by_policy', | ||
}, | ||
}); | ||
|
||
cy.getByTestId('preview-error-download-btn').should('be.visible'); | ||
cy.getByTestId('preview-error-download-btn').click(); | ||
cy.contains('Downloading of this content has been disabled based on an access policy.'); | ||
}); | ||
}); |