-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(files): properly show file not found error
Signed-off-by: skjnldsv <[email protected]>
- Loading branch information
Showing
2 changed files
with
56 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
import type { User } from "@nextcloud/cypress" | ||
|
||
/** | ||
* @copyright Copyright (c) 2022 John Molakvoæ <[email protected]> | ||
* | ||
|
@@ -20,14 +22,53 @@ | |
* | ||
*/ | ||
describe('Files', { testIsolation: true }, () => { | ||
let currentUser: User | ||
|
||
beforeEach(() => { | ||
cy.createRandomUser().then((user) => { | ||
cy.login(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') | ||
}) | ||
}) |