@@ -74,7 +74,17 @@ vi.mock('@nextcloud/vue/components/NcAppContent', () => ({
7474 default : { name : 'NcAppContent' , template : '<div><slot /></div>' } ,
7575} ) )
7676vi . mock ( '@nextcloud/vue/components/NcBreadcrumb' , ( ) => ( {
77- default : { name : 'NcBreadcrumb' , template : '<div><slot name="icon" /></div>' } ,
77+ default : {
78+ name : 'NcBreadcrumb' ,
79+ template : '<div><slot name="icon" /><slot name="menu-icon" /><slot /></div>' ,
80+ } ,
81+ } ) )
82+ vi . mock ( '@nextcloud/vue/components/NcActionButton' , ( ) => ( {
83+ default : {
84+ name : 'NcActionButton' ,
85+ emits : [ 'click' ] ,
86+ template : '<button class="nc-action-button-stub" @click="$emit(\'click\')"><slot /></button>' ,
87+ } ,
7888} ) )
7989vi . mock ( '@nextcloud/vue/components/NcBreadcrumbs' , ( ) => ( {
8090 default : { name : 'NcBreadcrumbs' , template : '<div><slot /><slot name="actions" /></div>' } ,
@@ -141,6 +151,45 @@ describe('FilesList.vue rendering rules', () => {
141151 expect ( wrapper . vm . mdiFolder ) . toBeTruthy ( )
142152 expect ( wrapper . vm . mdiViewGrid ) . toBeTruthy ( )
143153 expect ( wrapper . vm . mdiViewList ) . toBeTruthy ( )
154+ expect ( wrapper . vm . mdiChevronDown ) . toBeTruthy ( )
155+ expect ( wrapper . vm . mdiChevronUp ) . toBeTruthy ( )
156+ expect ( wrapper . vm . mdiReload ) . toBeTruthy ( )
157+ } )
158+
159+ it ( 'initialises isMenuOpen as false' , async ( ) => {
160+ const filesStore = useFilesStore ( )
161+ vi . spyOn ( filesStore , 'getAllFiles' ) . mockResolvedValue ( { } )
162+
163+ const wrapper = mountComponent ( )
164+ await flushPromises ( )
165+
166+ expect ( wrapper . vm . isMenuOpen ) . toBe ( false )
167+ } )
168+
169+ it ( 'renders RequestPicker before the breadcrumbs in the header' , async ( ) => {
170+ const filesStore = useFilesStore ( )
171+ vi . spyOn ( filesStore , 'getAllFiles' ) . mockResolvedValue ( { } )
172+
173+ const wrapper = mountComponent ( )
174+ await flushPromises ( )
175+
176+ const header = wrapper . find ( '.files-list__header' )
177+ const firstChild = header . element . children [ 0 ]
178+ expect ( firstChild . classList . contains ( 'request-picker-stub' ) ) . toBe ( true )
179+ } )
180+
181+ it ( 'calls filesStore.updateAllFiles once more when reload button is clicked' , async ( ) => {
182+ const filesStore = useFilesStore ( )
183+ vi . spyOn ( filesStore , 'getAllFiles' ) . mockResolvedValue ( { } )
184+ const updateSpy = vi . spyOn ( filesStore , 'updateAllFiles' ) . mockResolvedValue ( { } )
185+
186+ const wrapper = mountComponent ( )
187+ await flushPromises ( )
188+
189+ const callsBefore = updateSpy . mock . calls . length
190+ await wrapper . find ( '.nc-action-button-stub' ) . trigger ( 'click' )
191+
192+ expect ( updateSpy . mock . calls . length ) . toBe ( callsBefore + 1 )
144193 } )
145194
146195 it ( 'shows empty-state request action when user can request sign' , async ( ) => {
@@ -186,7 +235,8 @@ describe('FilesList.vue rendering rules', () => {
186235 const wrapper = mountComponent ( )
187236 await flushPromises ( )
188237
189- const iconWithPath = wrapper . findAll ( '.nc-icon' ) . find ( ( node ) => ! ! node . attributes ( 'data-path' ) )
238+ const gridButton = wrapper . find ( '.files-list__header-grid-button' )
239+ const iconWithPath = gridButton . findAll ( '.nc-icon' ) . find ( ( node ) => ! ! node . attributes ( 'data-path' ) )
190240 expect ( iconWithPath ?. attributes ( 'data-path' ) ) . toBe ( wrapper . vm . mdiViewGrid )
191241 } )
192242
@@ -199,7 +249,8 @@ describe('FilesList.vue rendering rules', () => {
199249 const wrapper = mountComponent ( )
200250 await flushPromises ( )
201251
202- const iconWithPath = wrapper . findAll ( '.nc-icon' ) . find ( ( node ) => ! ! node . attributes ( 'data-path' ) )
252+ const gridButton = wrapper . find ( '.files-list__header-grid-button' )
253+ const iconWithPath = gridButton . findAll ( '.nc-icon' ) . find ( ( node ) => ! ! node . attributes ( 'data-path' ) )
203254 expect ( iconWithPath ?. attributes ( 'data-path' ) ) . toBe ( wrapper . vm . mdiViewList )
204255 } )
205256} )
0 commit comments