chore(server): remove unused code (#13367)

This commit is contained in:
Jason Rasmussen
2024-10-11 00:44:38 -04:00
committed by GitHub
parent 8daa8073ae
commit 930df46f74
26 changed files with 34 additions and 415 deletions

View File

@@ -155,55 +155,4 @@ export const albumStub = {
isActivityEnabled: true,
order: AssetOrder.DESC,
}),
emptyWithInvalidThumbnail: Object.freeze<AlbumEntity>({
id: 'album-5',
albumName: 'Empty album with invalid thumbnail',
description: '',
ownerId: authStub.admin.user.id,
owner: userStub.admin,
assets: [],
albumThumbnailAsset: null,
albumThumbnailAssetId: null,
createdAt: new Date(),
updatedAt: new Date(),
deletedAt: null,
sharedLinks: [],
albumUsers: [],
isActivityEnabled: true,
order: AssetOrder.DESC,
}),
oneAssetInvalidThumbnail: Object.freeze<AlbumEntity>({
id: 'album-6',
albumName: 'Album with one asset and invalid thumbnail',
description: '',
ownerId: authStub.admin.user.id,
owner: userStub.admin,
assets: [assetStub.image],
albumThumbnailAsset: assetStub.livePhotoMotionAsset,
albumThumbnailAssetId: assetStub.livePhotoMotionAsset.id,
createdAt: new Date(),
updatedAt: new Date(),
deletedAt: null,
sharedLinks: [],
albumUsers: [],
isActivityEnabled: true,
order: AssetOrder.DESC,
}),
oneAssetValidThumbnail: Object.freeze<AlbumEntity>({
id: 'album-6',
albumName: 'Album with one asset and invalid thumbnail',
description: '',
ownerId: authStub.admin.user.id,
owner: userStub.admin,
assets: [assetStub.image],
albumThumbnailAsset: assetStub.image,
albumThumbnailAssetId: assetStub.image.id,
createdAt: new Date(),
updatedAt: new Date(),
deletedAt: null,
sharedLinks: [],
albumUsers: [],
isActivityEnabled: true,
order: AssetOrder.DESC,
}),
};

View File

@@ -11,7 +11,3 @@ export const keyStub = {
user: userStub.admin,
} as APIKeyEntity),
};
export const apiKeyCreateStub = {
name: 'API Key',
};

View File

@@ -523,37 +523,6 @@ export const assetStub = {
},
} as AssetEntity),
liveMotionWithThumb: Object.freeze({
id: fileStub.livePhotoMotion.uuid,
status: AssetStatus.ACTIVE,
originalPath: fileStub.livePhotoMotion.originalPath,
ownerId: authStub.user1.user.id,
type: AssetType.VIDEO,
isVisible: false,
fileModifiedAt: new Date('2022-06-19T23:41:36.910Z'),
fileCreatedAt: new Date('2022-06-19T23:41:36.910Z'),
files: [
{
assetId: 'asset-id',
type: AssetFileType.PREVIEW,
path: '/uploads/user-id/thumbs/path.ext',
createdAt: new Date('2023-02-23T05:06:29.716Z'),
updatedAt: new Date('2023-02-23T05:06:29.716Z'),
},
{
assetId: 'asset-id',
type: AssetFileType.THUMBNAIL,
path: '/uploads/user-id/webp/path.ext',
createdAt: new Date('2023-02-23T05:06:29.716Z'),
updatedAt: new Date('2023-02-23T05:06:29.716Z'),
},
],
exifInfo: {
fileSizeInByte: 100_000,
timeZone: `America/New_York`,
},
} as AssetEntity),
livePhotoStillAsset: Object.freeze({
id: 'live-photo-still-asset',
status: AssetStatus.ACTIVE,
@@ -570,22 +539,6 @@ export const assetStub = {
},
} as AssetEntity),
livePhotoStillAssetWithTheSameLivePhotoMotionAsset: Object.freeze({
id: 'live-photo-still-asset-1',
status: AssetStatus.ACTIVE,
originalPath: fileStub.livePhotoStill.originalPath,
ownerId: authStub.user1.user.id,
type: AssetType.IMAGE,
livePhotoVideoId: 'live-photo-motion-asset',
isVisible: true,
fileModifiedAt: new Date('2022-06-19T23:41:36.910Z'),
fileCreatedAt: new Date('2022-06-19T23:41:36.910Z'),
exifInfo: {
fileSizeInByte: 25_000,
timeZone: `America/New_York`,
},
} as AssetEntity),
livePhotoWithOriginalFileName: Object.freeze({
id: 'live-photo-still-asset',
status: AssetStatus.ACTIVE,
@@ -645,6 +598,7 @@ export const assetStub = {
duplicateId: null,
isOffline: false,
}),
sidecar: Object.freeze<AssetEntity>({
id: 'asset-id',
status: AssetStatus.ACTIVE,
@@ -679,6 +633,7 @@ export const assetStub = {
duplicateId: null,
isOffline: false,
}),
sidecarWithoutExt: Object.freeze<AssetEntity>({
id: 'asset-id',
status: AssetStatus.ACTIVE,
@@ -751,45 +706,7 @@ export const assetStub = {
duplicateId: null,
isOffline: false,
}),
missingFileExtension: Object.freeze<AssetEntity>({
id: 'asset-id',
status: AssetStatus.ACTIVE,
deviceAssetId: 'device-asset-id',
fileModifiedAt: new Date('2023-02-23T05:06:29.716Z'),
fileCreatedAt: new Date('2023-02-23T05:06:29.716Z'),
owner: userStub.user1,
ownerId: 'user-id',
deviceId: 'device-id',
originalPath: '/data/user1/photo.jpg',
checksum: Buffer.from('file hash', 'utf8'),
type: AssetType.IMAGE,
files,
thumbhash: Buffer.from('blablabla', 'base64'),
encodedVideoPath: null,
createdAt: new Date('2023-02-23T05:06:29.716Z'),
updatedAt: new Date('2023-02-23T05:06:29.716Z'),
localDateTime: new Date('2023-02-23T05:06:29.716Z'),
isFavorite: true,
isArchived: false,
isExternal: true,
duration: null,
isVisible: true,
livePhotoVideo: null,
livePhotoVideoId: null,
libraryId: 'library-id',
library: libraryStub.externalLibrary1,
tags: [],
sharedLinks: [],
originalFileName: 'photo',
faces: [],
deletedAt: null,
sidecarPath: null,
exifInfo: {
fileSizeInByte: 5000,
} as ExifEntity,
duplicateId: null,
isOffline: false,
}),
hasFileExtension: Object.freeze<AssetEntity>({
id: 'asset-id',
status: AssetStatus.ACTIVE,
@@ -829,6 +746,7 @@ export const assetStub = {
duplicateId: null,
isOffline: false,
}),
imageDng: Object.freeze<AssetEntity>({
id: 'asset-id',
status: AssetStatus.ACTIVE,
@@ -868,6 +786,7 @@ export const assetStub = {
duplicateId: null,
isOffline: false,
}),
hasEmbedding: Object.freeze<AssetEntity>({
id: 'asset-id-embedding',
status: AssetStatus.ACTIVE,
@@ -909,6 +828,7 @@ export const assetStub = {
},
isOffline: false,
}),
hasDupe: Object.freeze<AssetEntity>({
id: 'asset-id-dupe',
status: AssetStatus.ACTIVE,

View File

@@ -3,22 +3,6 @@ import { DatabaseAction, EntityType } from 'src/enum';
import { authStub } from 'test/fixtures/auth.stub';
export const auditStub = {
create: Object.freeze<AuditEntity>({
id: 1,
entityId: 'asset-created',
action: DatabaseAction.CREATE,
entityType: EntityType.ASSET,
ownerId: authStub.admin.user.id,
createdAt: new Date(),
}),
update: Object.freeze<AuditEntity>({
id: 2,
entityId: 'asset-updated',
action: DatabaseAction.UPDATE,
entityType: EntityType.ASSET,
ownerId: authStub.admin.user.id,
createdAt: new Date(),
}),
delete: Object.freeze<AuditEntity>({
id: 3,
entityId: 'asset-deleted',

View File

@@ -35,17 +35,6 @@ export const authStub = {
id: 'token-id',
} as SessionEntity,
}),
external1: Object.freeze<AuthDto>({
user: {
id: 'user-id',
email: 'immich@test.com',
isAdmin: false,
metadata: [] as UserMetadataEntity[],
} as UserEntity,
session: {
id: 'token-id',
} as SessionEntity,
}),
adminSharedLink: Object.freeze<AuthDto>({
user: {
id: 'admin_id',
@@ -76,20 +65,6 @@ export const authStub = {
key: Buffer.from('shared-link-key'),
} as SharedLinkEntity,
}),
readonlySharedLink: Object.freeze<AuthDto>({
user: {
id: 'admin_id',
email: 'admin@test.com',
isAdmin: true,
metadata: [] as UserMetadataEntity[],
} as UserEntity,
sharedLink: {
id: '123',
allowUpload: false,
allowDownload: false,
showExif: true,
} as SharedLinkEntity,
}),
passwordSharedLink: Object.freeze<AuthDto>({
user: {
id: 'admin_id',
@@ -106,35 +81,3 @@ export const authStub = {
} as SharedLinkEntity,
}),
};
export const loginResponseStub = {
admin: {
response: {
accessToken: expect.any(String),
name: 'Immich Admin',
isAdmin: true,
profileImagePath: '',
shouldChangePassword: true,
userEmail: 'admin@immich.app',
userId: expect.any(String),
},
},
user1oauth: {
accessToken: 'cmFuZG9tLWJ5dGVz',
userId: 'user-id',
userEmail: 'immich@test.com',
name: 'immich_name',
profileImagePath: '',
isAdmin: false,
shouldChangePassword: false,
},
user1password: {
accessToken: 'cmFuZG9tLWJ5dGVz',
userId: 'user-id',
userEmail: 'immich@test.com',
name: 'immich_name',
profileImagePath: '',
isAdmin: false,
shouldChangePassword: false,
},
};

View File

@@ -51,21 +51,6 @@ export const faceStub = {
sourceType: SourceType.MACHINE_LEARNING,
faceSearch: { faceId: 'assetFaceId3', embedding: [1, 2, 3, 4] },
}),
mergeFace2: Object.freeze<NonNullableProperty<AssetFaceEntity>>({
id: 'assetFaceId4',
assetId: assetStub.image1.id,
asset: assetStub.image1,
personId: personStub.mergePerson.id,
person: personStub.mergePerson,
boundingBoxX1: 0,
boundingBoxY1: 0,
boundingBoxX2: 1,
boundingBoxY2: 1,
imageHeight: 1024,
imageWidth: 1024,
sourceType: SourceType.MACHINE_LEARNING,
faceSearch: { faceId: 'assetFaceId4', embedding: [1, 2, 3, 4] },
}),
start: Object.freeze<NonNullableProperty<AssetFaceEntity>>({
id: 'assetFaceId5',
assetId: assetStub.image.id,

View File

@@ -1,6 +1,3 @@
import { join } from 'node:path';
import { APP_MEDIA_LOCATION } from 'src/constants';
import { THUMBNAIL_DIR } from 'src/cores/storage.core';
import { LibraryEntity } from 'src/entities/library.entity';
import { userStub } from 'test/fixtures/user.stub';
@@ -53,18 +50,6 @@ export const libraryStub = {
refreshedAt: null,
exclusionPatterns: [],
}),
externalLibraryWithExclusionPattern: Object.freeze<LibraryEntity>({
id: 'library-id',
name: 'test_library',
assets: [],
owner: userStub.admin,
ownerId: 'user-id',
importPaths: [],
createdAt: new Date('2023-01-01'),
updatedAt: new Date('2023-01-01'),
refreshedAt: null,
exclusionPatterns: ['**/dir1/**'],
}),
patternPath: Object.freeze<LibraryEntity>({
id: 'library-id1337',
name: 'importpath-exclusion-library1',
@@ -83,7 +68,7 @@ export const libraryStub = {
assets: [],
owner: userStub.admin,
ownerId: 'user-id',
importPaths: [join(THUMBNAIL_DIR, 'library'), '/xyz', join(APP_MEDIA_LOCATION, 'library')],
importPaths: ['upload/thumbs', '/xyz', 'upload/library'],
createdAt: new Date('2023-01-01'),
updatedAt: new Date('2023-01-01'),
refreshedAt: null,

View File

@@ -44,20 +44,6 @@ export const personStub = {
faceAsset: null,
isHidden: false,
}),
noBirthDate: Object.freeze<PersonEntity>({
id: 'person-1',
createdAt: new Date('2021-01-01'),
updatedAt: new Date('2021-01-01'),
ownerId: userStub.admin.id,
owner: userStub.admin,
name: 'Person 1',
birthDate: null,
thumbnailPath: '/path/to/thumbnail.jpg',
faces: [],
faceAssetId: null,
faceAsset: null,
isHidden: false,
}),
withBirthDate: Object.freeze<PersonEntity>({
id: 'person-1',
createdAt: new Date('2021-01-01'),

View File

@@ -309,21 +309,6 @@ export const sharedLinkResponseStub = {
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,
password: null,
allowUpload: false,
allowDownload: false,
showMetadata: true,
album: albumResponse,
assets: [assetResponse],
}),
readonlyNoMetadata: Object.freeze<SharedLinkResponseDto>({
id: '123',
userId: 'admin_id',

View File

@@ -2,30 +2,6 @@ import { UserEntity } from 'src/entities/user.entity';
import { UserAvatarColor, UserMetadataKey } from 'src/enum';
import { authStub } from 'test/fixtures/auth.stub';
export const userDto = {
user1: {
email: 'user1@immich.app',
password: 'Password123',
name: 'User 1',
},
user2: {
email: 'user2@immich.app',
password: 'Password123',
name: 'User 2',
},
user3: {
email: 'user3@immich.app',
password: 'Password123',
name: 'User 3',
},
userWithQuota: {
email: 'quota-user@immich.app',
password: 'Password123',
name: 'User with quota',
quotaSizeInBytes: 42,
},
};
export const userStub = {
admin: Object.freeze<UserEntity>({
...authStub.admin.user,
@@ -100,22 +76,6 @@ export const userStub = {
quotaSizeInBytes: null,
quotaUsageInBytes: 0,
}),
externalPathRoot: Object.freeze<UserEntity>({
...authStub.user1.user,
password: 'immich_password',
name: 'immich_name',
storageLabel: 'label-1',
oauthId: '',
shouldChangePassword: false,
profileImagePath: '',
createdAt: new Date('2021-01-01'),
deletedAt: null,
updatedAt: new Date('2021-01-01'),
tags: [],
assets: [],
quotaSizeInBytes: null,
quotaUsageInBytes: 0,
}),
profilePath: Object.freeze<UserEntity>({
...authStub.user1.user,
password: 'immich_password',

View File

@@ -17,7 +17,6 @@ export const newAssetRepositoryMock = (): Mocked<IAssetRepository> => {
getByChecksum: vitest.fn(),
getByChecksums: vitest.fn(),
getUploadAssetIdByChecksum: vitest.fn(),
getWith: vitest.fn(),
getRandom: vitest.fn(),
getLastUpdatedAssetForAlbumId: vitest.fn(),
getAll: vitest.fn().mockResolvedValue({ items: [], hasNextPage: false }),

View File

@@ -9,7 +9,6 @@ export const newDatabaseRepositoryMock = (): Mocked<IDatabaseRepository> => {
getPostgresVersion: vitest.fn().mockResolvedValue('14.10 (Debian 14.10-1.pgdg120+1)'),
getPostgresVersionRange: vitest.fn().mockReturnValue('>=14.0.0'),
createExtension: vitest.fn().mockResolvedValue(void 0),
updateExtension: vitest.fn(),
updateVectorExtension: vitest.fn(),
reindex: vitest.fn(),
shouldReindex: vitest.fn(),

View File

@@ -6,6 +6,5 @@ export const newMapRepositoryMock = (): Mocked<IMapRepository> => {
init: vitest.fn(),
reverseGeocode: vitest.fn(),
getMapMarkers: vitest.fn(),
fetchStyle: vitest.fn(),
};
};

View File

@@ -16,7 +16,6 @@ export const newPersonRepositoryMock = (): Mocked<IPersonRepository> => {
update: vitest.fn(),
updateAll: vitest.fn(),
delete: vitest.fn(),
deleteAll: vitest.fn(),
deleteFaces: vitest.fn(),
getStatistics: vitest.fn(),
@@ -26,7 +25,6 @@ export const newPersonRepositoryMock = (): Mocked<IPersonRepository> => {
reassignFaces: vitest.fn(),
unassignFaces: vitest.fn(),
createFaces: vitest.fn(),
refreshFaces: vitest.fn(),
getFaces: vitest.fn(),
reassignFace: vitest.fn(),