feat(server): improve and refactor get all albums (#2048)

Co-authored-by: Alex Tran <alex.tran1502@gmail.com>
This commit is contained in:
Michel Heusschen
2023-03-26 04:46:48 +02:00
committed by GitHub
parent 2400004f41
commit c74fba483d
23 changed files with 1027 additions and 752 deletions

View File

@@ -3,6 +3,12 @@ import { IAlbumRepository } from '../src';
export const newAlbumRepositoryMock = (): jest.Mocked<IAlbumRepository> => {
return {
getByIds: jest.fn(),
getByAssetId: jest.fn(),
getAssetCountForIds: jest.fn(),
getInvalidThumbnail: jest.fn(),
getOwned: jest.fn(),
getShared: jest.fn(),
getNotShared: jest.fn(),
deleteAll: jest.fn(),
getAll: jest.fn(),
save: jest.fn(),

View File

@@ -4,6 +4,7 @@ export const newAssetRepositoryMock = (): jest.Mocked<IAssetRepository> => {
return {
getByIds: jest.fn(),
getWithout: jest.fn(),
getFirstAssetForAlbumId: jest.fn(),
getAll: jest.fn(),
deleteAll: jest.fn(),
save: jest.fn(),

View File

@@ -219,6 +219,97 @@ export const albumStub = {
sharedLinks: [],
sharedUsers: [],
}),
sharedWithUser: Object.freeze<AlbumEntity>({
id: 'album-2',
albumName: 'Empty album shared with user',
ownerId: authStub.admin.id,
owner: userEntityStub.admin,
assets: [],
albumThumbnailAsset: null,
albumThumbnailAssetId: null,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
sharedLinks: [],
sharedUsers: [userEntityStub.user1],
}),
sharedWithAdmin: Object.freeze<AlbumEntity>({
id: 'album-3',
albumName: 'Empty album shared with admin',
ownerId: authStub.user1.id,
owner: userEntityStub.user1,
assets: [],
albumThumbnailAsset: null,
albumThumbnailAssetId: null,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
sharedLinks: [],
sharedUsers: [userEntityStub.admin],
}),
oneAsset: Object.freeze<AlbumEntity>({
id: 'album-4',
albumName: 'Album with one asset',
ownerId: authStub.admin.id,
owner: userEntityStub.admin,
assets: [assetEntityStub.image],
albumThumbnailAsset: null,
albumThumbnailAssetId: null,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
sharedLinks: [],
sharedUsers: [],
}),
emptyWithInvalidThumbnail: Object.freeze<AlbumEntity>({
id: 'album-5',
albumName: 'Empty album with invalid thumbnail',
ownerId: authStub.admin.id,
owner: userEntityStub.admin,
assets: [],
albumThumbnailAsset: assetEntityStub.image,
albumThumbnailAssetId: assetEntityStub.image.id,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
sharedLinks: [],
sharedUsers: [],
}),
emptyWithValidThumbnail: Object.freeze<AlbumEntity>({
id: 'album-5',
albumName: 'Empty album with invalid thumbnail',
ownerId: authStub.admin.id,
owner: userEntityStub.admin,
assets: [],
albumThumbnailAsset: null,
albumThumbnailAssetId: null,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
sharedLinks: [],
sharedUsers: [],
}),
oneAssetInvalidThumbnail: Object.freeze<AlbumEntity>({
id: 'album-6',
albumName: 'Album with one asset and invalid thumbnail',
ownerId: authStub.admin.id,
owner: userEntityStub.admin,
assets: [assetEntityStub.image],
albumThumbnailAsset: assetEntityStub.livePhotoMotionAsset,
albumThumbnailAssetId: assetEntityStub.livePhotoMotionAsset.id,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
sharedLinks: [],
sharedUsers: [],
}),
oneAssetValidThumbnail: Object.freeze<AlbumEntity>({
id: 'album-6',
albumName: 'Album with one asset and invalid thumbnail',
ownerId: authStub.admin.id,
owner: userEntityStub.admin,
assets: [assetEntityStub.image],
albumThumbnailAsset: assetEntityStub.image,
albumThumbnailAssetId: assetEntityStub.image.id,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
sharedLinks: [],
sharedUsers: [],
}),
};
const assetInfo: ExifResponseDto = {