),
+ can_manage_group_policies: canManageGroupPolicies,
+ }
+ }
+ if (key === 'can_request_sign') {
+ return canRequestSign
+ }
+ return defaults
+ })
+
+ return mount(Settings, {
+ global: {
+ stubs: {
+ NcAppNavigationItem: {
+ name: 'NcAppNavigationItem',
+ props: ['name', 'to', 'href', 'icon'],
+ template: '{{ name }}',
+ },
+ AccountIcon: { template: '' },
+ StarIcon: { template: '' },
+ TuneIcon: { template: '' },
+ },
+ mocks: {
+ t,
+ },
+ },
+ }) as unknown as SettingsWrapper
+ }
+
+ beforeEach(() => {
+ if (wrapper) {
+ wrapper.unmount()
+ wrapper = null
+ }
+ vi.clearAllMocks()
+ mockPolicies.value = {}
+ loadStateMock.mockImplementation((app, key, defaults) => defaults)
+ })
+
+ describe('RULE: Account navigation item always displays', () => {
+ it('shows Account item for non-admin user', () => {
+ wrapper = createWrapper(false)
+ const items = getItems()
+ const accountItem = expectItem(findItemByName(items, 'Account'))
+
+ expect(accountItem.props('to')).toEqual({ name: 'Account' })
+
+ expect(accountItem).toBeTruthy()
+ })
+
+ it('shows Account item for admin user', () => {
+ wrapper = createWrapper(true)
+ const items = getItems()
+ const accountItem = expectItem(findItemByName(items, 'Account'))
+
+ expect(accountItem).toBeTruthy()
+ })
+
+ it('Account item links to Account route', () => {
+ wrapper = createWrapper()
+ const items = getItems()
+ const accountItem = expectItem(findItemByName(items, 'Account'))
+
+ expect(accountItem.props('to')).toEqual({ name: 'Account' })
+ })
+
+ it('Account item has user icon', () => {
+ wrapper = createWrapper()
+ const accountIcon = getWrapper().find('.account-icon')
+
+ expect(accountIcon.exists()).toBe(true)
+ })
+ })
+
+ describe('RULE: Administration item shows only for admin users', () => {
+ it('hides Administration for non-admin users', () => {
+ wrapper = createWrapper(false)
+ const items = getItems()
+ const adminItem = findItemByName(items, 'Administration')
+
+ expect(adminItem).toBeUndefined()
+ })
+
+ it('shows Administration for admin users', () => {
+ wrapper = createWrapper(true)
+ const items = getItems()
+ const adminItem = expectItem(findItemByName(items, 'Administration'))
+
+ expect(adminItem).toBeTruthy()
+ })
+
+ it('Administration item has tune icon', () => {
+ wrapper = createWrapper(true)
+ const tuneIcon = getWrapper().find('.tune-icon')
+
+ expect(tuneIcon.exists()).toBe(true)
+ })
+
+ it('Administration href points to admin settings', () => {
+ wrapper = createWrapper(true)
+ const items = getItems()
+ const adminItem = expectItem(findItemByName(items, 'Administration'))
+
+ expect(adminItem.props('href')).toContain('settings/admin/libresign')
+ })
+ })
+
+ describe('RULE: getAdminRoute generates correct URL', () => {
+ it('generates admin route with generateUrl', () => {
+ wrapper = createWrapper(true)
+ const route = getWrapper().vm.getAdminRoute()
+
+ expect(route).toContain('settings/admin/libresign')
+ })
+
+ it('returns formatted admin settings URL', () => {
+ wrapper = createWrapper(true)
+ const route = getWrapper().vm.getAdminRoute()
+
+ expect(route).toBe('/admin/settings/admin/libresign')
+ })
+ })
+
+ describe('RULE: Rate LibreSign item always displays', () => {
+ it('shows Rate item for non-admin', () => {
+ wrapper = createWrapper(false)
+ const items = getItems()
+ const rateItem = expectItem(findItemByName(items, 'Rate'))
+
+ expect(rateItem).toBeTruthy()
+ })
+ it('shows Rate item for admin', () => {
+ wrapper = createWrapper(true)
+ const items = getItems()
+ const rateItem = expectItem(findItemByName(items, 'Rate'))
+
+ expect(rateItem).toBeTruthy()
+ })
+
+ it('Rate item has star icon', () => {
+ wrapper = createWrapper()
+ const starIcon = getWrapper().find('.star-icon')
+ expect(starIcon.exists()).toBe(true)
+ })
+
+ it('Rate item links to apps marketplace', () => {
+ wrapper = createWrapper()
+ const items = getItems()
+ const rateItem = expectItem(findItemByName(items, 'Rate'))
+
+ expect(rateItem.props('href')).toContain('apps.nextcloud.com')
+ })
+
+ it('Rate item URL includes comments section', () => {
+ wrapper = createWrapper()
+ const items = getItems()
+ const rateItem = expectItem(findItemByName(items, 'Rate'))
+
+ expect(rateItem.props('href')).toContain('comments')
+ })
+
+ it('Rate item displays with heart emoji', () => {
+ wrapper = createWrapper()
+ const items = getItems()
+ const rateItem = expectItem(findItemByName(items, 'Rate'))
+
+ expect(rateItem.props('name')).toContain('❤️')
+ })
+ })
+
+ describe('RULE: isAdmin data property reflects user role', () => {
+ it('isAdmin false for non-admin user', () => {
+ wrapper = createWrapper(false)
+
+ expect(getWrapper().vm.isAdmin).toBe(false)
+ })
+
+ it('isAdmin true for admin user', () => {
+ wrapper = createWrapper(true)
+
+ expect(getWrapper().vm.isAdmin).toBe(true)
+ })
+ })
+
+ describe('RULE: unauthenticated users (signing via email link) do not crash the component', () => {
+ const createUnauthenticatedWrapper = (): SettingsWrapper => {
+ getCurrentUserMock.mockReturnValue(null)
+
+ return mount(Settings, {
+ global: {
+ stubs: {
+ NcAppNavigationItem: {
+ name: 'NcAppNavigationItem',
+ props: ['name', 'to', 'href', 'icon'],
+ template: '{{ name }}',
+ },
+ AccountIcon: { template: '' },
+ StarIcon: { template: '' },
+ TuneIcon: { template: '' },
+ },
+ mocks: { t },
+ },
+ }) as unknown as SettingsWrapper
+ }
+
+ it('mounts without throwing when getCurrentUser returns null', () => {
+ expect(() => createUnauthenticatedWrapper()).not.toThrow()
+ })
+
+ it('isAdmin is false when getCurrentUser returns null', () => {
+ wrapper = createUnauthenticatedWrapper()
+
+ expect(getWrapper().vm.isAdmin).toBe(false)
+ })
+
+ it('hides the Administration link when user is unauthenticated', () => {
+ wrapper = createUnauthenticatedWrapper()
+ const items = getItems()
+ const adminItem = findItemByName(items, 'Administration')
+
+ expect(adminItem).toBeUndefined()
+ })
+
+ it('shows expected navigation items for unauthenticated user', () => {
+ wrapper = createUnauthenticatedWrapper()
+ const items = getItems()
+
+ expectItem(findItemByName(items, 'Account'))
+ expectItem(findItemByName(items, 'My certificates'))
+ expectItem(findItemByName(items, 'Rate'))
+ })
+ })
+
+ describe('RULE: navigation items for different roles', () => {
+ it('shows expected navigation items for non-admin user', () => {
+ wrapper = createWrapper(false)
+ const items = getItems()
+
+ expectItem(findItemByName(items, 'Account'))
+ expectItem(findItemByName(items, 'Preferences'))
+ expectItem(findItemByName(items, 'My certificates'))
+ expectItem(findItemByName(items, 'Rate'))
+ })
+
+ it('shows expected navigation items for admin user', () => {
+ wrapper = createWrapper(true)
+ const items = getItems()
+
+ expectItem(findItemByName(items, 'Account'))
+ expectItem(findItemByName(items, 'Preferences'))
+ expectItem(findItemByName(items, 'Policies'))
+ expectItem(findItemByName(items, 'Administration'))
+ expectItem(findItemByName(items, 'My certificates'))
+ expectItem(findItemByName(items, 'Rate'))
+ })
+ })
+
+ describe('RULE: Preferences item follows personal preference capability', () => {
+ it('shows Preferences for non-admin users', () => {
+ wrapper = createWrapper(false)
+ const items = getItems()
+ const preferencesItem = expectItem(findItemByName(items, 'Preferences'))
+
+ expect(preferencesItem.props('to')).toEqual({ name: 'Preferences' })
+ })
+
+ it('shows Preferences for admin users', () => {
+ wrapper = createWrapper(true)
+ const items = getItems()
+ const preferencesItem = expectItem(findItemByName(items, 'Preferences'))
+
+ expect(preferencesItem).toBeTruthy()
+ })
+
+ it('renders the preferences icon', () => {
+ wrapper = createWrapper(false)
+
+ expect(getWrapper().find('.preferences-icon').exists()).toBe(true)
+ })
+
+ it('hides Preferences when no policy allows saving personal preferences', () => {
+ wrapper = createWrapper(false, false, true, {
+ signature_flow: {
+ canSaveAsUserDefault: false,
+ meta: { supportsUserPreference: true },
+ },
+ })
+ const items = getItems()
+
+ expect(findItemByName(items, 'Preferences')).toBeUndefined()
+ })
+
+ it('shows Preferences when add_footer allows saving personal preferences', () => {
+ wrapper = createWrapper(false, false, true, {
+ signature_flow: {
+ canSaveAsUserDefault: false,
+ meta: { supportsUserPreference: true },
+ },
+ add_footer: {
+ canSaveAsUserDefault: true,
+ meta: { supportsUserPreference: true },
+ },
+ })
+ const items = getItems()
+ const preferencesItem = expectItem(findItemByName(items, 'Preferences'))
+
+ expect(preferencesItem.props('to')).toEqual({ name: 'Preferences' })
+ })
+
+ it('hides Preferences when only unsupported policies report personal customization', () => {
+ wrapper = createWrapper(false, false, true, {
+ approval_group: {
+ canSaveAsUserDefault: true,
+ sourceScope: 'system',
+ },
+ })
+ const items = getItems()
+
+ expect(findItemByName(items, 'Preferences')).toBeUndefined()
+ })
+
+ it('shows Preferences when a saved user preference exists even if new saves are blocked', () => {
+ wrapper = createWrapper(false, false, true, {
+ signature_flow: {
+ canSaveAsUserDefault: false,
+ sourceScope: 'user',
+ meta: { supportsUserPreference: true },
+ },
+ })
+ const items = getItems()
+ const preferencesItem = expectItem(findItemByName(items, 'Preferences'))
+
+ expect(preferencesItem.props('to')).toEqual({ name: 'Preferences' })
+ })
+
+ it('hides Preferences when only TSA is assigned at user scope by an administrator', () => {
+ wrapper = createWrapper(false, false, true, {
+ tsa_settings: {
+ canSaveAsUserDefault: false,
+ sourceScope: 'user',
+ meta: {
+ supportsUserPreference: false,
+ },
+ },
+ })
+ const items = getItems()
+
+ expect(findItemByName(items, 'Preferences')).toBeUndefined()
+ })
+
+ it('hides Preferences when only external CRL validation is assigned at user scope by an administrator', () => {
+ wrapper = createWrapper(false, false, true, {
+ crl_external_validation_enabled: {
+ canSaveAsUserDefault: false,
+ sourceScope: 'user',
+ meta: {
+ supportsUserPreference: false,
+ },
+ },
+ })
+ const items = getItems()
+
+ expect(findItemByName(items, 'Preferences')).toBeUndefined()
+ })
+
+ it('hides Preferences when only request expiration is assigned at user scope by an administrator', () => {
+ wrapper = createWrapper(false, false, true, {
+ maximum_validity: {
+ canSaveAsUserDefault: false,
+ sourceScope: 'user',
+ meta: {
+ supportsUserPreference: false,
+ },
+ },
+ renewal_interval: {
+ canSaveAsUserDefault: false,
+ sourceScope: 'user',
+ meta: {
+ supportsUserPreference: false,
+ },
+ },
+ })
+ const items = getItems()
+
+ expect(findItemByName(items, 'Preferences')).toBeUndefined()
+ })
+
+ it('updates Preferences visibility after policy state changes', async () => {
+ wrapper = createWrapper(false, false, true, {
+ signature_flow: {
+ canSaveAsUserDefault: false,
+ meta: { supportsUserPreference: true },
+ },
+ })
+ expect(findItemByName(getItems(), 'Preferences')).toBeUndefined()
+
+ mockPolicies.value = {
+ signature_flow: {
+ canSaveAsUserDefault: true,
+ meta: { supportsUserPreference: true },
+ },
+ }
+ await nextTick()
+
+ const preferencesItem = expectItem(findItemByName(getItems(), 'Preferences'))
+ expect(preferencesItem.props('to')).toEqual({ name: 'Preferences' })
+ })
+
+ it('shows Preferences when personal defaults are allowed even if user cannot create signature requests', () => {
+ wrapper = createWrapper(false, false, false, {
+ signature_flow: {
+ canSaveAsUserDefault: true,
+ meta: { supportsUserPreference: true },
+ },
+ })
+ const items = getItems()
+ const preferencesItem = expectItem(findItemByName(items, 'Preferences'))
+
+ expect(preferencesItem.props('to')).toEqual({ name: 'Preferences' })
+ })
+
+ it('hides Preferences when the merged signature stamp preference is blocked by its companion policy', () => {
+ wrapper = createWrapper(false, false, true, {
+ signature_stamp: {
+ canSaveAsUserDefault: true,
+ sourceScope: 'group',
+ meta: { supportsUserPreference: true },
+ },
+ collect_metadata: {
+ canSaveAsUserDefault: false,
+ sourceScope: 'group',
+ meta: { supportsUserPreference: true },
+ },
+ })
+ const items = getItems()
+
+ expect(findItemByName(items, 'Preferences')).toBeUndefined()
+ })
+ })
+
+ describe('RULE: Policies item follows policy-management capability in the app menu', () => {
+ it('hides Policies for non-admin users', () => {
+ wrapper = createWrapper(false)
+ const items = getItems()
+
+ expect(findItemByName(items, 'Policies')).toBeUndefined()
+ })
+
+ it('shows Policies for admin users', () => {
+ wrapper = createWrapper(true)
+ const items = getItems()
+ const policiesItem = expectItem(findItemByName(items, 'Policies'))
+
+ expect(policiesItem.props('to')).toEqual({ name: 'Policies' })
+ })
+
+ it('hides Policies for non-admin users with group policy capability but no editable policies', () => {
+ wrapper = createWrapper(false, true, true, {
+ signature_flow: {
+ editableByCurrentActor: false,
+ meta: { supportsUserPreference: true },
+ },
+ })
+ const items = getItems()
+
+ expect(findItemByName(items, 'Policies')).toBeUndefined()
+ })
+
+ it('shows Policies for non-admin users with group policy capability and editable policy even without delegated rules', () => {
+ wrapper = createWrapper(false, true, true, {
+ groups_request_sign: {
+ groupCount: 0,
+ userCount: 0,
+ editableByCurrentActor: false,
+ },
+ show_confetti_after_signing: {
+ editableByCurrentActor: true,
+ },
+ })
+ const items = getItems()
+ const policiesItem = expectItem(findItemByName(items, 'Policies'))
+
+ expect(policiesItem.props('to')).toEqual({ name: 'Policies' })
+ })
+
+ it('shows Policies for non-admin group admins when external CRL validation only allows descendant admin rules', () => {
+ wrapper = createWrapper(false, true, true, {
+ crl_external_validation_enabled: {
+ editableByCurrentActor: false,
+ canSaveAsUserDefault: false,
+ meta: {
+ canCreateDescendantRules: true,
+ supportsUserPreference: false,
+ },
+ },
+ })
+ const items = getItems()
+ const policiesItem = expectItem(findItemByName(items, 'Policies'))
+
+ expect(policiesItem.props('to')).toEqual({ name: 'Policies' })
+ })
+
+ it('shows Policies for non-admin group admins when only lower-level customization is available', () => {
+ wrapper = createWrapper(false, true, true, {
+ show_confetti_after_signing: {
+ editableByCurrentActor: false,
+ canSaveAsUserDefault: true,
+ },
+ })
+ const items = getItems()
+ const policiesItem = expectItem(findItemByName(items, 'Policies'))
+
+ expect(policiesItem.props('to')).toEqual({ name: 'Policies' })
+ })
+
+ it('hides Policies when only unsupported editable policies exist', () => {
+ wrapper = createWrapper(false, true, true, {
+ approval_group: {
+ editableByCurrentActor: true,
+ },
+ })
+ const items = getItems()
+
+ expect(findItemByName(items, 'Policies')).toBeUndefined()
+ })
+
+ it('shows Policies for non-admin users with group policy capability and delegated policies', () => {
+ wrapper = createWrapper(false, true, true, {
+ groups_request_sign: {
+ groupCount: 1,
+ userCount: 0,
+ editableByCurrentActor: true,
+ },
+ })
+ const items = getItems()
+ const policiesItem = expectItem(findItemByName(items, 'Policies'))
+
+ expect(policiesItem.props('to')).toEqual({ name: 'Policies' })
+ })
+
+ it('hides Policies for non-admin users with delegated rules that are not editable', () => {
+ wrapper = createWrapper(false, true, true, {
+ groups_request_sign: {
+ groupCount: 1,
+ userCount: 0,
+ editableByCurrentActor: false,
+ },
+ })
+ const items = getItems()
+
+ expect(findItemByName(items, 'Policies')).toBeUndefined()
+ })
+
+ it('hides Policies for non-admin users when only system-level policies exist', () => {
+ wrapper = createWrapper(false, true, true, {
+ docmdp: {
+ groupCount: 0,
+ userCount: 0,
+ },
+ })
+ const items = getItems()
+
+ expect(findItemByName(items, 'Policies')).toBeUndefined()
+ })
+
+ it('updates Policies visibility after the policies store receives delegated counts', async () => {
+ wrapper = createWrapper(false, true, true, {
+ signature_flow: {
+ editableByCurrentActor: false,
+ canSaveAsUserDefault: false,
+ meta: { supportsUserPreference: true },
+ },
+ })
+ expect(findItemByName(getItems(), 'Policies')).toBeUndefined()
+
+ mockPolicies.value = {
+ groups_request_sign: {
+ groupCount: 1,
+ userCount: 0,
+ editableByCurrentActor: true,
+ },
+ }
+ await nextTick()
+
+ const policiesItem = expectItem(findItemByName(getItems(), 'Policies'))
+ expect(policiesItem.props('to')).toEqual({ name: 'Policies' })
+ })
+
+ it('renders the policies icon for admin users', () => {
+ wrapper = createWrapper(true)
+
+ expect(getWrapper().find('.policies-icon').exists()).toBe(true)
+ })
+ })
+
+ describe('RULE: each navigation item has name and icon', () => {
+ it('Account item has all properties', () => {
+ wrapper = createWrapper()
+ const items = getItems()
+ const accountItem = expectItem(findItemByName(items, 'Account'))
+
+ expect(accountItem.props('name')).toBeTruthy()
+ })
+
+ it('Rate item has all properties', () => {
+ wrapper = createWrapper()
+ const items = getItems()
+ const rateItem = expectItem(findItemByName(items, 'Rate'))
+
+ expect(rateItem.props('name')).toBeTruthy()
+ expect(rateItem.props('href')).toBeTruthy()
+ })
+
+ it('Admin item has all properties when present', () => {
+ wrapper = createWrapper(true)
+ const items = getItems()
+ const adminItem = expectItem(findItemByName(items, 'Administration'))
+
+ expect(adminItem.props('name')).toBeTruthy()
+ expect(adminItem.props('href')).toBeTruthy()
+ })
+
+ it('does not use fallback icon prop when custom icon slot is present', () => {
+ wrapper = createWrapper(true)
+ const items = getItems()
+ const preferencesItem = expectItem(findItemByName(items, 'Preferences'))
+ const policiesItem = expectItem(findItemByName(items, 'Policies'))
+ const adminItem = expectItem(findItemByName(items, 'Administration'))
+
+ expect(preferencesItem.props('icon')).toBeUndefined()
+ expect(policiesItem.props('icon')).toBeUndefined()
+ expect(adminItem.props('icon')).toBeUndefined()
+ })
+ })
+
+ describe('RULE: icons render correctly', () => {
+ it('renders all required icons for admin', () => {
+ wrapper = createWrapper(true)
+
+ expect(getWrapper().find('.account-icon').exists()).toBe(true)
+ expect(getWrapper().find('.tune-icon').exists()).toBe(true)
+ expect(getWrapper().find('.star-icon').exists()).toBe(true)
+ expect(getWrapper().find('.certificate-icon').exists()).toBe(true)
+ })
+
+ it('renders Account and Rate icons for non-admin', () => {
+ wrapper = createWrapper(false)
+
+ expect(getWrapper().find('.account-icon').exists()).toBe(true)
+ expect(getWrapper().find('.star-icon').exists()).toBe(true)
+ expect(getWrapper().find('.certificate-icon').exists()).toBe(true)
+ })
+
+ it('does not render admin icon for non-admin', () => {
+ wrapper = createWrapper(false)
+
+ expect(getWrapper().find('.tune-icon').exists()).toBe(false)
+ })
+ })
+
+ describe('RULE: navigation items render in correct order', () => {
+ it('renders Account first for non-admin', () => {
+ wrapper = createWrapper(false)
+ const items = getItems()
+ const firstItem = expectItemAt(items, 0)
+
+ expect(firstItem.props('name')).toContain('Account')
+ })
+
+ it('renders Account first for admin', () => {
+ wrapper = createWrapper(true)
+ const items = getItems()
+ const firstItem = expectItemAt(items, 0)
+
+ expect(firstItem.props('name')).toContain('Account')
+ })
+
+ it('renders Preferences second for admin', () => {
+ wrapper = createWrapper(true)
+ const items = getItems()
+ const secondItem = expectItemAt(items, 1)
+
+ expect(secondItem.props('name')).toContain('Preferences')
+ })
+
+ it('renders Policies before Administration for admin users', () => {
+ wrapper = createWrapper(true)
+ const items = getItems()
+ const thirdItem = expectItemAt(items, 2)
+ const fourthItem = expectItemAt(items, 3)
+
+ expect(thirdItem.props('name')).toContain('Policies')
+ expect(fourthItem.props('name')).toContain('Administration')
+ })
+
+ it('renders Rate last', () => {
+ wrapper = createWrapper(true)
+ const items = getItems()
+ const lastItem = expectItemAt(items, items.length - 1)
+
+ expect(lastItem.props('name')).toContain('Rate')
+ })
+ })
+
+ describe('RULE: component wraps items in unordered list', () => {
+ it('contains ul element', () => {
+ wrapper = createWrapper()
+ const ul = getWrapper().find('ul')
+ expect(ul.exists()).toBe(true)
+ })
+
+ it('navigation items are rendered as children of ul', () => {
+ wrapper = createWrapper()
+ const ul = getWrapper().find('ul')
+ const items = ul.findAllComponents({ name: 'NcAppNavigationItem' })
+
+ expect(items.length).toBeGreaterThan(0)
+ })
+ })
+
+ describe('RULE: complete workflow for different user roles', () => {
+ it('provides different experience for regular user', () => {
+ wrapper = createWrapper(false)
+ const items = getItems()
+
+ const hasAccount = items.some(i => i.props('name')?.includes('Account'))
+ const hasPreferences = items.some(i => i.props('name')?.includes('Preferences'))
+ const hasRate = items.some(i => i.props('name')?.includes('Rate'))
+ const hasAdmin = items.some(i => i.props('name')?.includes('Administration'))
+
+ expect(hasAccount).toBe(true)
+ expect(hasPreferences).toBe(true)
+ expect(hasRate).toBe(true)
+ expect(hasAdmin).toBe(false)
+ })
+
+ it('provides full experience for admin user', () => {
+ wrapper = createWrapper(true)
+ const items = getItems()
+
+ const hasAccount = items.some(i => i.props('name')?.includes('Account'))
+ const hasPreferences = items.some(i => i.props('name')?.includes('Preferences'))
+ const hasPolicies = items.some(i => i.props('name')?.includes('Policies'))
+ const hasRate = items.some(i => i.props('name')?.includes('Rate'))
+ const hasAdmin = items.some(i => i.props('name')?.includes('Administration'))
+
+ expect(hasAccount).toBe(true)
+ expect(hasPreferences).toBe(true)
+ expect(hasPolicies).toBe(true)
+ expect(hasRate).toBe(true)
+ expect(hasAdmin).toBe(true)
+ })
+
+ it('hides policies entry for group manager without editable policies', () => {
+ wrapper = createWrapper(false, true, true, {
+ signature_flow: {
+ editableByCurrentActor: false,
+ canSaveAsUserDefault: false,
+ meta: { supportsUserPreference: true },
+ },
+ })
+ const items = getItems()
+
+ const hasAccount = items.some(i => i.props('name')?.includes('Account'))
+ const hasPreferences = items.some(i => i.props('name')?.includes('Preferences'))
+ const hasPolicies = items.some(i => i.props('name')?.includes('Policies'))
+ const hasRate = items.some(i => i.props('name')?.includes('Rate'))
+ const hasAdmin = items.some(i => i.props('name')?.includes('Administration'))
+ const hasMyCertificates = items.some(i => i.props('name')?.includes('My certificates'))
+
+ expect(hasAccount).toBe(true)
+ expect(hasPreferences).toBe(false)
+ expect(hasPolicies).toBe(false)
+ expect(hasRate).toBe(true)
+ expect(hasAdmin).toBe(false)
+ expect(hasMyCertificates).toBe(true)
+ })
+
+ it('hides preferences entry when the user cannot change anything personally', () => {
+ wrapper = createWrapper(false, false, true, {
+ signature_flow: {
+ canSaveAsUserDefault: false,
+ meta: { supportsUserPreference: true },
+ },
+ })
+ const items = getItems()
+
+ const hasPreferences = items.some(i => i.props('name')?.includes('Preferences'))
+ const hasPolicies = items.some(i => i.props('name')?.includes('Policies'))
+
+ expect(hasPreferences).toBe(false)
+ expect(hasPolicies).toBe(false)
+ })
+
+ it('shows policies entry for group manager with editable policies', () => {
+ wrapper = createWrapper(false, true, true, {
+ groups_request_sign: {
+ canSaveAsUserDefault: false,
+ editableByCurrentActor: true,
+ groupCount: 1,
+ userCount: 0,
+ meta: { supportsUserPreference: false },
+ },
+ })
+ const items = getItems()
+
+ const hasPolicies = items.some(i => i.props('name')?.includes('Policies'))
+ const hasAdmin = items.some(i => i.props('name')?.includes('Administration'))
+
+ expect(hasPolicies).toBe(true)
+ expect(hasAdmin).toBe(false)
+ })
+ })
+
+ describe('RULE: Policies menu visibility for editable policies', () => {
+ it('shows Policies menu for instance admin', () => {
+ wrapper = createWrapper(true, false, false, {})
+ const items = getItems()
+
+ const hasPolicies = items.some(i => i.props('name')?.includes('Policies'))
+ expect(hasPolicies).toBe(true)
+ })
+
+ it('shows Policies menu for group admin when any manageable workbench policy exists', () => {
+ wrapper = createWrapper(false, true, true, {
+ show_confetti_after_signing: {
+ canSaveAsUserDefault: true,
+ editableByCurrentActor: true,
+ },
+ })
+
+ expect(getWrapper().vm.canManagePolicies).toBe(true)
+ })
+
+ it('hides Policies menu for regular user without editable policies', () => {
+ wrapper = createWrapper(false, false, true, {
+ add_footer: {
+ editableByCurrentActor: false,
+ canSaveAsUserDefault: true,
+ meta: { supportsUserPreference: true },
+ },
+ })
+
+ expect(getWrapper().vm.canManagePolicies).toBe(false)
+ })
+
+ it('canManagePolicies respects instance admin status', () => {
+ wrapper = createWrapper(true)
+
+ expect(getWrapper().vm.isAdmin).toBe(true)
+ expect(getWrapper().vm.canManagePolicies).toBe(true)
+ })
+
+ it('canManagePolicies true when group admin has editable policies', () => {
+ wrapper = createWrapper(false, true, true, {
+ groups_request_sign: {
+ editableByCurrentActor: true,
+ groupCount: 1,
+ },
+ })
+
+ expect(getWrapper().vm.canManagePolicies).toBe(true)
+ })
+
+ it('canManagePolicies false when not admin and no editable policies', () => {
+ wrapper = createWrapper(false, false, true, {
+ groups_request_sign: {
+ editableByCurrentActor: false,
+ canSaveAsUserDefault: true,
+ },
+ })
+
+ expect(getWrapper().vm.canManagePolicies).toBe(false)
+ })
+ })
+
+ describe('RULE: Account item icon configuration', () => {
+ it('Account item has icon prop', () => {
+ wrapper = createWrapper()
+ const items = getItems()
+ const accountItem = expectItem(findItemByName(items, 'Account'))
+
+ expect(accountItem.props('icon')).toBe('icon-user')
+ })
+ })
+})
diff --git a/src/tests/views/Account/Account.spec.ts b/src/tests/views/Account/Account.spec.ts
index 37aec4cc71..afaa8b72be 100644
--- a/src/tests/views/Account/Account.spec.ts
+++ b/src/tests/views/Account/Account.spec.ts
@@ -1,76 +1,70 @@
-/**
- * SPDX-FileCopyrightText: 2026 LibreCode coop and contributors
- * SPDX-License-Identifier: AGPL-3.0-or-later
- */
-
-import { describe, expect, it, vi } from 'vitest'
-import { mount } from '@vue/test-utils'
-
-import Account from '../../../views/Account/Account.vue'
-
-vi.mock('@nextcloud/vue/components/NcAppContent', () => ({
- default: { name: 'NcAppContent', template: '
' },
-}))
-
-vi.mock('@nextcloud/l10n', () => globalThis.mockNextcloudL10n())
-
-vi.mock('@nextcloud/auth', () => ({
- getCurrentUser: vi.fn(() => ({
- uid: 'ada',
- displayName: 'Ada Lovelace',
- })),
-}))
-
-describe('Account.vue', () => {
- function createWrapper() {
- return mount(Account, {
- global: {
- stubs: {
- UserImage: {
- name: 'UserImage',
- props: ['user'],
- template: '{{ user.displayName }}
',
- },
- ManagePassword: {
- name: 'ManagePassword',
- template: '',
- },
- Signatures: {
- name: 'Signatures',
- template: '',
- },
- Documents: {
- name: 'Documents',
- template: '',
- },
- },
- },
- })
- }
-
- it('renders the current user details and certificate section', () => {
- const wrapper = createWrapper()
-
- expect(wrapper.text()).toContain('Details')
- expect(wrapper.text()).toContain('Certificate')
- expect(wrapper.text()).toContain('Ada Lovelace')
- })
-
- it('passes the current user to UserImage', () => {
- const wrapper = createWrapper()
- const userImage = wrapper.findComponent({ name: 'UserImage' })
-
- expect(userImage.props('user')).toEqual({
- uid: 'ada',
- displayName: 'Ada Lovelace',
- })
- })
-
- it('renders the account partial sections', () => {
- const wrapper = createWrapper()
-
- expect(wrapper.find('.manage-password-stub').exists()).toBe(true)
- expect(wrapper.find('.signatures-stub').exists()).toBe(true)
- expect(wrapper.find('.documents-stub').exists()).toBe(true)
- })
-})
+/**
+ * SPDX-FileCopyrightText: 2026 LibreCode coop and contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+
+import { describe, expect, it, vi } from 'vitest'
+import { mount } from '@vue/test-utils'
+
+import Account from '../../../views/Account/Account.vue'
+
+vi.mock('@nextcloud/vue/components/NcAppContent', () => ({
+ default: { name: 'NcAppContent', template: '
' },
+}))
+
+vi.mock('@nextcloud/l10n', () => globalThis.mockNextcloudL10n())
+
+vi.mock('@nextcloud/auth', () => ({
+ getCurrentUser: vi.fn(() => ({
+ uid: 'ada',
+ displayName: 'Ada Lovelace',
+ })),
+}))
+
+describe('Account.vue', () => {
+ function createWrapper() {
+ return mount(Account, {
+ global: {
+ stubs: {
+ UserImage: {
+ name: 'UserImage',
+ props: ['user'],
+ template: '{{ user.displayName }}
',
+ },
+ Signatures: {
+ name: 'Signatures',
+ template: '',
+ },
+ Documents: {
+ name: 'Documents',
+ template: '',
+ },
+ },
+ },
+ })
+ }
+
+ it('renders the current user details', () => {
+ const wrapper = createWrapper()
+
+ expect(wrapper.text()).toContain('Details')
+ expect(wrapper.text()).toContain('Ada Lovelace')
+ })
+
+ it('passes the current user to UserImage', () => {
+ const wrapper = createWrapper()
+ const userImage = wrapper.findComponent({ name: 'UserImage' })
+
+ expect(userImage.props('user')).toEqual({
+ uid: 'ada',
+ displayName: 'Ada Lovelace',
+ })
+ })
+
+ it('renders the signatures and documents sections', () => {
+ const wrapper = createWrapper()
+
+ expect(wrapper.find('.signatures-stub').exists()).toBe(true)
+ expect(wrapper.find('.documents-stub').exists()).toBe(true)
+ })
+})
diff --git a/src/tests/views/Certificates/MyCertificates.spec.ts b/src/tests/views/Certificates/MyCertificates.spec.ts
new file mode 100644
index 0000000000..860ae6c0db
--- /dev/null
+++ b/src/tests/views/Certificates/MyCertificates.spec.ts
@@ -0,0 +1,33 @@
+/**
+ * SPDX-FileCopyrightText: 2024 LibreCode coop and contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+
+import { describe, expect, it, vi } from 'vitest'
+import { mount } from '@vue/test-utils'
+
+import MyCertificates from '../../../views/Certificates/MyCertificates.vue'
+
+vi.mock('@nextcloud/l10n', () => globalThis.mockNextcloudL10n())
+
+vi.mock('@nextcloud/vue/components/NcAppContent', () => ({
+ default: { name: 'NcAppContent', template: '
' },
+}))
+
+describe('MyCertificates.vue', () => {
+ it('renders my certificates heading and the manage password component', () => {
+ const wrapper = mount(MyCertificates, {
+ global: {
+ stubs: {
+ ManagePassword: {
+ name: 'ManagePassword',
+ template: '',
+ },
+ },
+ },
+ })
+
+ expect(wrapper.text()).toContain('My certificates')
+ expect(wrapper.find('.manage-password-stub').exists()).toBe(true)
+ })
+})
diff --git a/src/views/Account/Account.vue b/src/views/Account/Account.vue
index d38ce63efe..2cf8857bd2 100644
--- a/src/views/Account/Account.vue
+++ b/src/views/Account/Account.vue
@@ -14,10 +14,6 @@
{{ user.displayName }}
-
-
{{ t('libresign', 'Certificate') }}
-
-
@@ -36,7 +32,6 @@ import { getCurrentUser } from '@nextcloud/auth'
import NcAppContent from '@nextcloud/vue/components/NcAppContent'
import Documents from './partials/Documents.vue'
-import ManagePassword from './partials/ManagePassword.vue'
import Signatures from './partials/Signatures.vue'
import UserImage from './partials/UserImage.vue'
@@ -113,11 +108,6 @@ defineExpose({
padding-left: 22px;
}
}
-
- .user-password{
- display: flex;
- flex-direction: column;
- }
}
@media (max-width: 650px) {
diff --git a/src/views/Certificates/MyCertificates.vue b/src/views/Certificates/MyCertificates.vue
new file mode 100644
index 0000000000..c2dbf0a1e4
--- /dev/null
+++ b/src/views/Certificates/MyCertificates.vue
@@ -0,0 +1,31 @@
+
+
+
+ {{ t('libresign', 'My certificates') }}
+
+
+
+
+
+
+
+
+