diff --git a/cypress/snapshots/base/AppNavigationItem.cy.ts/NcAppNavigationItem-primary-on-active-route-menu-active.png b/cypress/snapshots/base/AppNavigationItem.cy.ts/NcAppNavigationItem-primary-on-active-route-menu-active.png new file mode 100644 index 0000000000..72003c00ec Binary files /dev/null and b/cypress/snapshots/base/AppNavigationItem.cy.ts/NcAppNavigationItem-primary-on-active-route-menu-active.png differ diff --git a/cypress/snapshots/base/AppNavigationItem.cy.ts/NcAppNavigationItem-primary-on-active-route.png b/cypress/snapshots/base/AppNavigationItem.cy.ts/NcAppNavigationItem-primary-on-active-route.png new file mode 100644 index 0000000000..1bd24b9e45 Binary files /dev/null and b/cypress/snapshots/base/AppNavigationItem.cy.ts/NcAppNavigationItem-primary-on-active-route.png differ diff --git a/cypress/snapshots/base/AppNavigationItem.cy.ts/NcAppNavigationItem-tertiary-non-active-route.png b/cypress/snapshots/base/AppNavigationItem.cy.ts/NcAppNavigationItem-tertiary-non-active-route.png new file mode 100644 index 0000000000..ead409e17a Binary files /dev/null and b/cypress/snapshots/base/AppNavigationItem.cy.ts/NcAppNavigationItem-tertiary-non-active-route.png differ diff --git a/cypress/support/component.ts b/cypress/support/component.ts index 06fe198022..de577a07f6 100644 --- a/cypress/support/component.ts +++ b/cypress/support/component.ts @@ -13,6 +13,12 @@ // https://on.cypress.io/configuration // *********************************************************** +// setup styles +import '../../styleguide/assets/default.css' +import '../../styleguide/assets/additional.css' +import '../../styleguide/assets/icons.css' + +// cypress commands import './commands' import { mount } from '@cypress/vue2' diff --git a/cypress/visual/AppNavigationItem.cy.ts b/cypress/visual/AppNavigationItem.cy.ts new file mode 100644 index 0000000000..893ac589fb --- /dev/null +++ b/cypress/visual/AppNavigationItem.cy.ts @@ -0,0 +1,45 @@ +import { mount } from 'cypress/vue2' +import Vue, { defineComponent } from 'vue' +import VueRouter from 'vue-router' + +import NcAppNavigationItem from '../../src/components/NcAppNavigationItem/NcAppNavigationItem.vue' + +describe('NcAppNavigationItem', () => { + describe('With router link', () => { + const RouterComponent = defineComponent({ + template: '
', + components: { NcAppNavigationItem }, + }) + + const router = new VueRouter({ + routes: [ + { path: '/' }, + { path: '/foo' }, + ], + }) + + beforeEach(() => { + Vue.use(VueRouter) + + mount(RouterComponent as never, { + extensions: { + plugins: [router], + }, + router, + }) + }) + + it('has tertiary styling on non active route', () => { + cy.contains('.app-navigation-entry', 'Foo').compareSnapshot('NcAppNavigationItem-tertiary-non-active-route') + }) + + it('has primary styling on active route', () => { + cy.contains('.app-navigation-entry', 'Home').compareSnapshot('NcAppNavigationItem-primary-on-active-route') + }) + + it('has primary button styling on active route with editing=true', () => { + cy.contains('.app-navigation-entry', 'Home').find('.app-navigation-entry__actions').click() + cy.get('.app-navigation-entry--editing').compareSnapshot('NcAppNavigationItem-primary-on-active-route-menu-active') + }) + }) +}) diff --git a/package-lock.json b/package-lock.json index a2b8f38644..4fcb5639b6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -88,6 +88,7 @@ "url-loader": "^4.1.1", "vite": "^4.3.9", "vue-eslint-parser": "^9.0.3", + "vue-router": "^3.6.5", "vue-styleguidist": "~4.72.0", "vue-template-compiler": "^2.7.14", "webpack": "^5.88.1", diff --git a/package.json b/package.json index ed27f8632c..118d912d74 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "styleguide:build": "vue-styleguidist build", "cypress": "TZ=UTC cypress run --component", "cypress:gui": "TZ=UTC cypress open --component", - "cypress:update-snapshots": "TZ=UTC cypress run --component --spec \"cypress/visual/**/*.cy.js\" --env type=base --config screenshotsFolder=cypress/snapshots/base" + "cypress:update-snapshots": "TZ=UTC cypress run --component --spec \"cypress/visual/**/*.cy.{t,j}s\" --env type=base --config screenshotsFolder=cypress/snapshots/base" }, "main": "dist/index.cjs", "exports": { @@ -143,6 +143,7 @@ "url-loader": "^4.1.1", "vite": "^4.3.9", "vue-eslint-parser": "^9.0.3", + "vue-router": "^3.6.5", "vue-styleguidist": "~4.72.0", "vue-template-compiler": "^2.7.14", "webpack": "^5.88.1", diff --git a/src/components/NcAppNavigationItem/NcAppNavigationItem.vue b/src/components/NcAppNavigationItem/NcAppNavigationItem.vue index 495cc07411..22b9b11414 100644 --- a/src/components/NcAppNavigationItem/NcAppNavigationItem.vue +++ b/src/components/NcAppNavigationItem/NcAppNavigationItem.vue @@ -291,6 +291,7 @@ Just set the `pinned` prop. @@ -319,6 +320,7 @@ Just set the `pinned` prop. :boundaries-element="actionsBoundariesElement" :placement="menuPlacement" :open="menuOpen" + :type="isActive && to ? 'primary' : null" :force-menu="forceMenu" :default-icon="menuIcon" @update:open="onMenuToggle"> diff --git a/src/components/NcAppNavigationItem/NcInputConfirmCancel.vue b/src/components/NcAppNavigationItem/NcInputConfirmCancel.vue index 7d7baafb4a..5ec98ed1b6 100644 --- a/src/components/NcAppNavigationItem/NcInputConfirmCancel.vue +++ b/src/components/NcAppNavigationItem/NcInputConfirmCancel.vue @@ -48,7 +48,7 @@