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
236import type { User } from '@nextcloud/cypress'
247import { getRowForFile , navigateToFolder , triggerActionForFile } from './FilesUtils'
8+ import { assertNotExistOrNotVisible } from '../settings/usersUtils'
259
2610describe ( '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 } ` )
0 commit comments