mirror of
https://github.com/immich-app/immich.git
synced 2026-03-04 09:57:33 +03:00
refactor: more small tests (#26159)
This commit is contained in:
@@ -4,6 +4,7 @@ import { SearchService } from 'src/services/search.service';
|
||||
import { AssetFactory } from 'test/factories/asset.factory';
|
||||
import { assetStub } from 'test/fixtures/asset.stub';
|
||||
import { authStub } from 'test/fixtures/auth.stub';
|
||||
import { newUuid } from 'test/small.factory';
|
||||
import { makeStream, newTestService, ServiceMocks } from 'test/utils';
|
||||
import { beforeEach, vitest } from 'vitest';
|
||||
|
||||
@@ -151,9 +152,7 @@ describe(SearchService.name, () => {
|
||||
},
|
||||
},
|
||||
});
|
||||
const id = assetStub.livePhotoMotionAsset.id;
|
||||
|
||||
const result = await sut.handleSearchDuplicates({ id });
|
||||
const result = await sut.handleSearchDuplicates({ id: newUuid() });
|
||||
|
||||
expect(result).toBe(JobStatus.Skipped);
|
||||
expect(mocks.assetJob.getForSearchDuplicatesJob).not.toHaveBeenCalled();
|
||||
@@ -168,9 +167,7 @@ describe(SearchService.name, () => {
|
||||
},
|
||||
},
|
||||
});
|
||||
const id = assetStub.livePhotoMotionAsset.id;
|
||||
|
||||
const result = await sut.handleSearchDuplicates({ id });
|
||||
const result = await sut.handleSearchDuplicates({ id: newUuid() });
|
||||
|
||||
expect(result).toBe(JobStatus.Skipped);
|
||||
expect(mocks.assetJob.getForSearchDuplicatesJob).not.toHaveBeenCalled();
|
||||
@@ -197,16 +194,13 @@ describe(SearchService.name, () => {
|
||||
});
|
||||
|
||||
it('should skip if asset is not visible', async () => {
|
||||
const id = assetStub.livePhotoMotionAsset.id;
|
||||
mocks.assetJob.getForSearchDuplicatesJob.mockResolvedValue({
|
||||
...hasEmbedding,
|
||||
visibility: AssetVisibility.Hidden,
|
||||
});
|
||||
const asset = AssetFactory.create({ visibility: AssetVisibility.Hidden });
|
||||
mocks.assetJob.getForSearchDuplicatesJob.mockResolvedValue({ ...hasEmbedding, ...asset });
|
||||
|
||||
const result = await sut.handleSearchDuplicates({ id });
|
||||
const result = await sut.handleSearchDuplicates({ id: asset.id });
|
||||
|
||||
expect(result).toBe(JobStatus.Skipped);
|
||||
expect(mocks.logger.debug).toHaveBeenCalledWith(`Asset ${id} is not visible, skipping`);
|
||||
expect(mocks.logger.debug).toHaveBeenCalledWith(`Asset ${asset.id} is not visible, skipping`);
|
||||
});
|
||||
|
||||
it('should fail if asset is missing embedding', async () => {
|
||||
|
||||
Reference in New Issue
Block a user