fix: better updating of links from photo_album

This commit is contained in:
2026-02-14 22:23:41 +01:00
parent 7a1d15d256
commit 51f58d608d
8 changed files with 344 additions and 37 deletions

View File

@@ -130,6 +130,8 @@ const mockPostMediaEngine = {
setProjectContext: vi.fn(),
linkMediaToPost: vi.fn(),
unlinkMediaFromPost: vi.fn(),
linkManyToPost: vi.fn(),
unlinkManyFromPost: vi.fn(),
getLinkedMediaForPost: vi.fn(),
getLinkedPostsForMedia: vi.fn(),
reorderMediaForPost: vi.fn(),
@@ -878,6 +880,32 @@ describe('IPC Handlers', () => {
});
});
describe('postMedia:linkMany', () => {
it('should batch link multiple media to post', async () => {
const batchResult = { linked: ['media-1', 'media-2'], skipped: [] };
mockPostMediaEngine.linkManyToPost.mockResolvedValue(batchResult);
const mediaIds = ['media-1', 'media-2'];
const result = await invokeHandler('postMedia:linkMany', 'post-1', mediaIds);
expect(mockPostMediaEngine.linkManyToPost).toHaveBeenCalledWith('post-1', mediaIds);
expect(result).toEqual(batchResult);
});
});
describe('postMedia:unlinkMany', () => {
it('should batch unlink multiple media from post', async () => {
const batchResult = { unlinked: ['media-1', 'media-2'] };
mockPostMediaEngine.unlinkManyFromPost.mockResolvedValue(batchResult);
const mediaIds = ['media-1', 'media-2'];
const result = await invokeHandler('postMedia:unlinkMany', 'post-1', mediaIds);
expect(mockPostMediaEngine.unlinkManyFromPost).toHaveBeenCalledWith('post-1', mediaIds);
expect(result).toEqual(batchResult);
});
});
describe('postMedia:getForPost', () => {
it('should return media linked to a post', async () => {
const linkedMedia = [createMockMedia(), createMockMedia()];