diff --git a/lib/Controller/NotesWallController.php b/lib/Controller/NoteController.php similarity index 97% rename from lib/Controller/NotesWallController.php rename to lib/Controller/NoteController.php index b5a5ed5..8ff8473 100644 --- a/lib/Controller/NotesWallController.php +++ b/lib/Controller/NoteController.php @@ -11,7 +11,7 @@ use OCA\Pantry\Exception\ForbiddenException; use OCA\Pantry\Exception\NotFoundException; use OCA\Pantry\ResponseDefinitions; use OCA\Pantry\Service\HouseAuthService; -use OCA\Pantry\Service\NotesWallService; +use OCA\Pantry\Service\NoteService; use OCA\Pantry\Service\NotificationService; use OCP\AppFramework\Http; use OCP\AppFramework\Http\Attribute\ApiRoute; @@ -25,13 +25,13 @@ use OCP\IUserSession; * @psalm-import-type PantryNote from ResponseDefinitions * @psalm-import-type PantrySuccess from ResponseDefinitions */ -final class NotesWallController extends OCSController { +final class NoteController extends OCSController { use TranslatesDomainExceptions; public function __construct( string $appName, IRequest $request, - private NotesWallService $notes, + private NoteService $notes, private HouseAuthService $auth, private NotificationService $notifications, private IUserSession $userSession, diff --git a/lib/Controller/PhotoWallController.php b/lib/Controller/PhotoController.php similarity index 98% rename from lib/Controller/PhotoWallController.php rename to lib/Controller/PhotoController.php index 4d82f1c..b3f7a3a 100644 --- a/lib/Controller/PhotoWallController.php +++ b/lib/Controller/PhotoController.php @@ -13,7 +13,7 @@ use OCA\Pantry\ResponseDefinitions; use OCA\Pantry\Service\HouseAuthService; use OCA\Pantry\Service\ImageService; use OCA\Pantry\Service\NotificationService; -use OCA\Pantry\Service\PhotoWallService; +use OCA\Pantry\Service\PhotoService; use OCP\AppFramework\Http; use OCP\AppFramework\Http\Attribute\ApiRoute; use OCP\AppFramework\Http\Attribute\NoAdminRequired; @@ -27,13 +27,13 @@ use OCP\IUserSession; * @psalm-import-type PantryPhotoFolder from ResponseDefinitions * @psalm-import-type PantrySuccess from ResponseDefinitions */ -final class PhotoWallController extends OCSController { +final class PhotoController extends OCSController { use TranslatesDomainExceptions; public function __construct( string $appName, IRequest $request, - private PhotoWallService $photos, + private PhotoService $photos, private HouseAuthService $auth, private ImageService $images, private NotificationService $notifications, @@ -223,7 +223,7 @@ final class PhotoWallController extends OCSController { throw new \RuntimeException('Could not read uploaded file'); } $original = (string)($data['name'] ?? 'image.jpg'); - $fileId = $this->images->uploadPhotoWall($uid, $houseId, $original, $bytes); + $fileId = $this->images->uploadPhoto($uid, $houseId, $original, $bytes); $photo = $this->photos->addPhoto($houseId, $uid, $fileId, $folderId, $caption); $this->notifications->notifyPhotoUploaded($houseId, $uid); diff --git a/lib/Service/ImageService.php b/lib/Service/ImageService.php index 7610ed0..55c5b85 100644 --- a/lib/Service/ImageService.php +++ b/lib/Service/ImageService.php @@ -13,7 +13,7 @@ use OCP\Files\NotPermittedException; class ImageService { public const CHECKLIST_ITEMS_SUBDIR = 'Checklist items'; - public const PHOTO_WALL_SUBDIR = 'Photo wall'; + public const PHOTOS_SUBDIR = 'Photo board'; public function __construct( private IRootFolder $rootFolder, @@ -41,13 +41,13 @@ class ImageService { /** * Upload image bytes to the user's configured pantry image folder under the - * "Photo wall" subdirectory, returning the Nextcloud file id on success. + * "Photo board" subdirectory, returning the Nextcloud file id on success. */ - public function uploadPhotoWall(string $uid, int $houseId, string $originalName, string $data): int { + public function uploadPhoto(string $uid, int $houseId, string $originalName, string $data): int { if ($data === '') { throw new \InvalidArgumentException('Empty file'); } - $folder = $this->resolvePhotoWallFolder($uid, $houseId); + $folder = $this->resolvePhotoFolder($uid, $houseId); $filename = $this->uniqueName($folder, $originalName); try { $file = $folder->newFile($filename, $data); @@ -57,9 +57,9 @@ class ImageService { return $file->getId(); } - private function resolvePhotoWallFolder(string $uid, int $houseId): Folder { + private function resolvePhotoFolder(string $uid, int $houseId): Folder { $base = $this->resolveBaseFolder($uid, $houseId); - return $this->getOrCreateSubFolder($base, self::PHOTO_WALL_SUBDIR); + return $this->getOrCreateSubFolder($base, self::PHOTOS_SUBDIR); } private function resolveChecklistItemsFolder(string $uid, int $houseId): Folder { diff --git a/lib/Service/NotesWallService.php b/lib/Service/NoteService.php similarity index 99% rename from lib/Service/NotesWallService.php rename to lib/Service/NoteService.php index b187d82..c0ce132 100644 --- a/lib/Service/NotesWallService.php +++ b/lib/Service/NoteService.php @@ -12,7 +12,7 @@ use OCA\Pantry\Db\NoteMapper; use OCA\Pantry\Exception\NotFoundException; use OCP\AppFramework\Db\DoesNotExistException; -class NotesWallService { +class NoteService { public function __construct( private NoteMapper $noteMapper, ) { diff --git a/lib/Service/PhotoWallService.php b/lib/Service/PhotoService.php similarity index 99% rename from lib/Service/PhotoWallService.php rename to lib/Service/PhotoService.php index 697f726..2e4e307 100644 --- a/lib/Service/PhotoWallService.php +++ b/lib/Service/PhotoService.php @@ -14,7 +14,7 @@ use OCA\Pantry\Db\PhotoMapper; use OCA\Pantry\Exception\NotFoundException; use OCP\AppFramework\Db\DoesNotExistException; -class PhotoWallService { +class PhotoService { public function __construct( private PhotoMapper $photoMapper, private PhotoFolderMapper $folderMapper, diff --git a/openapi.json b/openapi.json index c71a639..14a6200 100644 --- a/openapi.json +++ b/openapi.json @@ -3680,10 +3680,10 @@ }, "/ocs/v2.php/apps/pantry/api/houses/{houseId}/notes": { "get": { - "operationId": "notes_wall-index-notes", + "operationId": "note-index-notes", "summary": "List all notes in a house", "tags": [ - "notes_wall" + "note" ], "security": [ { @@ -3803,10 +3803,10 @@ } }, "post": { - "operationId": "notes_wall-create-note", + "operationId": "note-create-note", "summary": "Create a note", "tags": [ - "notes_wall" + "note" ], "security": [ { @@ -3933,10 +3933,10 @@ }, "/ocs/v2.php/apps/pantry/api/houses/{houseId}/notes/{noteId}": { "patch": { - "operationId": "notes_wall-update-note", + "operationId": "note-update-note", "summary": "Update a note", "tags": [ - "notes_wall" + "note" ], "security": [ { @@ -4077,10 +4077,10 @@ } }, "delete": { - "operationId": "notes_wall-delete-note", + "operationId": "note-delete-note", "summary": "Delete a note", "tags": [ - "notes_wall" + "note" ], "security": [ { @@ -4186,10 +4186,10 @@ }, "/ocs/v2.php/apps/pantry/api/houses/{houseId}/notes/reorder": { "post": { - "operationId": "notes_wall-reorder-notes", + "operationId": "note-reorder-notes", "summary": "Batch reorder notes", "tags": [ - "notes_wall" + "note" ], "security": [ { @@ -4319,10 +4319,10 @@ }, "/ocs/v2.php/apps/pantry/api/houses/{houseId}/photos/folders": { "get": { - "operationId": "photo_wall-index-folders", + "operationId": "photo-index-folders", "summary": "List all photo folders in a house", "tags": [ - "photo_wall" + "photo" ], "security": [ { @@ -4442,10 +4442,10 @@ } }, "post": { - "operationId": "photo_wall-create-folder", + "operationId": "photo-create-folder", "summary": "Create a photo folder", "tags": [ - "photo_wall" + "photo" ], "security": [ { @@ -4560,10 +4560,10 @@ }, "/ocs/v2.php/apps/pantry/api/houses/{houseId}/photos/folders/{folderId}": { "patch": { - "operationId": "photo_wall-update-folder", + "operationId": "photo-update-folder", "summary": "Update a photo folder", "tags": [ - "photo_wall" + "photo" ], "security": [ { @@ -4692,11 +4692,11 @@ } }, "delete": { - "operationId": "photo_wall-delete-folder", + "operationId": "photo-delete-folder", "summary": "Delete a photo folder", "description": "Photos in this folder are moved to the wall root.", "tags": [ - "photo_wall" + "photo" ], "security": [ { @@ -4802,10 +4802,10 @@ }, "/ocs/v2.php/apps/pantry/api/houses/{houseId}/photos/folders/reorder": { "post": { - "operationId": "photo_wall-reorder-folders", + "operationId": "photo-reorder-folders", "summary": "Batch reorder folders", "tags": [ - "photo_wall" + "photo" ], "security": [ { @@ -4935,10 +4935,10 @@ }, "/ocs/v2.php/apps/pantry/api/houses/{houseId}/photos": { "get": { - "operationId": "photo_wall-index-photos", + "operationId": "photo-index-photos", "summary": "List all photos in a house", "tags": [ - "photo_wall" + "photo" ], "security": [ { @@ -5058,10 +5058,10 @@ } }, "post": { - "operationId": "photo_wall-upload-photo", + "operationId": "photo-upload-photo", "summary": "Upload a photo", "tags": [ - "photo_wall" + "photo" ], "security": [ { @@ -5182,10 +5182,10 @@ }, "/ocs/v2.php/apps/pantry/api/houses/{houseId}/photos/{photoId}": { "patch": { - "operationId": "photo_wall-update-photo", + "operationId": "photo-update-photo", "summary": "Update a photo", "tags": [ - "photo_wall" + "photo" ], "security": [ { @@ -5321,10 +5321,10 @@ } }, "delete": { - "operationId": "photo_wall-delete-photo", + "operationId": "photo-delete-photo", "summary": "Delete a photo", "tags": [ - "photo_wall" + "photo" ], "security": [ { @@ -5430,10 +5430,10 @@ }, "/ocs/v2.php/apps/pantry/api/houses/{houseId}/photos/reorder": { "post": { - "operationId": "photo_wall-reorder-photos", + "operationId": "photo-reorder-photos", "summary": "Batch reorder photos", "tags": [ - "photo_wall" + "photo" ], "security": [ { diff --git a/src/components/NotesWall/NoteCard.test.ts b/src/components/Notes/NoteCard.test.ts similarity index 100% rename from src/components/NotesWall/NoteCard.test.ts rename to src/components/Notes/NoteCard.test.ts diff --git a/src/components/NotesWall/NoteCard.vue b/src/components/Notes/NoteCard.vue similarity index 100% rename from src/components/NotesWall/NoteCard.vue rename to src/components/Notes/NoteCard.vue diff --git a/src/components/NotesWall/NoteDialog.test.ts b/src/components/Notes/NoteDialog.test.ts similarity index 100% rename from src/components/NotesWall/NoteDialog.test.ts rename to src/components/Notes/NoteDialog.test.ts diff --git a/src/components/NotesWall/NoteDialog.vue b/src/components/Notes/NoteDialog.vue similarity index 100% rename from src/components/NotesWall/NoteDialog.vue rename to src/components/Notes/NoteDialog.vue diff --git a/src/components/NotesWall/index.ts b/src/components/Notes/index.ts similarity index 100% rename from src/components/NotesWall/index.ts rename to src/components/Notes/index.ts diff --git a/src/components/NotesWall/noteColors.test.ts b/src/components/Notes/noteColors.test.ts similarity index 100% rename from src/components/NotesWall/noteColors.test.ts rename to src/components/Notes/noteColors.test.ts diff --git a/src/components/NotesWall/noteColors.ts b/src/components/Notes/noteColors.ts similarity index 100% rename from src/components/NotesWall/noteColors.ts rename to src/components/Notes/noteColors.ts diff --git a/src/components/PhotoWall/FolderDialog.test.ts b/src/components/Photos/FolderDialog.test.ts similarity index 100% rename from src/components/PhotoWall/FolderDialog.test.ts rename to src/components/Photos/FolderDialog.test.ts diff --git a/src/components/PhotoWall/FolderDialog.vue b/src/components/Photos/FolderDialog.vue similarity index 100% rename from src/components/PhotoWall/FolderDialog.vue rename to src/components/Photos/FolderDialog.vue diff --git a/src/components/PhotoWall/FolderStack.test.ts b/src/components/Photos/FolderStack.test.ts similarity index 100% rename from src/components/PhotoWall/FolderStack.test.ts rename to src/components/Photos/FolderStack.test.ts diff --git a/src/components/PhotoWall/FolderStack.vue b/src/components/Photos/FolderStack.vue similarity index 100% rename from src/components/PhotoWall/FolderStack.vue rename to src/components/Photos/FolderStack.vue diff --git a/src/components/PhotoWall/PhotoCard.test.ts b/src/components/Photos/PhotoCard.test.ts similarity index 100% rename from src/components/PhotoWall/PhotoCard.test.ts rename to src/components/Photos/PhotoCard.test.ts diff --git a/src/components/PhotoWall/PhotoCard.vue b/src/components/Photos/PhotoCard.vue similarity index 100% rename from src/components/PhotoWall/PhotoCard.vue rename to src/components/Photos/PhotoCard.vue diff --git a/src/components/PhotoWall/PhotoPreview.test.ts b/src/components/Photos/PhotoPreview.test.ts similarity index 100% rename from src/components/PhotoWall/PhotoPreview.test.ts rename to src/components/Photos/PhotoPreview.test.ts diff --git a/src/components/PhotoWall/PhotoPreview.vue b/src/components/Photos/PhotoPreview.vue similarity index 100% rename from src/components/PhotoWall/PhotoPreview.vue rename to src/components/Photos/PhotoPreview.vue diff --git a/src/components/PhotoWall/index.ts b/src/components/Photos/index.ts similarity index 100% rename from src/components/PhotoWall/index.ts rename to src/components/Photos/index.ts diff --git a/src/components/StatusBadge/StatusBadge.test.ts b/src/components/StatusBadge/StatusBadge.test.ts deleted file mode 100644 index 0678967..0000000 --- a/src/components/StatusBadge/StatusBadge.test.ts +++ /dev/null @@ -1,270 +0,0 @@ -/** - * Example test file demonstrating Vue component testing with mocked dependencies. - * - * This shows how to: - * - Mock @nextcloud/l10n translation functions - * - Mock icon components from vue-material-design-icons - * - Mount components with props - * - Test computed properties via wrapper.vm - * - Test emitted events - * - Test conditional rendering - * - Test CSS classes and inline styles - */ -import { mount } from '@vue/test-utils' -import { beforeEach, describe, expect, it, vi } from 'vitest' - -import { createIconMock, nextcloudL10nMock } from '@/test-utils' -import StatusBadge from './StatusBadge.vue' - -// Mock @nextcloud/l10n -vi.mock('@nextcloud/l10n', () => nextcloudL10nMock) - -// Mock icon components -vi.mock('@icons/Check.vue', () => createIconMock('CheckIcon')) -vi.mock('@icons/Alert.vue', () => createIconMock('AlertIcon')) -vi.mock('@icons/ClockOutline.vue', () => createIconMock('ClockIcon')) - -describe('StatusBadge', () => { - beforeEach(() => { - vi.clearAllMocks() - }) - - describe('rendering', () => { - it('renders with required status prop', () => { - const wrapper = mount(StatusBadge, { - props: { status: 'success' }, - }) - - expect(wrapper.exists()).toBe(true) - expect(wrapper.classes()).toContain('status-badge') - }) - - it('renders the label when provided', () => { - const wrapper = mount(StatusBadge, { - props: { status: 'success', label: 'Completed' }, - }) - - expect(wrapper.find('.status-label').text()).toBe('Completed') - }) - - it('renders without label when not provided', () => { - const wrapper = mount(StatusBadge, { - props: { status: 'success' }, - }) - - expect(wrapper.find('.status-label').text()).toBe('') - }) - }) - - describe('CSS classes', () => { - it('applies correct class for success status', () => { - const wrapper = mount(StatusBadge, { - props: { status: 'success' }, - }) - - expect(wrapper.classes()).toContain('status-success') - }) - - it('applies correct class for warning status', () => { - const wrapper = mount(StatusBadge, { - props: { status: 'warning' }, - }) - - expect(wrapper.classes()).toContain('status-warning') - }) - - it('applies correct class for pending status', () => { - const wrapper = mount(StatusBadge, { - props: { status: 'pending' }, - }) - - expect(wrapper.classes()).toContain('status-pending') - }) - - it('applies correct class for error status', () => { - const wrapper = mount(StatusBadge, { - props: { status: 'error' }, - }) - - expect(wrapper.classes()).toContain('status-error') - }) - - it('applies clickable class when clickable prop is true', () => { - const wrapper = mount(StatusBadge, { - props: { status: 'success', clickable: true }, - }) - - expect(wrapper.classes()).toContain('status-clickable') - }) - - it('does not apply clickable class when clickable prop is false', () => { - const wrapper = mount(StatusBadge, { - props: { status: 'success', clickable: false }, - }) - - expect(wrapper.classes()).not.toContain('status-clickable') - }) - }) - - describe('inline styles', () => { - it('applies custom color style when customColor is provided', () => { - const wrapper = mount(StatusBadge, { - props: { status: 'success', customColor: '#ff5500' }, - }) - - const style = wrapper.attributes('style') - // Note: happy-dom preserves hex colors instead of converting to RGB - expect(style).toContain('background-color: #ff5500') - }) - - it('does not apply custom style when customColor is not provided', () => { - const wrapper = mount(StatusBadge, { - props: { status: 'success' }, - }) - - const style = wrapper.attributes('style') - expect(style).toBeUndefined() - }) - }) - - describe('icon rendering', () => { - it('renders CheckIcon for success status', () => { - const wrapper = mount(StatusBadge, { - props: { status: 'success', showIcon: true }, - }) - - expect(wrapper.find('.mock-check-icon').exists()).toBe(true) - }) - - it('renders AlertIcon for warning status', () => { - const wrapper = mount(StatusBadge, { - props: { status: 'warning', showIcon: true }, - }) - - expect(wrapper.find('.mock-alert-icon').exists()).toBe(true) - }) - - it('renders ClockIcon for pending status', () => { - const wrapper = mount(StatusBadge, { - props: { status: 'pending', showIcon: true }, - }) - - expect(wrapper.find('.mock-clock-icon').exists()).toBe(true) - }) - - it('renders AlertIcon for error status', () => { - const wrapper = mount(StatusBadge, { - props: { status: 'error', showIcon: true }, - }) - - expect(wrapper.find('.mock-alert-icon').exists()).toBe(true) - }) - - it('does not render icon when showIcon is false', () => { - const wrapper = mount(StatusBadge, { - props: { status: 'success', showIcon: false }, - }) - - expect(wrapper.find('.mock-check-icon').exists()).toBe(false) - expect(wrapper.find('.mock-alert-icon').exists()).toBe(false) - expect(wrapper.find('.mock-clock-icon').exists()).toBe(false) - }) - }) - - describe('computed properties', () => { - it('computes correct tooltipText for success status', () => { - const wrapper = mount(StatusBadge, { - props: { status: 'success' }, - }) - - // Access computed property via wrapper.vm - expect((wrapper.vm as InstanceType).tooltipText).toBe( - 'Completed successfully', - ) - }) - - it('computes correct tooltipText for error status', () => { - const wrapper = mount(StatusBadge, { - props: { status: 'error' }, - }) - - expect((wrapper.vm as InstanceType).tooltipText).toBe('Failed') - }) - - it('computes statusClass correctly', () => { - const wrapper = mount(StatusBadge, { - props: { status: 'warning', clickable: true }, - }) - - const statusClass = (wrapper.vm as InstanceType).statusClass - expect(statusClass).toEqual({ - 'status-warning': true, - 'status-clickable': true, - }) - }) - - it('computes customStyle as null when no customColor', () => { - const wrapper = mount(StatusBadge, { - props: { status: 'success' }, - }) - - expect((wrapper.vm as InstanceType).customStyle).toBeNull() - }) - - it('computes customStyle correctly when customColor is set', () => { - const wrapper = mount(StatusBadge, { - props: { status: 'success', customColor: '#123456' }, - }) - - expect((wrapper.vm as InstanceType).customStyle).toEqual({ - '--status-color': '#123456', - backgroundColor: '#123456', - }) - }) - }) - - describe('events', () => { - it('emits click event when clickable and clicked', async () => { - const wrapper = mount(StatusBadge, { - props: { status: 'success', clickable: true }, - }) - - await wrapper.trigger('click') - - expect(wrapper.emitted('click')).toBeTruthy() - expect(wrapper.emitted('click')).toHaveLength(1) - }) - - it('does not emit click event when not clickable', async () => { - const wrapper = mount(StatusBadge, { - props: { status: 'success', clickable: false }, - }) - - await wrapper.trigger('click') - - expect(wrapper.emitted('click')).toBeFalsy() - }) - - it('passes the MouseEvent to the click handler', async () => { - const wrapper = mount(StatusBadge, { - props: { status: 'success', clickable: true }, - }) - - await wrapper.trigger('click') - - const emittedEvents = wrapper.emitted('click') - expect(emittedEvents).toBeTruthy() - expect(emittedEvents![0]![0]).toBeInstanceOf(MouseEvent) - }) - }) - - describe('title attribute', () => { - it('sets title attribute based on status', () => { - const wrapper = mount(StatusBadge, { - props: { status: 'pending' }, - }) - - expect(wrapper.attributes('title')).toBe('In progress') - }) - }) -}) diff --git a/src/components/StatusBadge/StatusBadge.vue b/src/components/StatusBadge/StatusBadge.vue deleted file mode 100644 index bfdcd47..0000000 --- a/src/components/StatusBadge/StatusBadge.vue +++ /dev/null @@ -1,148 +0,0 @@ - - - - - diff --git a/src/components/StatusBadge/index.ts b/src/components/StatusBadge/index.ts deleted file mode 100644 index bff99c5..0000000 --- a/src/components/StatusBadge/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default } from './StatusBadge.vue' diff --git a/src/composables/useNotesWall.test.ts b/src/composables/useNotes.test.ts similarity index 91% rename from src/composables/useNotesWall.test.ts rename to src/composables/useNotes.test.ts index 93ae681..515d3b9 100644 --- a/src/composables/useNotesWall.test.ts +++ b/src/composables/useNotes.test.ts @@ -11,7 +11,7 @@ const mockApi = vi.hoisted(() => ({ vi.mock('@/api/notes', () => mockApi) -import { useNotesWall } from './useNotesWall' +import { useNotes } from './useNotes' function makeNote(overrides: Partial = {}): Note { return { @@ -28,7 +28,7 @@ function makeNote(overrides: Partial = {}): Note { } } -describe('useNotesWall', () => { +describe('useNotes', () => { beforeEach(() => { vi.resetAllMocks() }) @@ -38,7 +38,7 @@ describe('useNotesWall', () => { const notes = [makeNote({ id: 1 }), makeNote({ id: 2 })] mockApi.listNotes.mockResolvedValue(notes) - const wall = useNotesWall(1) + const wall = useNotes(1) await wall.load() expect(wall.notes.value).toEqual(notes) @@ -49,7 +49,7 @@ describe('useNotesWall', () => { it('sets error on failure', async () => { mockApi.listNotes.mockRejectedValue(new Error('Network error')) - const wall = useNotesWall(1) + const wall = useNotes(1) await wall.load() expect(wall.error.value).toBe('Network error') @@ -63,7 +63,7 @@ describe('useNotesWall', () => { const newNote = makeNote({ id: 10 }) mockApi.createNote.mockResolvedValue(newNote) - const wall = useNotesWall(1) + const wall = useNotes(1) await wall.load() const result = await wall.create('New Note', 'content', '#ff0000') @@ -80,7 +80,7 @@ describe('useNotesWall', () => { mockApi.listNotes.mockResolvedValue([original]) mockApi.updateNote.mockResolvedValue(updated) - const wall = useNotesWall(1) + const wall = useNotes(1) await wall.load() await wall.update(1, { title: 'New' }) @@ -93,7 +93,7 @@ describe('useNotesWall', () => { mockApi.listNotes.mockResolvedValue([makeNote({ id: 1 }), makeNote({ id: 2 })]) mockApi.deleteNote.mockResolvedValue(undefined) - const wall = useNotesWall(1) + const wall = useNotes(1) await wall.load() await wall.remove(1) @@ -110,7 +110,7 @@ describe('useNotesWall', () => { ]) mockApi.reorderNotes.mockResolvedValue(undefined) - const wall = useNotesWall(1) + const wall = useNotes(1) await wall.load() await wall.reorder([ { id: 2, sortOrder: 0 }, diff --git a/src/composables/useNotesWall.ts b/src/composables/useNotes.ts similarity index 97% rename from src/composables/useNotesWall.ts rename to src/composables/useNotes.ts index 0ad88e3..565538b 100644 --- a/src/composables/useNotesWall.ts +++ b/src/composables/useNotes.ts @@ -2,7 +2,7 @@ import { ref } from 'vue' import * as api from '@/api/notes' import type { Note } from '@/api/types' -export function useNotesWall(houseId: number) { +export function useNotes(houseId: number) { const notes = ref([]) const loading = ref(false) const error = ref(null) diff --git a/src/composables/usePhotoWall.test.ts b/src/composables/usePhotos.test.ts similarity index 93% rename from src/composables/usePhotoWall.test.ts rename to src/composables/usePhotos.test.ts index db6d96d..6e3498c 100644 --- a/src/composables/usePhotoWall.test.ts +++ b/src/composables/usePhotos.test.ts @@ -16,7 +16,7 @@ const mockApi = vi.hoisted(() => ({ vi.mock('@/api/photos', () => mockApi) -import { usePhotoWall } from './usePhotoWall' +import { usePhotos } from './usePhotos' function makePhoto(overrides: Partial = {}): Photo { return { @@ -45,7 +45,7 @@ function makeFolder(overrides: Partial = {}): PhotoFolder { } } -describe('usePhotoWall', () => { +describe('usePhotos', () => { beforeEach(() => { vi.resetAllMocks() }) @@ -57,7 +57,7 @@ describe('usePhotoWall', () => { mockApi.listPhotos.mockResolvedValue(photos) mockApi.listFolders.mockResolvedValue(folders) - const wall = usePhotoWall(1) + const wall = usePhotos(1) await wall.load() expect(wall.photos.value).toEqual(photos) @@ -70,7 +70,7 @@ describe('usePhotoWall', () => { mockApi.listPhotos.mockRejectedValue(new Error('Network error')) mockApi.listFolders.mockResolvedValue([]) - const wall = usePhotoWall(1) + const wall = usePhotos(1) await wall.load() expect(wall.error.value).toBe('Network error') @@ -87,7 +87,7 @@ describe('usePhotoWall', () => { ]) mockApi.listFolders.mockResolvedValue([]) - const wall = usePhotoWall(1) + const wall = usePhotos(1) await wall.load() expect(wall.rootPhotos.value).toHaveLength(2) @@ -105,7 +105,7 @@ describe('usePhotoWall', () => { ]) mockApi.listFolders.mockResolvedValue([]) - const wall = usePhotoWall(1) + const wall = usePhotos(1) await wall.load() expect(wall.photosInFolder(5)).toHaveLength(2) @@ -122,7 +122,7 @@ describe('usePhotoWall', () => { const newPhoto = makePhoto({ id: 10, fileId: 100 }) mockApi.uploadPhoto.mockResolvedValue(newPhoto) - const wall = usePhotoWall(1) + const wall = usePhotos(1) await wall.load() const file = new File(['data'], 'test.jpg') const result = await wall.upload(file, 5) @@ -142,7 +142,7 @@ describe('usePhotoWall', () => { mockApi.listFolders.mockResolvedValue([]) mockApi.updatePhoto.mockResolvedValue(updated) - const wall = usePhotoWall(1) + const wall = usePhotos(1) await wall.load() await wall.updatePhoto(1, { caption: 'New' }) @@ -156,7 +156,7 @@ describe('usePhotoWall', () => { mockApi.listFolders.mockResolvedValue([]) mockApi.deletePhoto.mockResolvedValue(undefined) - const wall = usePhotoWall(1) + const wall = usePhotos(1) await wall.load() await wall.removePhoto(1) @@ -174,7 +174,7 @@ describe('usePhotoWall', () => { mockApi.listFolders.mockResolvedValue([]) mockApi.reorderPhotos.mockResolvedValue(undefined) - const wall = usePhotoWall(1) + const wall = usePhotos(1) await wall.load() await wall.reorderPhotos([ { id: 2, sortOrder: 0 }, @@ -193,7 +193,7 @@ describe('usePhotoWall', () => { const newFolder = makeFolder({ id: 10, name: 'New' }) mockApi.createFolder.mockResolvedValue(newFolder) - const wall = usePhotoWall(1) + const wall = usePhotos(1) await wall.load() const result = await wall.createFolder('New') @@ -211,7 +211,7 @@ describe('usePhotoWall', () => { mockApi.listFolders.mockResolvedValue([original]) mockApi.updateFolder.mockResolvedValue(updated) - const wall = usePhotoWall(1) + const wall = usePhotos(1) await wall.load() await wall.updateFolder(1, { name: 'New' }) @@ -228,7 +228,7 @@ describe('usePhotoWall', () => { mockApi.listFolders.mockResolvedValue([makeFolder({ id: 5 })]) mockApi.deleteFolder.mockResolvedValue(undefined) - const wall = usePhotoWall(1) + const wall = usePhotos(1) await wall.load() await wall.removeFolder(5) @@ -248,7 +248,7 @@ describe('usePhotoWall', () => { ]) mockApi.reorderFolders.mockResolvedValue(undefined) - const wall = usePhotoWall(1) + const wall = usePhotos(1) await wall.load() await wall.reorderFolders([ { id: 2, sortOrder: 0 }, diff --git a/src/composables/usePhotoWall.ts b/src/composables/usePhotos.ts similarity index 98% rename from src/composables/usePhotoWall.ts rename to src/composables/usePhotos.ts index 6bc6a13..f4e7aab 100644 --- a/src/composables/usePhotoWall.ts +++ b/src/composables/usePhotos.ts @@ -2,7 +2,7 @@ import { computed, ref } from 'vue' import * as api from '@/api/photos' import type { Photo, PhotoFolder } from '@/api/types' -export function usePhotoWall(houseId: number) { +export function usePhotos(houseId: number) { const photos = ref([]) const folders = ref([]) const loading = ref(false) diff --git a/src/router.ts b/src/router.ts index ec8d21e..660215e 100644 --- a/src/router.ts +++ b/src/router.ts @@ -45,19 +45,19 @@ const routes: RouteRecordRaw[] = [ { path: 'photos', name: 'photos', - component: () => import('@/views/PhotoWallView.vue'), + component: () => import('@/views/PhotosView.vue'), props: true, }, { path: 'photos/folders/:folderId', name: 'photo-folder', - component: () => import('@/views/PhotoWallView.vue'), + component: () => import('@/views/PhotosView.vue'), props: true, }, { path: 'notes', name: 'notes', - component: () => import('@/views/NotesWallView.vue'), + component: () => import('@/views/NotesView.vue'), props: true, }, ], diff --git a/src/views/NotesWallView.vue b/src/views/NotesView.vue similarity index 98% rename from src/views/NotesWallView.vue rename to src/views/NotesView.vue index 297ef76..fbc4169 100644 --- a/src/views/NotesWallView.vue +++ b/src/views/NotesView.vue @@ -83,16 +83,16 @@ import NcLoadingIcon from '@nextcloud/vue/components/NcLoadingIcon' import NcEmptyContent from '@nextcloud/vue/components/NcEmptyContent' import NcDialog from '@nextcloud/vue/components/NcDialog' import PageToolbar from '@/components/PageToolbar' -import { NoteCard, NoteDialog } from '@/components/NotesWall' +import { NoteCard, NoteDialog } from '@/components/Notes' import PlusIcon from '@icons/Plus.vue' import NoteIcon from '@icons/Note.vue' import type { Note } from '@/api/types' -import { useNotesWall } from '@/composables/useNotesWall' +import { useNotes } from '@/composables/useNotes' const props = defineProps<{ houseId: string }>() const houseIdNum = computed(() => Number(props.houseId)) -const { notes, loading, load, create, update, remove, reorder } = useNotesWall(houseIdNum.value) +const { notes, loading, load, create, update, remove, reorder } = useNotes(houseIdNum.value) onMounted(load) watch( diff --git a/src/views/NotesWallStub.vue b/src/views/NotesWallStub.vue deleted file mode 100644 index f81a024..0000000 --- a/src/views/NotesWallStub.vue +++ /dev/null @@ -1,22 +0,0 @@ - - - diff --git a/src/views/PhotoBoardStub.vue b/src/views/PhotoBoardStub.vue deleted file mode 100644 index 62a404b..0000000 --- a/src/views/PhotoBoardStub.vue +++ /dev/null @@ -1,25 +0,0 @@ - - - diff --git a/src/views/PhotoWallView.vue b/src/views/PhotosView.vue similarity index 97% rename from src/views/PhotoWallView.vue rename to src/views/PhotosView.vue index 4d737c0..0e155ac 100644 --- a/src/views/PhotoWallView.vue +++ b/src/views/PhotosView.vue @@ -10,16 +10,22 @@ @@ -224,13 +230,13 @@ import NcEmptyContent from '@nextcloud/vue/components/NcEmptyContent' import NcDialog from '@nextcloud/vue/components/NcDialog' import NcTextField from '@nextcloud/vue/components/NcTextField' import PageToolbar from '@/components/PageToolbar' -import { PhotoCard, FolderStack, FolderDialog, PhotoPreview } from '@/components/PhotoWall' +import { PhotoCard, FolderStack, FolderDialog, PhotoPreview } from '@/components/Photos' import UploadIcon from '@icons/Upload.vue' import ImageIcon from '@icons/Image.vue' import ArrowLeftIcon from '@icons/ArrowLeft.vue' import FolderPlusIcon from '@icons/FolderPlus.vue' import type { Photo, PhotoFolder } from '@/api/types' -import { usePhotoWall } from '@/composables/usePhotoWall' +import { usePhotos } from '@/composables/usePhotos' const props = defineProps<{ houseId: string; folderId?: string }>() const router = useRouter() @@ -249,7 +255,7 @@ const { createFolder, updateFolder, removeFolder, -} = usePhotoWall(houseIdNum.value) +} = usePhotos(houseIdNum.value) onMounted(load) watch( @@ -549,7 +555,7 @@ async function submitDeleteFolder() { } const strings = { - title: t('pantry', 'Photo wall'), + title: t('pantry', 'Photo board'), upload: t('pantry', 'Upload'), newFolder: t('pantry', 'New folder'), back: t('pantry', 'Back'), diff --git a/tests/unit/Service/ChecklistServiceTest.php b/tests/unit/Service/ChecklistServiceTest.php index 9b77dcd..8f7522f 100644 --- a/tests/unit/Service/ChecklistServiceTest.php +++ b/tests/unit/Service/ChecklistServiceTest.php @@ -11,8 +11,8 @@ use OCA\Pantry\Db\Checklist; use OCA\Pantry\Db\ChecklistItem; use OCA\Pantry\Db\ChecklistItemMapper; use OCA\Pantry\Db\ChecklistMapper; -use OCA\Pantry\Service\RecurrenceService; use OCA\Pantry\Service\ChecklistService; +use OCA\Pantry\Service\RecurrenceService; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; diff --git a/tests/unit/Service/NotesWallServiceTest.php b/tests/unit/Service/NoteServiceTest.php similarity index 97% rename from tests/unit/Service/NotesWallServiceTest.php rename to tests/unit/Service/NoteServiceTest.php index c2b1c14..a42916f 100644 --- a/tests/unit/Service/NotesWallServiceTest.php +++ b/tests/unit/Service/NoteServiceTest.php @@ -10,19 +10,19 @@ namespace OCA\Pantry\Tests\Unit\Service; use OCA\Pantry\Db\Note; use OCA\Pantry\Db\NoteMapper; use OCA\Pantry\Exception\NotFoundException; -use OCA\Pantry\Service\NotesWallService; +use OCA\Pantry\Service\NoteService; use OCP\AppFramework\Db\DoesNotExistException; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; -class NotesWallServiceTest extends TestCase { +class NoteServiceTest extends TestCase { /** @var NoteMapper&MockObject */ private NoteMapper $noteMapper; - private NotesWallService $svc; + private NoteService $svc; protected function setUp(): void { $this->noteMapper = $this->createMock(NoteMapper::class); - $this->svc = new NotesWallService($this->noteMapper); + $this->svc = new NoteService($this->noteMapper); } private function makeNote(array $overrides = []): Note { diff --git a/tests/unit/Service/PhotoWallServiceTest.php b/tests/unit/Service/PhotoServiceTest.php similarity index 98% rename from tests/unit/Service/PhotoWallServiceTest.php rename to tests/unit/Service/PhotoServiceTest.php index 765781e..7718922 100644 --- a/tests/unit/Service/PhotoWallServiceTest.php +++ b/tests/unit/Service/PhotoServiceTest.php @@ -12,22 +12,22 @@ use OCA\Pantry\Db\PhotoFolder; use OCA\Pantry\Db\PhotoFolderMapper; use OCA\Pantry\Db\PhotoMapper; use OCA\Pantry\Exception\NotFoundException; -use OCA\Pantry\Service\PhotoWallService; +use OCA\Pantry\Service\PhotoService; use OCP\AppFramework\Db\DoesNotExistException; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; -class PhotoWallServiceTest extends TestCase { +class PhotoServiceTest extends TestCase { /** @var PhotoMapper&MockObject */ private PhotoMapper $photoMapper; /** @var PhotoFolderMapper&MockObject */ private PhotoFolderMapper $folderMapper; - private PhotoWallService $svc; + private PhotoService $svc; protected function setUp(): void { $this->photoMapper = $this->createMock(PhotoMapper::class); $this->folderMapper = $this->createMock(PhotoFolderMapper::class); - $this->svc = new PhotoWallService( + $this->svc = new PhotoService( $this->photoMapper, $this->folderMapper, );