|
5 | 5 |
|
6 | 6 | import type { User } from '@nextcloud/e2e-test-server/cypress' |
7 | 7 |
|
| 8 | +import { ShareType } from '@nextcloud/sharing' |
8 | 9 | import { deleteDownloadsFolderBeforeEach } from '../../support/utils/deleteDownloadsFolder.ts' |
| 10 | +import { randomString } from '../../support/utils/randomString.ts' |
9 | 11 | import { deleteFileWithRequest, getRowForFileId, selectAllFiles, triggerActionForFileId } from '../files/FilesUtils.ts' |
10 | 12 |
|
11 | 13 | describe('files_trashbin: download files', { testIsolation: true }, () => { |
@@ -67,3 +69,69 @@ describe('files_trashbin: download files', { testIsolation: true }, () => { |
67 | 69 | cy.get('[data-cy-files-list-selection-action="download"]').should('not.exist') |
68 | 70 | }) |
69 | 71 | }) |
| 72 | + |
| 73 | +describe('files_trashbin: file row', { testIsolation: true }, () => { |
| 74 | + let alice: User |
| 75 | + let bob: User |
| 76 | + let randomGroupName: string |
| 77 | + let fileId: number |
| 78 | + |
| 79 | + before(() => { |
| 80 | + randomGroupName = randomString(10) |
| 81 | + cy.runOccCommand(`group:add ${randomGroupName}`) |
| 82 | + |
| 83 | + cy.createRandomUser().then((user) => { |
| 84 | + alice = user |
| 85 | + |
| 86 | + cy.modifyUser(alice, 'display', 'Alice') |
| 87 | + |
| 88 | + cy.mkdir(alice, '/Shared') |
| 89 | + }) |
| 90 | + |
| 91 | + cy.createRandomUser().then((user) => { |
| 92 | + bob = user |
| 93 | + |
| 94 | + cy.modifyUser(bob, 'display', 'Bob') |
| 95 | + |
| 96 | + cy.runOccCommand(`group:adduser ${randomGroupName} ${bob.userId}`) |
| 97 | + }) |
| 98 | + }) |
| 99 | + |
| 100 | + it('shows data for file deleted by owner', () => { |
| 101 | + cy.uploadContent(alice, new Blob(['<content>']), 'text/plain', '/test-file.txt') |
| 102 | + .then(({ headers }) => fileId = Number.parseInt(headers['oc-fileid'])) |
| 103 | + .then(() => deleteFileWithRequest(alice, '/test-file.txt')) |
| 104 | + |
| 105 | + cy.login(alice) |
| 106 | + cy.visit('/apps/files/trashbin') |
| 107 | + |
| 108 | + getRowForFileId(fileId).should('be.visible') |
| 109 | + // The full name includes one span for the name and one span for the |
| 110 | + // extension, so text() returns a space when composing them even if it |
| 111 | + // will not be visible when rendered in the browser. |
| 112 | + getRowForFileId(fileId).find('[data-cy-files-list-row-name]').should((element) => expect(element.text().trim()).to.equal('test-file .txt')) |
| 113 | + getRowForFileId(fileId).find('[data-cy-files-list-row-column-custom="files_trashbin--original-location"]').should('have.text', 'All files') |
| 114 | + getRowForFileId(fileId).find('[data-cy-files-list-row-column-custom="files_trashbin--deleted-by"]').should('have.text', 'You') |
| 115 | + getRowForFileId(fileId).find('[data-cy-files-list-row-column-custom="files_trashbin--deleted"]').should('have.text', 'few seconds ago') |
| 116 | + }) |
| 117 | + |
| 118 | + it('shows data for file deleted by sharee in a folder shared with a group', () => { |
| 119 | + cy.createShare(alice, '/Shared', ShareType.Group, randomGroupName) |
| 120 | + |
| 121 | + cy.uploadContent(alice, new Blob(['<content>']), 'text/plain', '/Shared/test-file.txt') |
| 122 | + .then(({ headers }) => fileId = Number.parseInt(headers['oc-fileid'])) |
| 123 | + .then(() => deleteFileWithRequest(bob, '/Shared/test-file.txt')) |
| 124 | + |
| 125 | + cy.login(alice) |
| 126 | + cy.visit('/apps/files/trashbin') |
| 127 | + |
| 128 | + getRowForFileId(fileId).should('be.visible') |
| 129 | + // The full name includes one span for the name and one span for the |
| 130 | + // extension, so text() returns a space when composing them even if it |
| 131 | + // will not be visible when rendered in the browser. |
| 132 | + getRowForFileId(fileId).find('[data-cy-files-list-row-name]').should((element) => expect(element.text().trim()).to.equal('test-file .txt')) |
| 133 | + getRowForFileId(fileId).find('[data-cy-files-list-row-column-custom="files_trashbin--original-location"]').should('have.text', 'Shared') |
| 134 | + getRowForFileId(fileId).find('[data-cy-files-list-row-column-custom="files_trashbin--deleted-by"]').should('have.text', 'Bob') |
| 135 | + getRowForFileId(fileId).find('[data-cy-files-list-row-column-custom="files_trashbin--deleted"]').should('have.text', 'few seconds ago') |
| 136 | + }) |
| 137 | +}) |
0 commit comments