-
-
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): Update displayname on rename
Nextcloud always sets the `displayname` attribute, with fallback to the basename. So if we move or rename a file the old displayname will still be used as we only update the basename but not the displayname. Safest would be refetch, but if displayname and basename is equal we can safe one request and set the displayname to the new basename. Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
- Loading branch information
Showing
2 changed files
with
57 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/** | ||
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors | ||
* SPDX-License-Identifier: AGPL-3.0-or-later | ||
*/ | ||
|
||
import { getRowForFile, renameFile, triggerActionForFile } from './FilesUtils.ts' | ||
|
||
/** | ||
* This is a regression test for https://github.com/nextcloud/server/issues/43331 | ||
* Where files with XML entities in their names were wrongly displayed and could no longer be renamed / deleted etc. | ||
*/ | ||
describe('Files: Can rename files', { testIsolation: false }, () => { | ||
before(() => { | ||
cy.createRandomUser().then((user) => { | ||
cy.uploadContent(user, new Blob(), 'text/plain', '/foo.txt') | ||
cy.login(user) | ||
cy.visit('/apps/files/') | ||
}) | ||
}) | ||
|
||
it('See that the file is named correctly', () => { | ||
getRowForFile('foo.txt') | ||
.should('be.visible') | ||
.should('contain.text', 'foo.txt') | ||
}) | ||
|
||
it('Can rename the file', () => { | ||
cy.intercept('MOVE', /\/remote.php\/dav\/files\//).as('renameFile') | ||
|
||
renameFile('foo.txt', 'bar.txt') | ||
cy.wait('@renameFile') | ||
|
||
getRowForFile('bar.txt') | ||
.should('be.visible') | ||
}) | ||
|
||
it('See that the name is correctly shown', () => { | ||
getRowForFile('bar.txt') | ||
.should('be.visible') | ||
.should('contain.text', 'bar.txt') | ||
}) | ||
|
||
it('See that the name preserved on reload', () => { | ||
cy.reload() | ||
|
||
getRowForFile('bar.txt') | ||
.should('be.visible') | ||
.should('contain.text', 'bar.txt') | ||
}) | ||
}) |