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