@@ -13,6 +13,7 @@ import { useUserConfigStore } from '../../../store/userconfig.js'
1313
1414vi . mock ( '@nextcloud/l10n' , ( ) => ( {
1515 t : vi . fn ( ( _app : string , text : string ) => text ) ,
16+ isRTL : vi . fn ( ( ) => false ) ,
1617} ) )
1718
1819vi . mock ( '@nextcloud/logger' , ( ) => ( {
@@ -74,7 +75,17 @@ vi.mock('@nextcloud/vue/components/NcAppContent', () => ({
7475 default : { name : 'NcAppContent' , template : '<div><slot /></div>' } ,
7576} ) )
7677vi . mock ( '@nextcloud/vue/components/NcBreadcrumb' , ( ) => ( {
77- default : { name : 'NcBreadcrumb' , template : '<div><slot name="icon" /></div>' } ,
78+ default : {
79+ name : 'NcBreadcrumb' ,
80+ template : '<div><slot name="icon" /><slot name="menu-icon" /><slot /></div>' ,
81+ } ,
82+ } ) )
83+ vi . mock ( '@nextcloud/vue/components/NcActionButton' , ( ) => ( {
84+ default : {
85+ name : 'NcActionButton' ,
86+ emits : [ 'click' ] ,
87+ template : '<button class="nc-action-button-stub" @click="$emit(\'click\')"><slot /></button>' ,
88+ } ,
7889} ) )
7990vi . mock ( '@nextcloud/vue/components/NcBreadcrumbs' , ( ) => ( {
8091 default : { name : 'NcBreadcrumbs' , template : '<div><slot /><slot name="actions" /></div>' } ,
@@ -104,13 +115,6 @@ vi.mock('../../../views/FilesList/FilesListVirtual.vue', () => ({
104115 } ,
105116} ) )
106117
107- vi . mock ( '../../../views/FilesList/FileListFilters.vue' , ( ) => ( {
108- default : {
109- name : 'FileListFilters' ,
110- template : '<div class="file-list-filters-stub" />' ,
111- } ,
112- } ) )
113-
114118vi . mock ( '../../../components/Request/RequestPicker.vue' , ( ) => ( {
115119 default : {
116120 name : 'RequestPicker' ,
@@ -148,6 +152,45 @@ describe('FilesList.vue rendering rules', () => {
148152 expect ( wrapper . vm . mdiFolder ) . toBeTruthy ( )
149153 expect ( wrapper . vm . mdiViewGrid ) . toBeTruthy ( )
150154 expect ( wrapper . vm . mdiViewList ) . toBeTruthy ( )
155+ expect ( wrapper . vm . mdiChevronDown ) . toBeTruthy ( )
156+ expect ( wrapper . vm . mdiChevronUp ) . toBeTruthy ( )
157+ expect ( wrapper . vm . mdiReload ) . toBeTruthy ( )
158+ } )
159+
160+ it ( 'initialises isMenuOpen as false' , async ( ) => {
161+ const filesStore = useFilesStore ( )
162+ vi . spyOn ( filesStore , 'getAllFiles' ) . mockResolvedValue ( { } )
163+
164+ const wrapper = mountComponent ( )
165+ await flushPromises ( )
166+
167+ expect ( wrapper . vm . isMenuOpen ) . toBe ( false )
168+ } )
169+
170+ it ( 'renders RequestPicker before the breadcrumbs in the header' , async ( ) => {
171+ const filesStore = useFilesStore ( )
172+ vi . spyOn ( filesStore , 'getAllFiles' ) . mockResolvedValue ( { } )
173+
174+ const wrapper = mountComponent ( )
175+ await flushPromises ( )
176+
177+ const header = wrapper . find ( '.files-list__header' )
178+ const firstChild = header . element . children [ 0 ]
179+ expect ( firstChild . classList . contains ( 'request-picker-stub' ) ) . toBe ( true )
180+ } )
181+
182+ it ( 'calls filesStore.updateAllFiles once more when reload button is clicked' , async ( ) => {
183+ const filesStore = useFilesStore ( )
184+ vi . spyOn ( filesStore , 'getAllFiles' ) . mockResolvedValue ( { } )
185+ const updateSpy = vi . spyOn ( filesStore , 'updateAllFiles' ) . mockResolvedValue ( { } )
186+
187+ const wrapper = mountComponent ( )
188+ await flushPromises ( )
189+
190+ const callsBefore = updateSpy . mock . calls . length
191+ await wrapper . find ( '.nc-action-button-stub' ) . trigger ( 'click' )
192+
193+ expect ( updateSpy . mock . calls . length ) . toBe ( callsBefore + 1 )
151194 } )
152195
153196 it ( 'shows empty-state request action when user can request sign' , async ( ) => {
@@ -193,7 +236,8 @@ describe('FilesList.vue rendering rules', () => {
193236 const wrapper = mountComponent ( )
194237 await flushPromises ( )
195238
196- const iconWithPath = wrapper . findAll ( '.nc-icon' ) . find ( ( node ) => ! ! node . attributes ( 'data-path' ) )
239+ const gridButton = wrapper . find ( '.files-list__header-grid-button' )
240+ const iconWithPath = gridButton . findAll ( '.nc-icon' ) . find ( ( node ) => ! ! node . attributes ( 'data-path' ) )
197241 expect ( iconWithPath ?. attributes ( 'data-path' ) ) . toBe ( wrapper . vm . mdiViewGrid )
198242 } )
199243
@@ -206,7 +250,8 @@ describe('FilesList.vue rendering rules', () => {
206250 const wrapper = mountComponent ( )
207251 await flushPromises ( )
208252
209- const iconWithPath = wrapper . findAll ( '.nc-icon' ) . find ( ( node ) => ! ! node . attributes ( 'data-path' ) )
253+ const gridButton = wrapper . find ( '.files-list__header-grid-button' )
254+ const iconWithPath = gridButton . findAll ( '.nc-icon' ) . find ( ( node ) => ! ! node . attributes ( 'data-path' ) )
210255 expect ( iconWithPath ?. attributes ( 'data-path' ) ) . toBe ( wrapper . vm . mdiViewList )
211256 } )
212257} )
0 commit comments