|
| 1 | +import type { User } from "@nextcloud/cypress" |
| 2 | + |
1 | 3 | /** |
2 | 4 | * @copyright Copyright (c) 2022 John Molakvoæ <[email protected]> |
3 | 5 | * |
|
20 | 22 | * |
21 | 23 | */ |
22 | 24 | describe('Files', { testIsolation: true }, () => { |
| 25 | + let currentUser: User |
| 26 | + |
23 | 27 | beforeEach(() => { |
24 | 28 | cy.createRandomUser().then((user) => { |
25 | | - cy.login(user) |
| 29 | + currentUser = user |
26 | 30 | }) |
27 | 31 | }) |
28 | 32 |
|
29 | 33 | it('Login with a user and open the files app', () => { |
| 34 | + cy.login(currentUser) |
30 | 35 | cy.visit('/apps/files') |
31 | 36 | cy.get('[data-cy-files-list] [data-cy-files-list-row-name="welcome.txt"]').should('be.visible') |
32 | 37 | }) |
| 38 | + |
| 39 | + it('Opens a valid file shows it as active', () => { |
| 40 | + cy.uploadContent(currentUser, new Blob(), 'text/plain', '/original.txt').then((response) => { |
| 41 | + const fileId = Number.parseInt(response.headers['oc-fileid'] ?? '0') |
| 42 | + |
| 43 | + cy.login(currentUser) |
| 44 | + cy.visit('/apps/files/files/' + fileId) |
| 45 | + |
| 46 | + cy.get(`[data-cy-files-list-row-fileid=${fileId}]`) |
| 47 | + .should('be.visible') |
| 48 | + cy.get(`[data-cy-files-list-row-fileid=${fileId}]`) |
| 49 | + .invoke('attr', 'data-cy-files-list-row-name').should('eq', 'original.txt') |
| 50 | + cy.get(`[data-cy-files-list-row-fileid=${fileId}]`) |
| 51 | + .invoke('attr', 'class').should('contain', 'active') |
| 52 | + cy.contains('The file could not be found').should('not.exist') |
| 53 | + }) |
| 54 | + }) |
| 55 | + |
| 56 | + it('Opens a valid folder shows its content', () => { |
| 57 | + cy.mkdir(currentUser, '/folder').then(() => { |
| 58 | + cy.login(currentUser) |
| 59 | + cy.visit('/apps/files/files?dir=/folder') |
| 60 | + |
| 61 | + cy.get('[data-cy-files-content-breadcrumbs]').contains('folder').should('be.visible') |
| 62 | + cy.contains('The file could not be found').should('not.exist') |
| 63 | + }) |
| 64 | + }) |
| 65 | + |
| 66 | + it('Opens an unknown file show an error', () => { |
| 67 | + cy.intercept('PROPFIND', /\/remote.php\/dav\//).as('propfind') |
| 68 | + cy.login(currentUser) |
| 69 | + cy.visit('/apps/files/files/123456') |
| 70 | + |
| 71 | + cy.wait('@propfind') |
| 72 | + cy.contains('The file could not be found').should('be.visible') |
| 73 | + }) |
33 | 74 | }) |
0 commit comments