fix: importer bugs and editor bugs
This commit is contained in:
@@ -76,6 +76,7 @@ const mockMediaEngine = {
|
||||
reindexText: vi.fn(),
|
||||
getThumbnailDataUrl: vi.fn(),
|
||||
regenerateMissingThumbnails: vi.fn(),
|
||||
getRelativePath: vi.fn(),
|
||||
};
|
||||
|
||||
const mockProjectEngine = {
|
||||
@@ -606,10 +607,21 @@ describe('IPC Handlers', () => {
|
||||
});
|
||||
|
||||
describe('media:getUrl', () => {
|
||||
it('should return bds-media protocol URL', async () => {
|
||||
it('should return relative media path', async () => {
|
||||
mockMediaEngine.getRelativePath.mockResolvedValue('media/2025/01/media-123.jpg');
|
||||
|
||||
const result = await invokeHandler('media:getUrl', 'media-123');
|
||||
|
||||
expect(result).toBe('bds-media://media-123');
|
||||
expect(mockMediaEngine.getRelativePath).toHaveBeenCalledWith('media-123');
|
||||
expect(result).toBe('media/2025/01/media-123.jpg');
|
||||
});
|
||||
|
||||
it('should fall back to media/{id} when relative path is not found', async () => {
|
||||
mockMediaEngine.getRelativePath.mockResolvedValue(null);
|
||||
|
||||
const result = await invokeHandler('media:getUrl', 'media-unknown');
|
||||
|
||||
expect(result).toBe('media/media-unknown');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user