Skip to content

Commit

Permalink
feat(IntegrationMultipleFileDownload): add e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
MellyGray committed Dec 11, 2023
1 parent 4ff97b1 commit d032777
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,6 @@ const expectedDatasetAlternateVersion = {
describe('JS Dataset Mapper', () => {
it('maps jsDataset model to the domain Dataset model', () => {
const mapped = JSDatasetMapper.toDataset(jsDataset, citation, datasetSummaryFields)
console.log(mapped)
expect(expectedDataset).to.deep.equal(mapped)
})
it('maps jsDataset model to the domain Dataset model for alternate version', () => {
Expand Down
99 changes: 58 additions & 41 deletions tests/e2e-integration/e2e/sections/dataset/Dataset.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -419,54 +419,71 @@ describe('Dataset', () => {
})
})

it('downloads a file', () => {
cy.wrap(
DatasetHelper.createWithFiles(FileHelper.createMany(1)).then((dataset) =>
DatasetHelper.publish(dataset.persistentId)
describe('Downloading files', () => {
it('downloads a file', () => {
cy.wrap(
DatasetHelper.createWithFiles(FileHelper.createMany(1)).then((dataset) =>
DatasetHelper.publish(dataset.persistentId)
)
)
)
.its('persistentId')
.then((persistentId: string) => {
cy.wait(1500) // Wait for the dataset to be published
cy.visit(`/spa/datasets?persistentId=${persistentId}`)
cy.wait(1500) // Wait for the page to load

cy.findByText('Files').should('exist')

cy.findByRole('button', { name: 'Access File' }).should('exist').click()

// Workaround for issue where Cypress gets stuck on the download
cy.window()
.document()
.then(function (doc) {
doc.addEventListener('click', () => {
setTimeout(function () {
doc.location.reload()
}, 5000)
.its('persistentId')
.then((persistentId: string) => {
cy.wait(1500) // Wait for the dataset to be published
cy.visit(`/spa/datasets?persistentId=${persistentId}`)
cy.wait(1500) // Wait for the page to load

cy.findByText('Files').should('exist')

cy.findByRole('button', { name: 'Access File' }).should('exist').click()

// Workaround for issue where Cypress gets stuck on the download
cy.window()
.document()
.then(function (doc) {
doc.addEventListener('click', () => {
setTimeout(function () {
doc.location.reload()
}, 5000)
})
cy.findByText('Plain Text').should('exist').click()
})
cy.findByText('Plain Text').should('exist').click()
})

cy.findByText('1 Downloads').should('exist')
})
})
cy.findByText('1 Downloads').should('exist')
})
})

it.only('downloads multiple files', () => {
cy.wrap(
DatasetHelper.createWithFiles(FileHelper.createMany(3)).then((dataset) =>
DatasetHelper.publish(dataset.persistentId)
it('downloads multiple files', () => {
cy.wrap(
DatasetHelper.createWithFiles(FileHelper.createMany(3)).then((dataset) =>
DatasetHelper.publish(dataset.persistentId)
)
)
)
.its('persistentId')
.then((persistentId: string) => {
cy.visit(`/spa/datasets?persistentId=${persistentId}`)
cy.wait(1500) // Wait for the page to load
.its('persistentId')
.then((persistentId: string) => {
cy.wait(1500) // Wait for the page to load
cy.visit(`/spa/datasets?persistentId=${persistentId}`)
cy.wait(1500) // Wait for the page to load

cy.findByText('Files').should('exist')

cy.findByText('Files').should('exist')
cy.get('table > thead > tr > th > input[type=checkbox]').click()

cy.get('table > thead > tr > th > input[type=checkbox]').click()
cy.findByRole('button', { name: 'Download' }).should('exist').click({ force: true })

cy.findByRole('button', { name: 'Download' }).should('exist').click()
})
// Workaround for issue where Cypress gets stuck on the download
cy.window()
.document()
.then(function (doc) {
doc.addEventListener('click', () => {
setTimeout(function () {
doc.location.reload()
}, 5000)
})
cy.findByText('Original Format').should('exist').click()
})

cy.findAllByText('1 Downloads').should('exist')
})
})
})
})

0 comments on commit d032777

Please sign in to comment.