mirror of
https://github.com/immich-app/immich.git
synced 2025-12-22 01:11:20 +03:00
feat(web): Improve duplicate suggestion (#14947)
* feat: Improve duplicate suggestion * format * feat(web): Add deduplication info popup * fix: lint * fmt --------- Co-authored-by: Alex <alex.tran1502@gmail.com>
This commit is contained in:
committed by
GitHub
parent
23f3e737fd
commit
b4c1304b46
37
web/src/lib/utils/duplicate-utils.spec.ts
Normal file
37
web/src/lib/utils/duplicate-utils.spec.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import { suggestDuplicate } from '$lib/utils/duplicate-utils';
|
||||
import type { AssetResponseDto } from '@immich/sdk';
|
||||
|
||||
describe('choosing a duplicate', () => {
|
||||
it('picks the asset with the largest file size', () => {
|
||||
const assets = [
|
||||
{ exifInfo: { fileSizeInByte: 300 } },
|
||||
{ exifInfo: { fileSizeInByte: 200 } },
|
||||
{ exifInfo: { fileSizeInByte: 100 } },
|
||||
];
|
||||
expect(suggestDuplicate(assets as AssetResponseDto[])).toEqual(assets[0]);
|
||||
});
|
||||
|
||||
it('picks the asset with the most exif data if multiple assets have the same file size', () => {
|
||||
const assets = [
|
||||
{ exifInfo: { fileSizeInByte: 200, rating: 5, fNumber: 1 } },
|
||||
{ exifInfo: { fileSizeInByte: 200, rating: 5 } },
|
||||
{ exifInfo: { fileSizeInByte: 100, rating: 5 } },
|
||||
];
|
||||
expect(suggestDuplicate(assets as AssetResponseDto[])).toEqual(assets[0]);
|
||||
});
|
||||
|
||||
it('returns undefined for an empty array', () => {
|
||||
const assets: AssetResponseDto[] = [];
|
||||
expect(suggestDuplicate(assets)).toBeUndefined();
|
||||
});
|
||||
|
||||
it('handles assets with no exifInfo', () => {
|
||||
const assets = [{ exifInfo: { fileSizeInByte: 200 } }, {}];
|
||||
expect(suggestDuplicate(assets as AssetResponseDto[])).toEqual(assets[0]);
|
||||
});
|
||||
|
||||
it('handles assets with exifInfo but no fileSizeInByte', () => {
|
||||
const assets = [{ exifInfo: { rating: 5, fNumber: 1 } }, { exifInfo: { rating: 5 } }];
|
||||
expect(suggestDuplicate(assets as AssetResponseDto[])).toEqual(assets[0]);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user