Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
test(cy): open attachment in public share
Only in folder description though as we do not allow it from the viewer.

Signed-off-by: Max <[email protected]>
  • Loading branch information
max-nextcloud committed Jul 28, 2025
commit 8b0456472144c17746f60ca27007f1bdbf1de71c
96 changes: 60 additions & 36 deletions cypress/e2e/shareWithAttachments.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ const user = randUser()
const recipient = randUser()

describe('Share with attachments', () => {

before(() => {
cy.createUser(user)
cy.createUser(recipient)
Expand All @@ -18,22 +17,18 @@ describe('Share with attachments', () => {
it('handle file operations by recipient user', () => {
cy.login(user)
const fileName = 'testShared.md'
cy.createMarkdown(
fileName,
'![git](.attachments.123/github.png)',
false,
)
.as('textFileId')
.then((fileId) => {
const attachmentsFolder = `.attachments.${fileId}`
cy.createFolder(attachmentsFolder)
cy.uploadFile(
'github.png',
'image/png',
`${attachmentsFolder}/github.png`,
).as('attachmentId')
cy.shareFileToUser(fileName, recipient)
})
cy.createFile(fileName, '![git](.attachments.123/github.png)')
.as('textFileId')
.then((fileId) => {
const attachmentsFolder = `.attachments.${fileId}`
cy.createFolder(attachmentsFolder)
cy.uploadFile(
'github.png',
'image/png',
`${attachmentsFolder}/github.png`,
).as('attachmentId')
cy.shareFileToUser(fileName, recipient)
})

cy.login(recipient)
cy.showHiddenFiles()
Expand All @@ -44,33 +39,62 @@ describe('Share with attachments', () => {
cy.getFile('github.png').should('not.exist')

// check the attachment folder is not there
cy.getFileId('testShared.md')
.then((documentId) => {
cy.getFile('.attachments.' + documentId).should('not.exist')
})
cy.getFileId('testShared.md').then((documentId) => {
cy.getFile('.attachments.' + documentId).should('not.exist')
})

// move the file and check the attachment folder is still not there
cy.moveFile('testShared.md', 'testMoved.md')
cy.reloadFileList()
cy.getFileId('testMoved.md')
.then((documentId) => {
cy.getFile('.attachments.' + documentId).should('not.exist')
})
cy.getFileId('testMoved.md').then((documentId) => {
cy.getFile('.attachments.' + documentId).should('not.exist')
})

// copy the file and check the attachment folder was copied
cy.copyFile('testMoved.md', 'testCopied.md')
cy.reloadFileList()
cy.getFileId('testCopied.md')
.then((documentId) => {
cy.openFolder('.attachments.' + documentId)
})
cy.get('@attachmentId')
.then((attachmentId) => {
// these are new copied attachment files
// so they should not have the same IDs than the ones created when uploading the files
cy.getFileId('github.png')
.should('not.eq', String(attachmentId))
})
cy.getFileId('testCopied.md').then((documentId) => {
cy.openFolder('.attachments.' + documentId)
})
cy.get('@attachmentId').then((attachmentId) => {
// these are new copied attachment files
// so they should not have the same IDs than the ones created when uploading the files
cy.getFileId('github.png').should('not.eq', String(attachmentId))
})
})
})

describe('Public Share with attachments', () => {
before(function () {
cy.createUser(user)
})

beforeEach(function () {
cy.login(user)
cy.createTestFolder().as('folder').then(cy.shareFile).as('token')
cy.then(function () {
cy.createFile(
`${this.folder}/Readme.md`,
'![Attached text](.attachments.123/lines.txt)',
).as('fileId')
})
cy.then(function () {
const attachmentsFolder = `${this.folder}/.attachments.${this.fileId}`
cy.createFolder(attachmentsFolder)
cy.uploadFile(
'lines.txt',
'text/plain',
`${attachmentsFolder}/lines.txt`,
)
})
cy.clearCookies()
})

it('open attached files in folder description', function () {
cy.visit(`/s/${this.token}`)
cy.get('.content-wrapper').should('exist')
cy.get('.content-wrapper .name', { timeout: 10_000 }).click()
cy.get('.viewer').should('exist')
cy.get('.language-plaintext').should('contain', 'multiple lines')
})
})
Loading