update tests

This commit is contained in:
mertalev 2025-04-01 15:49:54 -04:00
parent e7503ce3dc
commit 33c9ea1c9c
No known key found for this signature in database
GPG Key ID: DF6ABC77AAD98C95
5 changed files with 49 additions and 6 deletions

View File

@ -584,7 +584,7 @@ describe(AssetMediaService.name, () => {
sut.viewThumbnail(authStub.admin, assetStub.image.id, { size: AssetMediaSize.PREVIEW }), sut.viewThumbnail(authStub.admin, assetStub.image.id, { size: AssetMediaSize.PREVIEW }),
).resolves.toEqual( ).resolves.toEqual(
new ImmichFileResponse({ new ImmichFileResponse({
path: assetStub.image.files[0].path, path: '/uploads/user-id/thumbs/path.jpg',
cacheControl: CacheControl.PRIVATE_WITH_CACHE, cacheControl: CacheControl.PRIVATE_WITH_CACHE,
contentType: 'image/jpeg', contentType: 'image/jpeg',
fileName: 'asset-id_preview.jpg', fileName: 'asset-id_preview.jpg',
@ -599,7 +599,7 @@ describe(AssetMediaService.name, () => {
sut.viewThumbnail(authStub.admin, assetStub.image.id, { size: AssetMediaSize.THUMBNAIL }), sut.viewThumbnail(authStub.admin, assetStub.image.id, { size: AssetMediaSize.THUMBNAIL }),
).resolves.toEqual( ).resolves.toEqual(
new ImmichFileResponse({ new ImmichFileResponse({
path: assetStub.image.files[1].path, path: '/uploads/user-id/webp/path.ext',
cacheControl: CacheControl.PRIVATE_WITH_CACHE, cacheControl: CacheControl.PRIVATE_WITH_CACHE,
contentType: 'application/octet-stream', contentType: 'application/octet-stream',
fileName: 'asset-id_thumbnail.ext', fileName: 'asset-id_thumbnail.ext',

View File

@ -578,6 +578,7 @@ describe(AssetService.name, () => {
files: [ files: [
'/uploads/user-id/webp/path.ext', '/uploads/user-id/webp/path.ext',
'/uploads/user-id/thumbs/path.jpg', '/uploads/user-id/thumbs/path.jpg',
'/uploads/user-id/fullsize/path.webp',
assetWithFace.encodedVideoPath, assetWithFace.encodedVideoPath,
assetWithFace.sidecarPath, assetWithFace.sidecarPath,
assetWithFace.originalPath, assetWithFace.originalPath,
@ -637,7 +638,14 @@ describe(AssetService.name, () => {
{ {
name: JobName.DELETE_FILES, name: JobName.DELETE_FILES,
data: { data: {
files: [undefined, undefined, undefined, undefined, 'fake_path/asset_1.jpeg'], files: [
'/uploads/user-id/webp/path.ext',
'/uploads/user-id/thumbs/path.jpg',
'/uploads/user-id/fullsize/path.webp',
undefined,
undefined,
'fake_path/asset_1.jpeg',
],
}, },
}, },
], ],
@ -658,7 +666,14 @@ describe(AssetService.name, () => {
{ {
name: JobName.DELETE_FILES, name: JobName.DELETE_FILES,
data: { data: {
files: [undefined, undefined, undefined, undefined, 'fake_path/asset_1.jpeg'], files: [
'/uploads/user-id/webp/path.ext',
'/uploads/user-id/thumbs/path.jpg',
'/uploads/user-id/fullsize/path.webp',
undefined,
undefined,
'fake_path/asset_1.jpeg',
],
}, },
}, },
], ],

View File

@ -234,6 +234,24 @@ describe(MediaService.name, () => {
}); });
await expect(sut.handleAssetMigration({ id: assetStub.image.id })).resolves.toBe(JobStatus.SUCCESS); await expect(sut.handleAssetMigration({ id: assetStub.image.id })).resolves.toBe(JobStatus.SUCCESS);
expect(mocks.move.create).toHaveBeenCalledWith({
entityId: assetStub.image.id,
pathType: AssetPathType.FULLSIZE,
oldPath: '/uploads/user-id/fullsize/path.webp',
newPath: 'upload/thumbs/user-id/as/se/asset-id-fullsize.jpeg',
});
expect(mocks.move.create).toHaveBeenCalledWith({
entityId: assetStub.image.id,
pathType: AssetPathType.PREVIEW,
oldPath: '/uploads/user-id/thumbs/path.jpg',
newPath: 'upload/thumbs/user-id/as/se/asset-id-preview.jpeg',
});
expect(mocks.move.create).toHaveBeenCalledWith({
entityId: assetStub.image.id,
pathType: AssetPathType.THUMBNAIL,
oldPath: '/uploads/user-id/webp/path.ext',
newPath: 'upload/thumbs/user-id/as/se/asset-id-thumbnail.webp',
});
expect(mocks.move.create).toHaveBeenCalledTimes(3); expect(mocks.move.create).toHaveBeenCalledTimes(3);
}); });
}); });

View File

@ -140,7 +140,7 @@ export class MediaService extends BaseService {
return JobStatus.FAILED; return JobStatus.FAILED;
} }
await this.storageCore.moveAssetImage(asset, AssetPathType.FULLSIZE, ImageFormat.JPEG); await this.storageCore.moveAssetImage(asset, AssetPathType.FULLSIZE, image.fullsize.format);
await this.storageCore.moveAssetImage(asset, AssetPathType.PREVIEW, image.preview.format); await this.storageCore.moveAssetImage(asset, AssetPathType.PREVIEW, image.preview.format);
await this.storageCore.moveAssetImage(asset, AssetPathType.THUMBNAIL, image.thumbnail.format); await this.storageCore.moveAssetImage(asset, AssetPathType.THUMBNAIL, image.thumbnail.format);
await this.storageCore.moveAssetVideo(asset); await this.storageCore.moveAssetVideo(asset);

View File

@ -26,7 +26,16 @@ const thumbnailFile: AssetFileEntity = {
updatedAt: new Date('2023-02-23T05:06:29.716Z'), updatedAt: new Date('2023-02-23T05:06:29.716Z'),
}; };
const files: AssetFileEntity[] = [previewFile, thumbnailFile]; const fullsizeFile: AssetFileEntity = {
id: 'file-3',
assetId: 'asset-id',
type: AssetFileType.FULLSIZE,
path: '/uploads/user-id/fullsize/path.webp',
createdAt: new Date('2023-02-23T05:06:29.716Z'),
updatedAt: new Date('2023-02-23T05:06:29.716Z'),
};
const files: AssetFileEntity[] = [fullsizeFile, previewFile, thumbnailFile];
export const stackStub = (stackId: string, assets: AssetEntity[]): StackEntity => { export const stackStub = (stackId: string, assets: AssetEntity[]): StackEntity => {
return { return {
@ -553,6 +562,7 @@ export const assetStub = {
fileSizeInByte: 25_000, fileSizeInByte: 25_000,
timeZone: `America/New_York`, timeZone: `America/New_York`,
}, },
files,
} as AssetEntity), } as AssetEntity),
livePhotoWithOriginalFileName: Object.freeze({ livePhotoWithOriginalFileName: Object.freeze({