Skip to content

Commit 6ec72ce

Browse files
authored
Merge pull request #46973 from nextcloud/backport/46432/stable28
2 parents 1ea1f4f + cefcf07 commit 6ec72ce

14 files changed

Lines changed: 201 additions & 46 deletions

apps/files/src/views/FilesList.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,9 @@ export default defineComponent({
434434
// TODO: preserve selection on browsing?
435435
this.selectionStore.reset()
436436
this.resetSearch()
437+
if (window.OCA.Files.Sidebar?.close) {
438+
window.OCA.Files.Sidebar.close()
439+
}
437440
this.fetchContent()
438441
439442
// Scroll to top, force virtual scroller to re-render

apps/files/src/views/Sidebar.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ import { emit, subscribe, unsubscribe } from '@nextcloud/event-bus'
110110
import { File, Folder, formatFileSize } from '@nextcloud/files'
111111
import { encodePath } from '@nextcloud/paths'
112112
import { generateRemoteUrl, generateUrl } from '@nextcloud/router'
113-
import { Type as ShareTypes } from '@nextcloud/sharing'
113+
import { ShareTypes } from '@nextcloud/sharing'
114114
import { mdiStar, mdiStarOutline } from '@mdi/js'
115115
import axios from '@nextcloud/axios'
116116
import $ from 'jquery'

apps/files_sharing/src/files_sharing_tab.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,16 @@ window.addEventListener('DOMContentLoaded', function() {
7373
await TabInstance.update(fileInfo)
7474
TabInstance.$mount(el)
7575
},
76+
7677
update(fileInfo) {
7778
TabInstance.update(fileInfo)
7879
},
80+
7981
destroy() {
80-
TabInstance.$destroy()
81-
TabInstance = null
82+
if (TabInstance) {
83+
TabInstance.$destroy()
84+
TabInstance = null
85+
}
8286
},
8387
}))
8488
}

cypress.config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ export default defineConfig({
4646
// Disable session isolation
4747
testIsolation: false,
4848

49+
requestTimeout: 30000,
50+
4951
// We've imported your old cypress plugins here.
5052
// You may want to clean this up later by importing these.
5153
async setupNodeEvents(on, config) {

cypress/e2e/files/files-sidebar.cy.ts

Lines changed: 55 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,11 @@
11
/**
2-
* @copyright Copyright (c) 2024 Ferdinand Thiessen <[email protected]>
3-
*
4-
* @author Ferdinand Thiessen <[email protected]>
5-
*
6-
* @license AGPL-3.0-or-later
7-
*
8-
* This program is free software: you can redistribute it and/or modify
9-
* it under the terms of the GNU Affero General Public License as
10-
* published by the Free Software Foundation, either version 3 of the
11-
* License, or (at your option) any later version.
12-
*
13-
* This program is distributed in the hope that it will be useful,
14-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16-
* GNU Affero General Public License for more details.
17-
*
18-
* You should have received a copy of the GNU Affero General Public License
19-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
20-
*
2+
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
3+
* SPDX-License-Identifier: AGPL-3.0-or-later
214
*/
225

236
import type { User } from '@nextcloud/cypress'
247
import { getRowForFile, navigateToFolder, triggerActionForFile } from './FilesUtils'
8+
import { assertNotExistOrNotVisible } from '../settings/usersUtils'
259

2610
describe('Files: Sidebar', { testIsolation: true }, () => {
2711
let user: User
@@ -43,7 +27,10 @@ describe('Files: Sidebar', { testIsolation: true }, () => {
4327

4428
triggerActionForFile('file', 'details')
4529

46-
cy.get('[data-cy-sidebar]').should('be.visible')
30+
cy.get('[data-cy-sidebar]')
31+
.should('be.visible')
32+
.findByRole('heading', { name: 'file' })
33+
.should('be.visible')
4734
})
4835

4936
it('changes the current fileid', () => {
@@ -56,22 +43,63 @@ describe('Files: Sidebar', { testIsolation: true }, () => {
5643
cy.url().should('contain', `apps/files/files/${fileId}`)
5744
})
5845

59-
it('closes the sidebar on delete', () => {
46+
it('changes the sidebar content on other file', () => {
6047
cy.visit('/apps/files')
6148
getRowForFile('file').should('be.visible')
6249

50+
triggerActionForFile('file', 'details')
51+
52+
cy.get('[data-cy-sidebar]')
53+
.should('be.visible')
54+
.findByRole('heading', { name: 'file' })
55+
.should('be.visible')
56+
57+
triggerActionForFile('folder', 'details')
58+
cy.get('[data-cy-sidebar]')
59+
.should('be.visible')
60+
.findByRole('heading', { name: 'folder' })
61+
.should('be.visible')
62+
})
63+
64+
it('closes the sidebar on navigation', () => {
65+
cy.visit('/apps/files')
66+
67+
getRowForFile('file').should('be.visible')
68+
getRowForFile('folder').should('be.visible')
69+
6370
// open the sidebar
6471
triggerActionForFile('file', 'details')
6572
// validate it is open
66-
cy.get('[data-cy-sidebar]').should('be.visible')
67-
// wait for the sidebar to be settled
68-
cy.wait(500)
73+
cy.get('[data-cy-sidebar]')
74+
.should('be.visible')
75+
76+
// if we navigate to the folder
77+
navigateToFolder('folder')
78+
// the sidebar should not be visible anymore
79+
cy.get('[data-cy-sidebar]')
80+
.should(assertNotExistOrNotVisible)
81+
})
6982

83+
it('closes the sidebar on delete', () => {
84+
cy.intercept('DELETE', `**/remote.php/dav/files/${user.userId}/file`).as('deleteFile')
85+
// visit the files app
86+
cy.visit('/apps/files')
87+
getRowForFile('file').should('be.visible')
88+
// open the sidebar
89+
triggerActionForFile('file', 'details')
90+
// validate it is open
91+
cy.get('[data-cy-sidebar]').should('be.visible')
92+
// delete the file
7093
triggerActionForFile('file', 'delete')
71-
cy.get('[data-cy-sidebar]').should('not.exist')
94+
cy.wait('@deleteFile', { timeout: 10000 })
95+
// see the sidebar is closed
96+
cy.get('[data-cy-sidebar]')
97+
.should(assertNotExistOrNotVisible)
7298
})
7399

74100
it('changes the fileid on delete', () => {
101+
cy.intercept('DELETE', `**/remote.php/dav/files/${user.userId}/folder/other`).as('deleteFile')
102+
75103
cy.uploadContent(user, new Blob([]), 'text/plain', '/folder/other').then((response) => {
76104
const otherFileId = Number.parseInt(response.headers['oc-fileid'] ?? '0')
77105
cy.login(user)
@@ -86,10 +114,10 @@ describe('Files: Sidebar', { testIsolation: true }, () => {
86114
// validate it is open
87115
cy.get('[data-cy-sidebar]').should('be.visible')
88116
cy.url().should('contain', `apps/files/files/${otherFileId}`)
89-
// wait for the sidebar to be settled
90-
cy.wait(500)
91117

92118
triggerActionForFile('other', 'delete')
119+
cy.wait('@deleteFile')
120+
93121
cy.get('[data-cy-sidebar]').should('not.exist')
94122
// Ensure the URL is changed
95123
cy.url().should('not.contain', `apps/files/files/${otherFileId}`)

cypress/support/commands.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import { addCommands, User } from '@nextcloud/cypress'
2727
import { basename } from 'path'
2828

2929
// Add custom commands
30+
import '@testing-library/cypress/add-commands'
3031
import 'cypress-if'
3132
import 'cypress-wait-until'
3233
addCommands()

dist/files-main.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/files-main.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/files-sidebar.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/files-sidebar.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)