2024-03-21 00:53:07 +02:00
|
|
|
import { AlbumResponseDto } from 'src/dtos/album.dto';
|
|
|
|
import { AssetResponseDto } from 'src/dtos/asset-response.dto';
|
|
|
|
import { ExifResponseDto } from 'src/dtos/exif.dto';
|
|
|
|
import { SharedLinkResponseDto } from 'src/dtos/shared-link.dto';
|
|
|
|
import { mapUser } from 'src/dtos/user.dto';
|
2024-03-20 23:02:51 +02:00
|
|
|
import { AssetOrder } from 'src/entities/album.entity';
|
|
|
|
import { AssetType } from 'src/entities/asset.entity';
|
|
|
|
import { SharedLinkEntity, SharedLinkType } from 'src/entities/shared-link.entity';
|
|
|
|
import { UserEntity } from 'src/entities/user.entity';
|
2024-03-20 20:32:04 +02:00
|
|
|
import { assetStub } from 'test/fixtures/asset.stub';
|
|
|
|
import { authStub } from 'test/fixtures/auth.stub';
|
|
|
|
import { libraryStub } from 'test/fixtures/library.stub';
|
|
|
|
import { userStub } from 'test/fixtures/user.stub';
|
2023-08-01 03:28:07 +02:00
|
|
|
|
|
|
|
const today = new Date();
|
|
|
|
const tomorrow = new Date();
|
|
|
|
const yesterday = new Date();
|
|
|
|
tomorrow.setDate(today.getDate() + 1);
|
|
|
|
yesterday.setDate(yesterday.getDate() - 1);
|
|
|
|
|
|
|
|
const sharedLinkBytes = Buffer.from(
|
|
|
|
'2c2b646895f84753bff43fb696ad124f3b0faf2a0bd547406f26fa4a76b5c71990092baa536275654b2ab7a191fb21a6d6cd',
|
|
|
|
'hex',
|
|
|
|
);
|
|
|
|
|
|
|
|
const assetInfo: ExifResponseDto = {
|
|
|
|
make: 'camera-make',
|
|
|
|
model: 'camera-model',
|
|
|
|
exifImageWidth: 500,
|
|
|
|
exifImageHeight: 500,
|
|
|
|
fileSizeInByte: 100,
|
|
|
|
orientation: 'orientation',
|
|
|
|
dateTimeOriginal: today,
|
|
|
|
modifyDate: today,
|
|
|
|
timeZone: 'America/Los_Angeles',
|
|
|
|
lensModel: 'fancy',
|
|
|
|
fNumber: 100,
|
|
|
|
focalLength: 100,
|
|
|
|
iso: 100,
|
|
|
|
exposureTime: '1/16',
|
|
|
|
latitude: 100,
|
|
|
|
longitude: 100,
|
|
|
|
city: 'city',
|
|
|
|
state: 'state',
|
|
|
|
country: 'country',
|
|
|
|
description: 'description',
|
|
|
|
projectionType: null,
|
|
|
|
};
|
|
|
|
|
|
|
|
const assetResponse: AssetResponseDto = {
|
|
|
|
id: 'id_1',
|
|
|
|
deviceAssetId: 'device_asset_id_1',
|
|
|
|
ownerId: 'user_id_1',
|
|
|
|
deviceId: 'device_id_1',
|
|
|
|
type: AssetType.VIDEO,
|
|
|
|
originalPath: 'fake_path/jpeg',
|
|
|
|
originalFileName: 'asset_1.jpeg',
|
|
|
|
resized: false,
|
|
|
|
thumbhash: null,
|
|
|
|
fileModifiedAt: today,
|
2023-09-20 13:16:33 +02:00
|
|
|
isExternal: false,
|
|
|
|
isReadOnly: false,
|
|
|
|
isOffline: false,
|
2023-08-01 03:28:07 +02:00
|
|
|
fileCreatedAt: today,
|
2023-10-05 00:11:11 +02:00
|
|
|
localDateTime: today,
|
2023-08-01 03:28:07 +02:00
|
|
|
updatedAt: today,
|
|
|
|
isFavorite: false,
|
|
|
|
isArchived: false,
|
|
|
|
smartInfo: {
|
|
|
|
tags: [],
|
|
|
|
objects: ['a', 'b', 'c'],
|
|
|
|
},
|
|
|
|
duration: '0:00:00.00000',
|
|
|
|
exifInfo: assetInfo,
|
|
|
|
livePhotoVideoId: null,
|
|
|
|
tags: [],
|
|
|
|
people: [],
|
|
|
|
checksum: 'ZmlsZSBoYXNo',
|
2023-10-06 09:01:14 +02:00
|
|
|
isTrashed: false,
|
2023-09-20 13:16:33 +02:00
|
|
|
libraryId: 'library-id',
|
2023-10-14 03:46:30 +02:00
|
|
|
hasMetadata: true,
|
2023-10-22 04:38:07 +02:00
|
|
|
stackCount: 0,
|
2023-08-01 03:28:07 +02:00
|
|
|
};
|
|
|
|
|
2023-10-14 03:46:30 +02:00
|
|
|
const assetResponseWithoutMetadata = {
|
|
|
|
id: 'id_1',
|
|
|
|
type: AssetType.VIDEO,
|
|
|
|
resized: false,
|
|
|
|
thumbhash: null,
|
|
|
|
localDateTime: today,
|
|
|
|
duration: '0:00:00.00000',
|
|
|
|
livePhotoVideoId: null,
|
|
|
|
hasMetadata: false,
|
|
|
|
} as AssetResponseDto;
|
|
|
|
|
2023-08-01 03:28:07 +02:00
|
|
|
const albumResponse: AlbumResponseDto = {
|
|
|
|
albumName: 'Test Album',
|
2023-08-06 04:43:26 +02:00
|
|
|
description: '',
|
2023-08-01 03:28:07 +02:00
|
|
|
albumThumbnailAssetId: null,
|
|
|
|
createdAt: today,
|
|
|
|
updatedAt: today,
|
|
|
|
id: 'album-123',
|
|
|
|
ownerId: 'admin_id',
|
|
|
|
owner: mapUser(userStub.admin),
|
|
|
|
sharedUsers: [],
|
|
|
|
shared: false,
|
2023-08-11 18:00:51 +02:00
|
|
|
hasSharedLink: false,
|
2023-08-01 03:28:07 +02:00
|
|
|
assets: [],
|
|
|
|
assetCount: 1,
|
2023-11-07 06:37:21 +02:00
|
|
|
isActivityEnabled: true,
|
2024-03-14 18:45:03 +02:00
|
|
|
order: AssetOrder.DESC,
|
2023-08-01 03:28:07 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
export const sharedLinkStub = {
|
|
|
|
individual: Object.freeze({
|
|
|
|
id: '123',
|
2023-12-10 06:34:12 +02:00
|
|
|
userId: authStub.admin.user.id,
|
2023-08-01 03:28:07 +02:00
|
|
|
user: userStub.admin,
|
|
|
|
key: sharedLinkBytes,
|
|
|
|
type: SharedLinkType.INDIVIDUAL,
|
|
|
|
createdAt: today,
|
|
|
|
expiresAt: tomorrow,
|
|
|
|
allowUpload: true,
|
|
|
|
allowDownload: true,
|
|
|
|
showExif: true,
|
|
|
|
album: undefined,
|
|
|
|
description: null,
|
|
|
|
assets: [assetStub.image],
|
|
|
|
} as SharedLinkEntity),
|
|
|
|
valid: Object.freeze({
|
|
|
|
id: '123',
|
2023-12-10 06:34:12 +02:00
|
|
|
userId: authStub.admin.user.id,
|
2023-08-01 03:28:07 +02:00
|
|
|
user: userStub.admin,
|
|
|
|
key: sharedLinkBytes,
|
|
|
|
type: SharedLinkType.ALBUM,
|
|
|
|
createdAt: today,
|
|
|
|
expiresAt: tomorrow,
|
|
|
|
allowUpload: true,
|
|
|
|
allowDownload: true,
|
|
|
|
showExif: true,
|
|
|
|
album: undefined,
|
|
|
|
albumId: null,
|
|
|
|
description: null,
|
2023-10-29 03:35:38 +02:00
|
|
|
password: null,
|
2023-08-01 03:28:07 +02:00
|
|
|
assets: [],
|
|
|
|
} as SharedLinkEntity),
|
|
|
|
expired: Object.freeze({
|
|
|
|
id: '123',
|
2023-12-10 06:34:12 +02:00
|
|
|
userId: authStub.admin.user.id,
|
2023-08-01 03:28:07 +02:00
|
|
|
user: userStub.admin,
|
|
|
|
key: sharedLinkBytes,
|
|
|
|
type: SharedLinkType.ALBUM,
|
|
|
|
createdAt: today,
|
|
|
|
expiresAt: yesterday,
|
|
|
|
allowUpload: true,
|
|
|
|
allowDownload: true,
|
|
|
|
showExif: true,
|
|
|
|
description: null,
|
2023-10-29 03:35:38 +02:00
|
|
|
password: null,
|
2023-08-01 03:28:07 +02:00
|
|
|
albumId: null,
|
|
|
|
assets: [],
|
|
|
|
} as SharedLinkEntity),
|
|
|
|
readonlyNoExif: Object.freeze<SharedLinkEntity>({
|
|
|
|
id: '123',
|
2023-12-10 06:34:12 +02:00
|
|
|
userId: authStub.admin.user.id,
|
2023-08-01 03:28:07 +02:00
|
|
|
user: userStub.admin,
|
|
|
|
key: sharedLinkBytes,
|
|
|
|
type: SharedLinkType.ALBUM,
|
|
|
|
createdAt: today,
|
|
|
|
expiresAt: tomorrow,
|
|
|
|
allowUpload: false,
|
|
|
|
allowDownload: false,
|
|
|
|
showExif: false,
|
|
|
|
description: null,
|
2023-10-29 03:35:38 +02:00
|
|
|
password: null,
|
2023-08-01 03:28:07 +02:00
|
|
|
assets: [],
|
|
|
|
albumId: 'album-123',
|
|
|
|
album: {
|
|
|
|
id: 'album-123',
|
2023-12-10 06:34:12 +02:00
|
|
|
ownerId: authStub.admin.user.id,
|
2023-08-01 03:28:07 +02:00
|
|
|
owner: userStub.admin,
|
|
|
|
albumName: 'Test Album',
|
2023-08-06 04:43:26 +02:00
|
|
|
description: '',
|
2023-08-01 03:28:07 +02:00
|
|
|
createdAt: today,
|
|
|
|
updatedAt: today,
|
2023-09-18 17:56:50 +02:00
|
|
|
deletedAt: null,
|
2023-08-01 03:28:07 +02:00
|
|
|
albumThumbnailAsset: null,
|
|
|
|
albumThumbnailAssetId: null,
|
|
|
|
sharedUsers: [],
|
|
|
|
sharedLinks: [],
|
2023-11-07 06:37:21 +02:00
|
|
|
isActivityEnabled: true,
|
2024-03-14 18:45:03 +02:00
|
|
|
order: AssetOrder.DESC,
|
2023-08-01 03:28:07 +02:00
|
|
|
assets: [
|
|
|
|
{
|
|
|
|
id: 'id_1',
|
2023-09-06 05:14:44 +02:00
|
|
|
owner: undefined as unknown as UserEntity,
|
2023-08-01 03:28:07 +02:00
|
|
|
ownerId: 'user_id_1',
|
|
|
|
deviceAssetId: 'device_asset_id_1',
|
|
|
|
deviceId: 'device_id_1',
|
|
|
|
type: AssetType.VIDEO,
|
|
|
|
originalPath: 'fake_path/jpeg',
|
|
|
|
resizePath: '',
|
|
|
|
checksum: Buffer.from('file hash', 'utf8'),
|
|
|
|
fileModifiedAt: today,
|
|
|
|
fileCreatedAt: today,
|
2023-10-05 00:11:11 +02:00
|
|
|
localDateTime: today,
|
2023-08-01 03:28:07 +02:00
|
|
|
createdAt: today,
|
|
|
|
updatedAt: today,
|
|
|
|
isFavorite: false,
|
|
|
|
isArchived: false,
|
2023-09-20 13:16:33 +02:00
|
|
|
isExternal: false,
|
2023-08-01 03:28:07 +02:00
|
|
|
isReadOnly: false,
|
2023-09-20 13:16:33 +02:00
|
|
|
isOffline: false,
|
|
|
|
libraryId: 'library-id',
|
|
|
|
library: libraryStub.uploadLibrary1,
|
2023-08-01 03:28:07 +02:00
|
|
|
smartInfo: {
|
|
|
|
assetId: 'id_1',
|
|
|
|
tags: [],
|
|
|
|
objects: ['a', 'b', 'c'],
|
|
|
|
asset: null as any,
|
|
|
|
},
|
|
|
|
webpPath: '',
|
|
|
|
thumbhash: null,
|
|
|
|
encodedVideoPath: '',
|
|
|
|
duration: null,
|
|
|
|
isVisible: true,
|
|
|
|
livePhotoVideo: null,
|
|
|
|
livePhotoVideoId: null,
|
|
|
|
originalFileName: 'asset_1.jpeg',
|
|
|
|
exifInfo: {
|
|
|
|
projectionType: null,
|
|
|
|
livePhotoCID: null,
|
|
|
|
assetId: 'id_1',
|
|
|
|
description: 'description',
|
|
|
|
exifImageWidth: 500,
|
|
|
|
exifImageHeight: 500,
|
|
|
|
fileSizeInByte: 100,
|
|
|
|
orientation: 'orientation',
|
|
|
|
dateTimeOriginal: today,
|
|
|
|
modifyDate: today,
|
|
|
|
timeZone: 'America/Los_Angeles',
|
|
|
|
latitude: 100,
|
|
|
|
longitude: 100,
|
|
|
|
city: 'city',
|
|
|
|
state: 'state',
|
|
|
|
country: 'country',
|
|
|
|
make: 'camera-make',
|
|
|
|
model: 'camera-model',
|
|
|
|
lensModel: 'fancy',
|
|
|
|
fNumber: 100,
|
|
|
|
focalLength: 100,
|
|
|
|
iso: 100,
|
|
|
|
exposureTime: '1/16',
|
|
|
|
fps: 100,
|
|
|
|
asset: null as any,
|
|
|
|
exifTextSearchableColumn: '',
|
2023-09-26 01:18:47 +02:00
|
|
|
profileDescription: 'sRGB',
|
|
|
|
bitsPerSample: 8,
|
|
|
|
colorspace: 'sRGB',
|
2024-01-27 20:52:14 +02:00
|
|
|
autoStackId: null,
|
2023-08-01 03:28:07 +02:00
|
|
|
},
|
|
|
|
tags: [],
|
|
|
|
sharedLinks: [],
|
|
|
|
faces: [],
|
|
|
|
sidecarPath: null,
|
2023-10-06 09:01:14 +02:00
|
|
|
deletedAt: null,
|
2023-08-01 03:28:07 +02:00
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
}),
|
2023-10-29 03:35:38 +02:00
|
|
|
passwordRequired: Object.freeze<SharedLinkEntity>({
|
|
|
|
id: '123',
|
2023-12-10 06:34:12 +02:00
|
|
|
userId: authStub.admin.user.id,
|
2023-10-29 03:35:38 +02:00
|
|
|
user: userStub.admin,
|
|
|
|
key: sharedLinkBytes,
|
|
|
|
type: SharedLinkType.ALBUM,
|
|
|
|
createdAt: today,
|
|
|
|
expiresAt: tomorrow,
|
|
|
|
allowUpload: true,
|
|
|
|
allowDownload: true,
|
|
|
|
showExif: true,
|
|
|
|
description: null,
|
|
|
|
password: 'password',
|
|
|
|
assets: [],
|
|
|
|
albumId: null,
|
|
|
|
}),
|
2023-08-01 03:28:07 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
export const sharedLinkResponseStub = {
|
|
|
|
valid: Object.freeze<SharedLinkResponseDto>({
|
|
|
|
allowDownload: true,
|
|
|
|
allowUpload: true,
|
|
|
|
assets: [],
|
|
|
|
createdAt: today,
|
|
|
|
description: null,
|
2023-10-29 03:35:38 +02:00
|
|
|
password: null,
|
2023-08-01 03:28:07 +02:00
|
|
|
expiresAt: tomorrow,
|
|
|
|
id: '123',
|
|
|
|
key: sharedLinkBytes.toString('base64url'),
|
2023-10-14 03:46:30 +02:00
|
|
|
showMetadata: true,
|
2023-08-01 03:28:07 +02:00
|
|
|
type: SharedLinkType.ALBUM,
|
|
|
|
userId: 'admin_id',
|
|
|
|
}),
|
|
|
|
expired: Object.freeze<SharedLinkResponseDto>({
|
|
|
|
album: undefined,
|
|
|
|
allowDownload: true,
|
|
|
|
allowUpload: true,
|
|
|
|
assets: [],
|
|
|
|
createdAt: today,
|
|
|
|
description: null,
|
2023-10-29 03:35:38 +02:00
|
|
|
password: null,
|
2023-08-01 03:28:07 +02:00
|
|
|
expiresAt: yesterday,
|
|
|
|
id: '123',
|
|
|
|
key: sharedLinkBytes.toString('base64url'),
|
2023-10-14 03:46:30 +02:00
|
|
|
showMetadata: true,
|
2023-08-01 03:28:07 +02:00
|
|
|
type: SharedLinkType.ALBUM,
|
|
|
|
userId: 'admin_id',
|
|
|
|
}),
|
|
|
|
readonly: Object.freeze<SharedLinkResponseDto>({
|
|
|
|
id: '123',
|
|
|
|
userId: 'admin_id',
|
|
|
|
key: sharedLinkBytes.toString('base64url'),
|
|
|
|
type: SharedLinkType.ALBUM,
|
|
|
|
createdAt: today,
|
|
|
|
expiresAt: tomorrow,
|
|
|
|
description: null,
|
2023-10-29 03:35:38 +02:00
|
|
|
password: null,
|
2023-08-01 03:28:07 +02:00
|
|
|
allowUpload: false,
|
|
|
|
allowDownload: false,
|
2023-10-14 03:46:30 +02:00
|
|
|
showMetadata: true,
|
2023-08-01 03:28:07 +02:00
|
|
|
album: albumResponse,
|
|
|
|
assets: [assetResponse],
|
|
|
|
}),
|
2023-10-14 03:46:30 +02:00
|
|
|
readonlyNoMetadata: Object.freeze<SharedLinkResponseDto>({
|
2023-08-01 03:28:07 +02:00
|
|
|
id: '123',
|
|
|
|
userId: 'admin_id',
|
|
|
|
key: sharedLinkBytes.toString('base64url'),
|
|
|
|
type: SharedLinkType.ALBUM,
|
|
|
|
createdAt: today,
|
|
|
|
expiresAt: tomorrow,
|
|
|
|
description: null,
|
2023-10-29 03:35:38 +02:00
|
|
|
password: null,
|
2023-08-01 03:28:07 +02:00
|
|
|
allowUpload: false,
|
|
|
|
allowDownload: false,
|
2023-10-14 03:46:30 +02:00
|
|
|
showMetadata: false,
|
2023-08-11 18:00:51 +02:00
|
|
|
album: { ...albumResponse, startDate: assetResponse.fileCreatedAt, endDate: assetResponse.fileCreatedAt },
|
2023-10-14 03:46:30 +02:00
|
|
|
assets: [{ ...assetResponseWithoutMetadata, exifInfo: undefined }],
|
2023-08-01 03:28:07 +02:00
|
|
|
}),
|
|
|
|
};
|