123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 |
- import { deleteDownloadsFolderBeforeEach } from 'cypress-delete-downloads-folder'
- import { zipFileContains } from '../../../support/utils/assertions.ts'
- import { getRowForFile, triggerActionForFile } from '../../files/FilesUtils.ts'
- import { getShareUrl, setupPublicShare } from './setup-public-share.ts'
- describe('files_sharing: Public share - downloading files', { testIsolation: true }, () => {
- before(() => setupPublicShare())
- deleteDownloadsFolderBeforeEach()
- beforeEach(() => {
- cy.logout()
- cy.visit(getShareUrl())
- })
- it('Can download all files', () => {
- getRowForFile('foo.txt').should('be.visible')
- cy.get('[data-cy-files-list]').within(() => {
- cy.findByRole('checkbox', { name: /Toggle selection for all files/i })
- .should('exist')
- .check({ force: true })
-
- cy.contains('2 selected').should('be.visible')
-
- cy.findByRole('button', { name: 'Download (selected)' })
- .should('be.visible')
- .click()
-
- const downloadsFolder = Cypress.config('downloadsFolder')
- cy.readFile(`${downloadsFolder}/download.zip`, null, { timeout: 15000 })
- .should('exist')
- .and('have.length.gt', 30)
-
- .and(zipFileContains([
- 'foo.txt',
- 'subfolder/',
- 'subfolder/bar.txt',
- ]))
- })
- })
- it('Can download selected files', () => {
- getRowForFile('subfolder')
- .should('be.visible')
- cy.get('[data-cy-files-list]').within(() => {
- getRowForFile('subfolder')
- .findByRole('checkbox')
- .check({ force: true })
-
- cy.contains('1 selected').should('be.visible')
-
- cy.findByRole('button', { name: 'Download (selected)' })
- .should('be.visible')
- .click()
-
- const downloadsFolder = Cypress.config('downloadsFolder')
- cy.readFile(`${downloadsFolder}/subfolder.zip`, null, { timeout: 15000 })
- .should('exist')
- .and('have.length.gt', 30)
-
- .and(zipFileContains([
- 'subfolder/',
- 'subfolder/bar.txt',
- ]))
- })
- })
- it('Can download folder by action', () => {
- getRowForFile('subfolder')
- .should('be.visible')
- cy.get('[data-cy-files-list]').within(() => {
- triggerActionForFile('subfolder', 'download')
-
- const downloadsFolder = Cypress.config('downloadsFolder')
- cy.readFile(`${downloadsFolder}/subfolder.zip`, null, { timeout: 15000 })
- .should('exist')
- .and('have.length.gt', 30)
-
- .and(zipFileContains([
- 'subfolder/',
- 'subfolder/bar.txt',
- ]))
- })
- })
- it('Can download file by action', () => {
- getRowForFile('foo.txt')
- .should('be.visible')
- cy.get('[data-cy-files-list]').within(() => {
- triggerActionForFile('foo.txt', 'download')
-
- const downloadsFolder = Cypress.config('downloadsFolder')
- cy.readFile(`${downloadsFolder}/foo.txt`, 'utf-8', { timeout: 15000 })
- .should('exist')
- .and('have.length.gt', 5)
- .and('contain', '<content>foo</content>')
- })
- })
- it('Can download file by selection', () => {
- getRowForFile('foo.txt')
- .should('be.visible')
- cy.get('[data-cy-files-list]').within(() => {
- getRowForFile('foo.txt')
- .findByRole('checkbox')
- .check({ force: true })
- cy.findByRole('button', { name: 'Download (selected)' })
- .click()
-
- const downloadsFolder = Cypress.config('downloadsFolder')
- cy.readFile(`${downloadsFolder}/foo.txt`, 'utf-8', { timeout: 15000 })
- .should('exist')
- .and('have.length.gt', 5)
- .and('contain', '<content>foo</content>')
- })
- })
- })
|