Skip to content

Commit 5777457

Browse files
committed
fix: add pending code after backport
Signed-off-by: Vitor Mattos <[email protected]>
1 parent a94aed6 commit 5777457

1 file changed

Lines changed: 42 additions & 8 deletions

File tree

src/tests/views/FilesList/FilesList.spec.ts

Lines changed: 42 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { useUserConfigStore } from '../../../store/userconfig.js'
1313

1414
vi.mock('@nextcloud/l10n', () => ({
1515
t: vi.fn((_app: string, text: string) => text),
16+
isRTL: vi.fn(() => false),
1617
}))
1718

1819
vi.mock('@nextcloud/logger', () => ({
@@ -114,13 +115,6 @@ vi.mock('../../../views/FilesList/FilesListVirtual.vue', () => ({
114115
},
115116
}))
116117

117-
vi.mock('../../../views/FilesList/FileListFilters.vue', () => ({
118-
default: {
119-
name: 'FileListFilters',
120-
template: '<div class="file-list-filters-stub" />',
121-
},
122-
}))
123-
124118
vi.mock('../../../components/Request/RequestPicker.vue', () => ({
125119
default: {
126120
name: 'RequestPicker',
@@ -158,6 +152,45 @@ describe('FilesList.vue rendering rules', () => {
158152
expect(wrapper.vm.mdiFolder).toBeTruthy()
159153
expect(wrapper.vm.mdiViewGrid).toBeTruthy()
160154
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)
161194
})
162195

163196
it('shows empty-state request action when user can request sign', async () => {
@@ -217,7 +250,8 @@ describe('FilesList.vue rendering rules', () => {
217250
const wrapper = mountComponent()
218251
await flushPromises()
219252

220-
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'))
221255
expect(iconWithPath?.attributes('data-path')).toBe(wrapper.vm.mdiViewList)
222256
})
223257
})

0 commit comments

Comments
 (0)