mirror of
https://github.com/nextcloud/server.git
synced 2026-05-25 10:49:21 -04:00
test: Add E2E tests for trashbin columns
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
This commit is contained in:
parent
0258167877
commit
2ebfe0dbf4
2 changed files with 98 additions and 0 deletions
|
|
@ -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 }, () => {
|
||||
|
|
@ -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')
|
||||
})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -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
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in a new issue