@ -4,13 +4,46 @@
* /
// @ts-expect-error The package is currently broken - but works...
import { deleteDownloadsFolderBeforeEach } from 'cypress-delete-downloads-folder'
import { createShare , getShareUrl , setupPublicShare , type ShareContext } from './setup-public-share.ts'
import { getRowForFile , getRowForFileId , triggerActionForFile , triggerActionForFileId } from '../../files/FilesUtils.ts'
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 } , ( ) = > {
// in general there is no difference except downloading
// as file shares have the source of the share token but a different displayname
describe ( 'file share' , ( ) = > {
let fileId : number
before ( ( ) = > {
cy . createRandomUser ( ) . then ( ( user ) = > {
const context : ShareContext = { user }
cy . uploadContent ( user , new Blob ( [ '<content>foo</content>' ] ) , 'text/plain' , '/file.txt' )
. then ( ( { headers } ) = > { fileId = Number . parseInt ( headers [ 'oc-fileid' ] ) } )
cy . login ( user )
createShare ( context , 'file.txt' )
. then ( ( ) = > cy . logout ( ) )
. then ( ( ) = > cy . visit ( context . url ! ) )
} )
} )
it ( 'can download the file' , ( ) = > {
getRowForFileId ( fileId )
. should ( 'be.visible' )
getRowForFileId ( fileId )
. find ( '[data-cy-files-list-row-name]' )
. should ( ( el ) = > expect ( el . text ( ) ) . to . match ( /file\s*\.txt/ ) ) // extension is sparated so there might be a space between
triggerActionForFileId ( fileId , 'download' )
// check a file is downloaded with the correct name
const downloadsFolder = Cypress . config ( 'downloadsFolder' )
cy . readFile ( ` ${ downloadsFolder } /file.txt ` , 'utf-8' , { timeout : 15000 } )
. should ( 'exist' )
. and ( 'have.length.gt' , 5 )
. and ( 'contain' , '<content>foo</content>' )
} )
} )
describe ( 'folder share' , ( ) = > {
before ( ( ) = > setupPublicShare ( ) )
deleteDownloadsFolderBeforeEach ( )
@ -137,3 +170,4 @@ describe('files_sharing: Public share - downloading files', { testIsolation: tru
} )
} )
} )
} )