Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 7 additions & 1 deletion apps/files/src/components/FileEntry.vue
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
<CustomElementRender
:active-folder="activeFolder"
:active-view="activeView"
:render="column.render"
:render="adaptColumnRenderToCustomElementRender(column)"
:source="source" />
</td>
</tr>
Expand Down Expand Up @@ -299,6 +299,12 @@ export default defineComponent({
view: this.activeView!,
})
},

adaptColumnRenderToCustomElementRender(column) {
return ({ nodes, view }) => {
return column.render(nodes[0], view)
}
},
},
})
</script>
68 changes: 68 additions & 0 deletions cypress/e2e/files_trashbin/files.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@

import type { User } from '@nextcloud/e2e-test-server/cypress'

import { ShareType } from '@nextcloud/sharing'
import { deleteDownloadsFolderBeforeEach } from '../../support/utils/deleteDownloadsFolder.ts'
import { randomString } from '../../support/utils/randomString.ts'
import { deleteFileWithRequest, getRowForFileId, selectAllFiles, triggerActionForFileId } from '../files/FilesUtils.ts'

describe('files_trashbin: download files', { testIsolation: true }, () => {
Expand Down Expand Up @@ -67,3 +69,69 @@ describe('files_trashbin: download files', { testIsolation: true }, () => {
cy.get('[data-cy-files-list-selection-action="download"]').should('not.exist')
})
})

describe('files_trashbin: file row', { testIsolation: true }, () => {
let alice: User
let bob: User
let randomGroupName: string
let fileId: number

before(() => {
randomGroupName = randomString(10)
cy.runOccCommand(`group:add ${randomGroupName}`)

cy.createRandomUser().then((user) => {
alice = user

cy.modifyUser(alice, 'display', 'Alice')

cy.mkdir(alice, '/Shared')
})

cy.createRandomUser().then((user) => {
bob = user

cy.modifyUser(bob, 'display', 'Bob')

cy.runOccCommand(`group:adduser ${randomGroupName} ${bob.userId}`)
})
})

it('shows data for file deleted by owner', () => {
cy.uploadContent(alice, new Blob(['<content>']), 'text/plain', '/test-file.txt')
.then(({ headers }) => fileId = Number.parseInt(headers['oc-fileid']))
.then(() => deleteFileWithRequest(alice, '/test-file.txt'))

cy.login(alice)
cy.visit('/apps/files/trashbin')

getRowForFileId(fileId).should('be.visible')
// The full name includes one span for the name and one span for the
// extension, so text() returns a space when composing them even if it
// will not be visible when rendered in the browser.
getRowForFileId(fileId).find('[data-cy-files-list-row-name]').should((element) => expect(element.text().trim()).to.equal('test-file .txt'))
getRowForFileId(fileId).find('[data-cy-files-list-row-column-custom="files_trashbin--original-location"]').should('have.text', 'All files')
getRowForFileId(fileId).find('[data-cy-files-list-row-column-custom="files_trashbin--deleted-by"]').should('have.text', 'You')
getRowForFileId(fileId).find('[data-cy-files-list-row-column-custom="files_trashbin--deleted"]').should('have.text', 'few seconds ago')
})

it('shows data for file deleted by sharee in a folder shared with a group', () => {
cy.createShare(alice, '/Shared', ShareType.Group, randomGroupName)

cy.uploadContent(alice, new Blob(['<content>']), 'text/plain', '/Shared/test-file.txt')
.then(({ headers }) => fileId = Number.parseInt(headers['oc-fileid']))
.then(() => deleteFileWithRequest(bob, '/Shared/test-file.txt'))

cy.login(alice)
cy.visit('/apps/files/trashbin')

getRowForFileId(fileId).should('be.visible')
// The full name includes one span for the name and one span for the
// extension, so text() returns a space when composing them even if it
// will not be visible when rendered in the browser.
getRowForFileId(fileId).find('[data-cy-files-list-row-name]').should((element) => expect(element.text().trim()).to.equal('test-file .txt'))
getRowForFileId(fileId).find('[data-cy-files-list-row-column-custom="files_trashbin--original-location"]').should('have.text', 'Shared')
getRowForFileId(fileId).find('[data-cy-files-list-row-column-custom="files_trashbin--deleted-by"]').should('have.text', 'Bob')
getRowForFileId(fileId).find('[data-cy-files-list-row-column-custom="files_trashbin--deleted"]').should('have.text', 'few seconds ago')
})
})
30 changes: 30 additions & 0 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,36 @@ Cypress.Commands.add('uploadContent', (user: User, blob: Blob, mimeType: string,
})
})

Cypress.Commands.add('createShare', (sharer: User, path: string, shareType: number, shareWith: string) => {
return cy.clearCookies()
.then(async () => {
try {
const url = `${Cypress.env('baseUrl')}/ocs/v2.php/apps/files_sharing/api/v1/shares`
const response = await axios({
url,
method: 'POST',
auth: {
username: sharer.userId,
password: sharer.password,
},
headers: {
'OCS-ApiRequest': 'true',
},
data: {
path,
shareType,
shareWith,
},
})
cy.log(`Created share for ${path} of type ${shareType} with ${shareWith}`, response)
return response
} catch (cause) {
cy.log('error', cause)
throw new Error(`Unable to create share for ${path} of type ${shareType} with ${shareWith}`, { cause })
}
})
})

/**
* Reset the admin theming entirely
*/
Expand Down
4 changes: 2 additions & 2 deletions dist/files-main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files-main.js.map

Large diffs are not rendered by default.

Loading