diff --git a/apps/files/src/components/BreadCrumbs.vue b/apps/files/src/components/BreadCrumbs.vue
index ae26ce8c98c..df7931a4a5b 100644
--- a/apps/files/src/components/BreadCrumbs.vue
+++ b/apps/files/src/components/BreadCrumbs.vue
@@ -52,6 +52,7 @@
diff --git a/apps/files/src/views/Navigation.cy.ts b/apps/files/src/views/Navigation.cy.ts
index 07d9eee80cb..fe7800f32c9 100644
--- a/apps/files/src/views/Navigation.cy.ts
+++ b/apps/files/src/views/Navigation.cy.ts
@@ -1,19 +1,40 @@
-import FolderSvg from '@mdi/svg/svg/folder.svg'
-import ShareSvg from '@mdi/svg/svg/share-variant.svg'
+/**
+ * SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+import type { Navigation } from '@nextcloud/files'
+
import { createTestingPinia } from '@pinia/testing'
+import FolderSvg from '@mdi/svg/svg/folder.svg?raw'
import NavigationView from './Navigation.vue'
-import router from '../router/router'
import { useViewConfigStore } from '../store/viewConfig'
import { Folder, View, getNavigation } from '@nextcloud/files'
import Vue from 'vue'
+import router from '../router/router'
+
+const resetNavigation = () => {
+ const nav = getNavigation()
+ ;[...nav.views].forEach(({ id }) => nav.remove(id))
+ nav.setActive(null)
+}
+
+const createView = (id: string, name: string, parent?: string) => new View({
+ id,
+ name,
+ getContents: async () => ({ folder: {} as Folder, contents: [] }),
+ icon: FolderSvg,
+ order: 1,
+ parent,
+})
describe('Navigation renders', () => {
- delete window._nc_navigation
- const Navigation = getNavigation()
+ let Navigation: Navigation
before(() => {
+ delete window._nc_navigation
+ Navigation = getNavigation()
Vue.prototype.$navigation = Navigation
cy.mockInitialState('files', 'storageStats', {
@@ -40,29 +61,31 @@ describe('Navigation renders', () => {
})
describe('Navigation API', () => {
- delete window._nc_navigation
- const Navigation = getNavigation()
+ let Navigation: Navigation
+
+ before(async () => {
+ delete window._nc_navigation
+ Navigation = getNavigation()
- before(() => {
Vue.prototype.$navigation = Navigation
+ await router.replace({ name: 'filelist', params: { view: 'files' } })
})
+ beforeEach(() => resetNavigation())
+
it('Check API entries rendering', () => {
- Navigation.register(new View({
- id: 'files',
- name: 'Files',
- getContents: async () => ({ folder: {} as Folder, contents: [] }),
- icon: FolderSvg,
- order: 1,
- }))
+ Navigation.register(createView('files', 'Files'))
+ console.warn(Navigation.views)
cy.mount(NavigationView, {
- global: {
- plugins: [createTestingPinia({
- createSpy: cy.spy,
- })],
- },
router,
+ global: {
+ plugins: [
+ createTestingPinia({
+ createSpy: cy.spy,
+ }),
+ ],
+ },
})
cy.get('[data-cy-files-navigation]').should('be.visible')
@@ -72,21 +95,16 @@ describe('Navigation API', () => {
})
it('Adds a new entry and render', () => {
- Navigation.register(new View({
- id: 'sharing',
- name: 'Sharing',
- getContents: async () => ({ folder: {} as Folder, contents: [] }),
- icon: ShareSvg,
- order: 2,
- }))
+ Navigation.register(createView('files', 'Files'))
+ Navigation.register(createView('sharing', 'Sharing'))
cy.mount(NavigationView, {
+ router,
global: {
plugins: [createTestingPinia({
createSpy: cy.spy,
})],
},
- router,
})
cy.get('[data-cy-files-navigation]').should('be.visible')
@@ -96,22 +114,17 @@ describe('Navigation API', () => {
})
it('Adds a new children, render and open menu', () => {
- Navigation.register(new View({
- id: 'sharingin',
- name: 'Shared with me',
- getContents: async () => ({ folder: {} as Folder, contents: [] }),
- parent: 'sharing',
- icon: ShareSvg,
- order: 1,
- }))
+ Navigation.register(createView('files', 'Files'))
+ Navigation.register(createView('sharing', 'Sharing'))
+ Navigation.register(createView('sharingin', 'Shared with me', 'sharing'))
cy.mount(NavigationView, {
+ router,
global: {
plugins: [createTestingPinia({
createSpy: cy.spy,
})],
},
- router,
})
cy.wrap(useViewConfigStore()).as('viewConfigStore')
@@ -139,23 +152,18 @@ describe('Navigation API', () => {
})
it('Throws when adding a duplicate entry', () => {
- expect(() => {
- Navigation.register(new View({
- id: 'files',
- name: 'Files',
- getContents: async () => ({ folder: {} as Folder, contents: [] }),
- icon: FolderSvg,
- order: 1,
- }))
- }).to.throw('View id files is already registered')
+ Navigation.register(createView('files', 'Files'))
+ expect(() => Navigation.register(createView('files', 'Files')))
+ .to.throw('View id files is already registered')
})
})
describe('Quota rendering', () => {
- delete window._nc_navigation
- const Navigation = getNavigation()
+ let Navigation: Navigation
before(() => {
+ delete window._nc_navigation
+ Navigation = getNavigation()
Vue.prototype.$navigation = Navigation
})
diff --git a/apps/files/src/views/Navigation.vue b/apps/files/src/views/Navigation.vue
index 38b6fcb7f49..e71e4ececa1 100644
--- a/apps/files/src/views/Navigation.vue
+++ b/apps/files/src/views/Navigation.vue
@@ -62,7 +62,7 @@
:name="t('files', 'Files settings')"
data-cy-files-navigation-settings-button
@click.prevent.stop="openSettings">
-
+
@@ -75,24 +75,29 @@