1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
import type { User } from "@nextcloud/cypress"
/**
* SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
describe('Files', { testIsolation: true }, () => {
let currentUser: User
beforeEach(() => {
cy.createRandomUser().then((user) => {
currentUser = user
})
})
it('Login with a user and open the files app', () => {
cy.login(currentUser)
cy.visit('/apps/files')
cy.get('[data-cy-files-list] [data-cy-files-list-row-name="welcome.txt"]').should('be.visible')
})
it('Opens a valid file shows it as active', () => {
cy.uploadContent(currentUser, new Blob(), 'text/plain', '/original.txt').then((response) => {
const fileId = Number.parseInt(response.headers['oc-fileid'] ?? '0')
cy.login(currentUser)
cy.visit('/apps/files/files/' + fileId)
cy.get(`[data-cy-files-list-row-fileid=${fileId}]`)
.should('be.visible')
cy.get(`[data-cy-files-list-row-fileid=${fileId}]`)
.invoke('attr', 'data-cy-files-list-row-name').should('eq', 'original.txt')
cy.get(`[data-cy-files-list-row-fileid=${fileId}]`)
.invoke('attr', 'class').should('contain', 'active')
cy.contains('The file could not be found').should('not.exist')
})
})
it('Opens a valid folder shows its content', () => {
cy.mkdir(currentUser, '/folder').then(() => {
cy.login(currentUser)
cy.visit('/apps/files/files?dir=/folder')
cy.get('[data-cy-files-content-breadcrumbs]').contains('folder').should('be.visible')
cy.contains('The file could not be found').should('not.exist')
})
})
it('Opens an unknown file show an error', () => {
cy.intercept('PROPFIND', /\/remote.php\/dav\//).as('propfind')
cy.login(currentUser)
cy.visit('/apps/files/files/123456')
cy.wait('@propfind')
cy.contains('The file could not be found').should('be.visible')
})
})
|