diff --git a/README.md b/README.md index 50b7b5b..be4df00 100755 --- a/README.md +++ b/README.md @@ -91,31 +91,8 @@ For a complete list of available commands, usage examples, and detailed document ## Troubleshooting -### Cannot access management features - -If you are a Nextcloud administrator but cannot access Forum management features (e.g., managing -categories, roles, or settings), this is likely due to missing database seeds or role assignments. - -**Option 1: Using OCC commands** - -Run the following commands from your Nextcloud installation directory: - -```bash -# Repair database seeds (creates default roles and permissions if missing) -php occ forum:repair-seeds - -# Assign administrator role to an account -php occ forum:set-role admin -``` - -**Option 2: Using the server administration panel** - -1. Log in to Nextcloud as an administrator -2. Go to **Administration Settings** (click your profile picture → Administration Settings) -3. Navigate to **Forum** in the left sidebar under the Administration section -4. Use the **Repair Seeds** button to restore default roles and permissions -5. If the seeds are already in place, use the **Assign Roles** section to assign the administrator - role to accounts +For troubleshooting common issues, visit the +[Troubleshooting Wiki page](https://github.com/chenasraf/nextcloud-forum/wiki/Troubleshooting). ## Contributing diff --git a/src/components/AppNavigation/AppNavigation.test.ts b/src/components/AppNavigation/AppNavigation.test.ts new file mode 100644 index 0000000..0ef166a --- /dev/null +++ b/src/components/AppNavigation/AppNavigation.test.ts @@ -0,0 +1,515 @@ +import { describe, it, expect, vi, beforeEach } from 'vitest' +import { mount, flushPromises } from '@vue/test-utils' +import { + createIconMock, + createComponentMock, + RouterLinkStub, + createNcActionButtonMock, +} from '@/test-utils' +import { ref } from 'vue' + +// --- Composable mocks --- + +const mockFetchCategories = vi.fn().mockResolvedValue([]) +const mockGetAllCategoriesFlat = vi.fn(() => []) +// eslint-disable-next-line @typescript-eslint/no-explicit-any +const mockCategoryHeaders = ref([]) + +vi.mock('@/composables/useCategories', () => ({ + useCategories: () => ({ + categoryHeaders: mockCategoryHeaders, + fetchCategories: mockFetchCategories, + getAllCategoriesFlat: mockGetAllCategoriesFlat, + }), +})) + +const mockUserId = ref(null) +const mockDisplayName = ref('Test User') +const mockFetchCurrentUser = vi.fn().mockResolvedValue(null) + +vi.mock('@/composables/useCurrentUser', () => ({ + useCurrentUser: () => ({ + userId: mockUserId, + displayName: mockDisplayName, + fetchCurrentUser: mockFetchCurrentUser, + }), +})) + +const mockCanAccessAdmin = ref(false) +const mockCanAccessAdminTools = ref(false) +const mockCanManageUsers = ref(false) +const mockCanEditRoles = ref(false) +const mockCanEditCategories = ref(false) +const mockCanEditBbcodes = ref(false) +const mockCanAccessModeration = ref(false) + +vi.mock('@/composables/useUserRole', () => ({ + useUserRole: () => ({ + canAccessAdmin: mockCanAccessAdmin, + canAccessAdminTools: mockCanAccessAdminTools, + canManageUsers: mockCanManageUsers, + canEditRoles: mockCanEditRoles, + canEditCategories: mockCanEditCategories, + canEditBbcodes: mockCanEditBbcodes, + canAccessModeration: mockCanAccessModeration, + }), +})) + +const mockCurrentThreadCategoryId = ref(null) +const mockFetchThread = vi.fn() +const mockClearThread = vi.fn() + +vi.mock('@/composables/useCurrentThread', () => ({ + useCurrentThread: () => ({ + categoryId: mockCurrentThreadCategoryId, + fetchThread: mockFetchThread, + clearThread: mockClearThread, + }), +})) + +const mockIsGuest = ref(false) +const mockGuestDisplayName = ref(null) +const mockFetchGuestIdentity = vi.fn().mockResolvedValue(undefined) + +vi.mock('@/composables/useGuestSession', () => ({ + useGuestSession: () => ({ + isGuest: mockIsGuest, + guestDisplayName: mockGuestDisplayName, + fetchGuestIdentity: mockFetchGuestIdentity, + }), +})) + +// --- Component mocks --- + +vi.mock('@nextcloud/vue/components/NcAppNavigation', () => + createComponentMock('NcAppNavigation', { + template: '
', + }), +) + +vi.mock('@nextcloud/vue/components/NcAppNavigationItem', () => + createComponentMock('NcAppNavigationItem', { + template: + '', + props: ['name', 'to', 'active', 'open'], + }), +) + +vi.mock('@nextcloud/vue/components/NcAppNavigationSearch', () => + createComponentMock('NcAppNavigationSearch', { + template: '