mirror of
https://github.com/immich-app/immich.git
synced 2025-01-01 08:31:59 +00:00
chore(server): remove unused code (#13367)
This commit is contained in:
parent
8daa8073ae
commit
930df46f74
26 changed files with 34 additions and 415 deletions
|
@ -15,9 +15,6 @@ import { ISystemMetadataRepository } from 'src/interfaces/system-metadata.interf
|
||||||
import { getAssetFiles } from 'src/utils/asset.util';
|
import { getAssetFiles } from 'src/utils/asset.util';
|
||||||
import { getConfig } from 'src/utils/config';
|
import { getConfig } from 'src/utils/config';
|
||||||
|
|
||||||
export const THUMBNAIL_DIR = resolve(join(APP_MEDIA_LOCATION, StorageFolder.THUMBNAILS));
|
|
||||||
export const ENCODED_VIDEO_DIR = resolve(join(APP_MEDIA_LOCATION, StorageFolder.ENCODED_VIDEO));
|
|
||||||
|
|
||||||
export interface MoveRequest {
|
export interface MoveRequest {
|
||||||
entityId: string;
|
entityId: string;
|
||||||
pathType: PathType;
|
pathType: PathType;
|
||||||
|
@ -118,10 +115,6 @@ export class StorageCore {
|
||||||
return normalizedPath.startsWith(normalizedAppMediaLocation);
|
return normalizedPath.startsWith(normalizedAppMediaLocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
static isGeneratedAsset(path: string) {
|
|
||||||
return path.startsWith(THUMBNAIL_DIR) || path.startsWith(ENCODED_VIDEO_DIR);
|
|
||||||
}
|
|
||||||
|
|
||||||
async moveAssetImage(asset: AssetEntity, pathType: GeneratedImageType, format: ImageFormat) {
|
async moveAssetImage(asset: AssetEntity, pathType: GeneratedImageType, format: ImageFormat) {
|
||||||
const { id: entityId, files } = asset;
|
const { id: entityId, files } = asset;
|
||||||
const { thumbnailFile, previewFile } = getAssetFiles(files);
|
const { thumbnailFile, previewFile } = getAssetFiles(files);
|
||||||
|
|
|
@ -172,12 +172,6 @@ export interface IAssetRepository {
|
||||||
order?: FindOptionsOrder<AssetEntity>,
|
order?: FindOptionsOrder<AssetEntity>,
|
||||||
): Promise<AssetEntity | null>;
|
): Promise<AssetEntity | null>;
|
||||||
getWithout(pagination: PaginationOptions, property: WithoutProperty): Paginated<AssetEntity>;
|
getWithout(pagination: PaginationOptions, property: WithoutProperty): Paginated<AssetEntity>;
|
||||||
getWith(
|
|
||||||
pagination: PaginationOptions,
|
|
||||||
property: WithProperty,
|
|
||||||
libraryId?: string,
|
|
||||||
withDeleted?: boolean,
|
|
||||||
): Paginated<AssetEntity>;
|
|
||||||
getRandom(userIds: string[], count: number): Promise<AssetEntity[]>;
|
getRandom(userIds: string[], count: number): Promise<AssetEntity[]>;
|
||||||
getLastUpdatedAssetForAlbumId(albumId: string): Promise<AssetEntity | null>;
|
getLastUpdatedAssetForAlbumId(albumId: string): Promise<AssetEntity | null>;
|
||||||
getByLibraryIdAndOriginalPath(libraryId: string, originalPath: string): Promise<AssetEntity | null>;
|
getByLibraryIdAndOriginalPath(libraryId: string, originalPath: string): Promise<AssetEntity | null>;
|
||||||
|
|
|
@ -48,7 +48,6 @@ export interface IDatabaseRepository {
|
||||||
getPostgresVersion(): Promise<string>;
|
getPostgresVersion(): Promise<string>;
|
||||||
getPostgresVersionRange(): string;
|
getPostgresVersionRange(): string;
|
||||||
createExtension(extension: DatabaseExtension): Promise<void>;
|
createExtension(extension: DatabaseExtension): Promise<void>;
|
||||||
updateExtension(extension: DatabaseExtension, version?: string): Promise<void>;
|
|
||||||
updateVectorExtension(extension: VectorExtension, version?: string): Promise<VectorUpdateResult>;
|
updateVectorExtension(extension: VectorExtension, version?: string): Promise<VectorUpdateResult>;
|
||||||
reindex(index: VectorIndex): Promise<void>;
|
reindex(index: VectorIndex): Promise<void>;
|
||||||
shouldReindex(name: VectorIndex): Promise<boolean>;
|
shouldReindex(name: VectorIndex): Promise<boolean>;
|
||||||
|
|
|
@ -28,5 +28,4 @@ export interface IMapRepository {
|
||||||
init(): Promise<void>;
|
init(): Promise<void>;
|
||||||
reverseGeocode(point: GeoPoint): Promise<ReverseGeocodeResult>;
|
reverseGeocode(point: GeoPoint): Promise<ReverseGeocodeResult>;
|
||||||
getMapMarkers(ownerIds: string[], albumIds: string[], options?: MapMarkerSearchOptions): Promise<MapMarker[]>;
|
getMapMarkers(ownerIds: string[], albumIds: string[], options?: MapMarkerSearchOptions): Promise<MapMarker[]>;
|
||||||
fetchStyle(url: string): Promise<any>;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,9 +57,7 @@ export interface IPersonRepository {
|
||||||
|
|
||||||
create(person: Partial<PersonEntity>): Promise<PersonEntity>;
|
create(person: Partial<PersonEntity>): Promise<PersonEntity>;
|
||||||
createAll(people: Partial<PersonEntity>[]): Promise<string[]>;
|
createAll(people: Partial<PersonEntity>[]): Promise<string[]>;
|
||||||
createFaces(entities: Partial<AssetFaceEntity>[]): Promise<string[]>;
|
|
||||||
delete(entities: PersonEntity[]): Promise<void>;
|
delete(entities: PersonEntity[]): Promise<void>;
|
||||||
deleteAll(): Promise<void>;
|
|
||||||
deleteFaces(options: DeleteFacesOptions): Promise<void>;
|
deleteFaces(options: DeleteFacesOptions): Promise<void>;
|
||||||
refreshFaces(
|
refreshFaces(
|
||||||
facesToAdd: Partial<AssetFaceEntity>[],
|
facesToAdd: Partial<AssetFaceEntity>[],
|
||||||
|
|
|
@ -499,39 +499,6 @@ export class AssetRepository implements IAssetRepository {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getWith(
|
|
||||||
pagination: PaginationOptions,
|
|
||||||
property: WithProperty,
|
|
||||||
libraryId?: string,
|
|
||||||
withDeleted = false,
|
|
||||||
): Paginated<AssetEntity> {
|
|
||||||
let where: FindOptionsWhere<AssetEntity> | FindOptionsWhere<AssetEntity>[] = {};
|
|
||||||
|
|
||||||
switch (property) {
|
|
||||||
case WithProperty.SIDECAR: {
|
|
||||||
where = [{ sidecarPath: Not(IsNull()), isVisible: true }];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
default: {
|
|
||||||
throw new Error(`Invalid getWith property: ${property}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (libraryId) {
|
|
||||||
where = [{ ...where, libraryId }];
|
|
||||||
}
|
|
||||||
|
|
||||||
return paginate(this.repository, pagination, {
|
|
||||||
where,
|
|
||||||
withDeleted,
|
|
||||||
order: {
|
|
||||||
// Ensures correct order when paginating
|
|
||||||
createdAt: 'ASC',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
getLastUpdatedAssetForAlbumId(albumId: string): Promise<AssetEntity | null> {
|
getLastUpdatedAssetForAlbumId(albumId: string): Promise<AssetEntity | null> {
|
||||||
return this.repository.findOne({
|
return this.repository.findOne({
|
||||||
where: { albums: { id: albumId } },
|
where: { albums: { id: albumId } },
|
||||||
|
|
|
@ -74,10 +74,6 @@ export class DatabaseRepository implements IDatabaseRepository {
|
||||||
await this.dataSource.query(`CREATE EXTENSION IF NOT EXISTS ${extension}`);
|
await this.dataSource.query(`CREATE EXTENSION IF NOT EXISTS ${extension}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
async updateExtension(extension: DatabaseExtension, version?: string): Promise<void> {
|
|
||||||
await this.dataSource.query(`ALTER EXTENSION ${extension} UPDATE${version ? ` TO '${version}'` : ''}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
async updateVectorExtension(extension: VectorExtension, targetVersion?: string): Promise<VectorUpdateResult> {
|
async updateVectorExtension(extension: VectorExtension, targetVersion?: string): Promise<VectorUpdateResult> {
|
||||||
const { availableVersion, installedVersion } = await this.getExtensionVersion(extension);
|
const { availableVersion, installedVersion } = await this.getExtensionVersion(extension);
|
||||||
if (!installedVersion) {
|
if (!installedVersion) {
|
||||||
|
|
|
@ -113,20 +113,6 @@ export class MapRepository implements IMapRepository {
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
async fetchStyle(url: string) {
|
|
||||||
try {
|
|
||||||
const response = await fetch(url);
|
|
||||||
|
|
||||||
if (!response.ok) {
|
|
||||||
throw new Error(`Failed to fetch data from ${url} with status ${response.status}: ${await response.text()}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
return response.json();
|
|
||||||
} catch (error) {
|
|
||||||
throw new Error(`Failed to fetch data from ${url}: ${error}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async reverseGeocode(point: GeoPoint): Promise<ReverseGeocodeResult> {
|
async reverseGeocode(point: GeoPoint): Promise<ReverseGeocodeResult> {
|
||||||
this.logger.debug(`Request: ${point.latitude},${point.longitude}`);
|
this.logger.debug(`Request: ${point.latitude},${point.longitude}`);
|
||||||
|
|
||||||
|
|
|
@ -63,10 +63,6 @@ export class PersonRepository implements IPersonRepository {
|
||||||
await this.personRepository.remove(entities);
|
await this.personRepository.remove(entities);
|
||||||
}
|
}
|
||||||
|
|
||||||
async deleteAll(): Promise<void> {
|
|
||||||
await this.personRepository.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
async deleteFaces({ sourceType }: DeleteFacesOptions): Promise<void> {
|
async deleteFaces({ sourceType }: DeleteFacesOptions): Promise<void> {
|
||||||
await this.assetFaceRepository
|
await this.assetFaceRepository
|
||||||
.createQueryBuilder('asset_faces')
|
.createQueryBuilder('asset_faces')
|
||||||
|
@ -269,11 +265,6 @@ export class PersonRepository implements IPersonRepository {
|
||||||
return results.map((person) => person.id);
|
return results.map((person) => person.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
async createFaces(entities: AssetFaceEntity[]): Promise<string[]> {
|
|
||||||
const res = await this.assetFaceRepository.save(entities);
|
|
||||||
return res.map((row) => row.id);
|
|
||||||
}
|
|
||||||
|
|
||||||
async refreshFaces(
|
async refreshFaces(
|
||||||
facesToAdd: Partial<AssetFaceEntity>[],
|
facesToAdd: Partial<AssetFaceEntity>[],
|
||||||
faceIdsToRemove: string[],
|
faceIdsToRemove: string[],
|
||||||
|
|
|
@ -13,7 +13,7 @@ import { ISystemMetadataRepository } from 'src/interfaces/system-metadata.interf
|
||||||
import { IUserRepository } from 'src/interfaces/user.interface';
|
import { IUserRepository } from 'src/interfaces/user.interface';
|
||||||
import { AuthService } from 'src/services/auth.service';
|
import { AuthService } from 'src/services/auth.service';
|
||||||
import { keyStub } from 'test/fixtures/api-key.stub';
|
import { keyStub } from 'test/fixtures/api-key.stub';
|
||||||
import { authStub, loginResponseStub } from 'test/fixtures/auth.stub';
|
import { authStub } from 'test/fixtures/auth.stub';
|
||||||
import { sessionStub } from 'test/fixtures/session.stub';
|
import { sessionStub } from 'test/fixtures/session.stub';
|
||||||
import { sharedLinkStub } from 'test/fixtures/shared-link.stub';
|
import { sharedLinkStub } from 'test/fixtures/shared-link.stub';
|
||||||
import { systemConfigStub } from 'test/fixtures/system-config.stub';
|
import { systemConfigStub } from 'test/fixtures/system-config.stub';
|
||||||
|
@ -21,6 +21,16 @@ import { userStub } from 'test/fixtures/user.stub';
|
||||||
import { newTestService } from 'test/utils';
|
import { newTestService } from 'test/utils';
|
||||||
import { Mocked } from 'vitest';
|
import { Mocked } from 'vitest';
|
||||||
|
|
||||||
|
const oauthResponse = {
|
||||||
|
accessToken: 'cmFuZG9tLWJ5dGVz',
|
||||||
|
userId: 'user-id',
|
||||||
|
userEmail: 'immich@test.com',
|
||||||
|
name: 'immich_name',
|
||||||
|
profileImagePath: '',
|
||||||
|
isAdmin: false,
|
||||||
|
shouldChangePassword: false,
|
||||||
|
};
|
||||||
|
|
||||||
// const token = Buffer.from('my-api-key', 'utf8').toString('base64');
|
// const token = Buffer.from('my-api-key', 'utf8').toString('base64');
|
||||||
|
|
||||||
const email = 'test@immich.com';
|
const email = 'test@immich.com';
|
||||||
|
@ -100,7 +110,15 @@ describe('AuthService', () => {
|
||||||
it('should successfully log the user in', async () => {
|
it('should successfully log the user in', async () => {
|
||||||
userMock.getByEmail.mockResolvedValue(userStub.user1);
|
userMock.getByEmail.mockResolvedValue(userStub.user1);
|
||||||
sessionMock.create.mockResolvedValue(sessionStub.valid);
|
sessionMock.create.mockResolvedValue(sessionStub.valid);
|
||||||
await expect(sut.login(fixtures.login, loginDetails)).resolves.toEqual(loginResponseStub.user1password);
|
await expect(sut.login(fixtures.login, loginDetails)).resolves.toEqual({
|
||||||
|
accessToken: 'cmFuZG9tLWJ5dGVz',
|
||||||
|
userId: 'user-id',
|
||||||
|
userEmail: 'immich@test.com',
|
||||||
|
name: 'immich_name',
|
||||||
|
profileImagePath: '',
|
||||||
|
isAdmin: false,
|
||||||
|
shouldChangePassword: false,
|
||||||
|
});
|
||||||
expect(userMock.getByEmail).toHaveBeenCalledTimes(1);
|
expect(userMock.getByEmail).toHaveBeenCalledTimes(1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -469,7 +487,7 @@ describe('AuthService', () => {
|
||||||
sessionMock.create.mockResolvedValue(sessionStub.valid);
|
sessionMock.create.mockResolvedValue(sessionStub.valid);
|
||||||
|
|
||||||
await expect(sut.callback({ url: 'http://immich/auth/login?code=abc123' }, loginDetails)).resolves.toEqual(
|
await expect(sut.callback({ url: 'http://immich/auth/login?code=abc123' }, loginDetails)).resolves.toEqual(
|
||||||
loginResponseStub.user1oauth,
|
oauthResponse,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(userMock.getByEmail).toHaveBeenCalledTimes(1);
|
expect(userMock.getByEmail).toHaveBeenCalledTimes(1);
|
||||||
|
@ -498,7 +516,7 @@ describe('AuthService', () => {
|
||||||
sessionMock.create.mockResolvedValue(sessionStub.valid);
|
sessionMock.create.mockResolvedValue(sessionStub.valid);
|
||||||
|
|
||||||
await expect(sut.callback({ url: 'http://immich/auth/login?code=abc123' }, loginDetails)).resolves.toEqual(
|
await expect(sut.callback({ url: 'http://immich/auth/login?code=abc123' }, loginDetails)).resolves.toEqual(
|
||||||
loginResponseStub.user1oauth,
|
oauthResponse,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(userMock.getByEmail).toHaveBeenCalledTimes(2); // second call is for domain check before create
|
expect(userMock.getByEmail).toHaveBeenCalledTimes(2); // second call is for domain check before create
|
||||||
|
@ -546,7 +564,7 @@ describe('AuthService', () => {
|
||||||
userMock.create.mockResolvedValue(userStub.user1);
|
userMock.create.mockResolvedValue(userStub.user1);
|
||||||
|
|
||||||
await expect(sut.callback({ url: 'http://immich/auth/login?code=abc123' }, loginDetails)).resolves.toEqual(
|
await expect(sut.callback({ url: 'http://immich/auth/login?code=abc123' }, loginDetails)).resolves.toEqual(
|
||||||
loginResponseStub.user1oauth,
|
oauthResponse,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(userMock.create).toHaveBeenCalledWith(oauthUserWithDefaultQuota);
|
expect(userMock.create).toHaveBeenCalledWith(oauthUserWithDefaultQuota);
|
||||||
|
@ -560,7 +578,7 @@ describe('AuthService', () => {
|
||||||
oauthMock.getProfile.mockResolvedValue({ sub, email, immich_quota: 'abc' });
|
oauthMock.getProfile.mockResolvedValue({ sub, email, immich_quota: 'abc' });
|
||||||
|
|
||||||
await expect(sut.callback({ url: 'http://immich/auth/login?code=abc123' }, loginDetails)).resolves.toEqual(
|
await expect(sut.callback({ url: 'http://immich/auth/login?code=abc123' }, loginDetails)).resolves.toEqual(
|
||||||
loginResponseStub.user1oauth,
|
oauthResponse,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(userMock.create).toHaveBeenCalledWith(oauthUserWithDefaultQuota);
|
expect(userMock.create).toHaveBeenCalledWith(oauthUserWithDefaultQuota);
|
||||||
|
@ -574,7 +592,7 @@ describe('AuthService', () => {
|
||||||
oauthMock.getProfile.mockResolvedValue({ sub, email, immich_quota: -5 });
|
oauthMock.getProfile.mockResolvedValue({ sub, email, immich_quota: -5 });
|
||||||
|
|
||||||
await expect(sut.callback({ url: 'http://immich/auth/login?code=abc123' }, loginDetails)).resolves.toEqual(
|
await expect(sut.callback({ url: 'http://immich/auth/login?code=abc123' }, loginDetails)).resolves.toEqual(
|
||||||
loginResponseStub.user1oauth,
|
oauthResponse,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(userMock.create).toHaveBeenCalledWith(oauthUserWithDefaultQuota);
|
expect(userMock.create).toHaveBeenCalledWith(oauthUserWithDefaultQuota);
|
||||||
|
@ -588,7 +606,7 @@ describe('AuthService', () => {
|
||||||
oauthMock.getProfile.mockResolvedValue({ sub, email, immich_quota: 0 });
|
oauthMock.getProfile.mockResolvedValue({ sub, email, immich_quota: 0 });
|
||||||
|
|
||||||
await expect(sut.callback({ url: 'http://immich/auth/login?code=abc123' }, loginDetails)).resolves.toEqual(
|
await expect(sut.callback({ url: 'http://immich/auth/login?code=abc123' }, loginDetails)).resolves.toEqual(
|
||||||
loginResponseStub.user1oauth,
|
oauthResponse,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(userMock.create).toHaveBeenCalledWith({
|
expect(userMock.create).toHaveBeenCalledWith({
|
||||||
|
@ -608,7 +626,7 @@ describe('AuthService', () => {
|
||||||
oauthMock.getProfile.mockResolvedValue({ sub, email, immich_quota: 5 });
|
oauthMock.getProfile.mockResolvedValue({ sub, email, immich_quota: 5 });
|
||||||
|
|
||||||
await expect(sut.callback({ url: 'http://immich/auth/login?code=abc123' }, loginDetails)).resolves.toEqual(
|
await expect(sut.callback({ url: 'http://immich/auth/login?code=abc123' }, loginDetails)).resolves.toEqual(
|
||||||
loginResponseStub.user1oauth,
|
oauthResponse,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(userMock.create).toHaveBeenCalledWith({
|
expect(userMock.create).toHaveBeenCalledWith({
|
||||||
|
|
|
@ -141,8 +141,6 @@ describe(LibraryService.name, () => {
|
||||||
|
|
||||||
describe('handleQueueAssetRefresh', () => {
|
describe('handleQueueAssetRefresh', () => {
|
||||||
it('should queue refresh of a new asset', async () => {
|
it('should queue refresh of a new asset', async () => {
|
||||||
assetMock.getWith.mockResolvedValue({ items: [], hasNextPage: false });
|
|
||||||
|
|
||||||
libraryMock.get.mockResolvedValue(libraryStub.externalLibrary1);
|
libraryMock.get.mockResolvedValue(libraryStub.externalLibrary1);
|
||||||
storageMock.walk.mockImplementation(mockWalk);
|
storageMock.walk.mockImplementation(mockWalk);
|
||||||
|
|
||||||
|
@ -179,8 +177,6 @@ describe(LibraryService.name, () => {
|
||||||
|
|
||||||
storageMock.checkFileExists.mockResolvedValue(true);
|
storageMock.checkFileExists.mockResolvedValue(true);
|
||||||
|
|
||||||
assetMock.getWith.mockResolvedValue({ items: [], hasNextPage: false });
|
|
||||||
|
|
||||||
libraryMock.get.mockResolvedValue(libraryStub.externalLibraryWithImportPaths1);
|
libraryMock.get.mockResolvedValue(libraryStub.externalLibraryWithImportPaths1);
|
||||||
|
|
||||||
await sut.handleQueueSyncFiles({ id: libraryStub.externalLibraryWithImportPaths1.id });
|
await sut.handleQueueSyncFiles({ id: libraryStub.externalLibraryWithImportPaths1.id });
|
||||||
|
|
|
@ -721,7 +721,6 @@ describe(PersonService.name, () => {
|
||||||
'/uploads/user-id/thumbs/path.jpg',
|
'/uploads/user-id/thumbs/path.jpg',
|
||||||
expect.objectContaining({ minScore: 0.7, modelName: 'buffalo_l' }),
|
expect.objectContaining({ minScore: 0.7, modelName: 'buffalo_l' }),
|
||||||
);
|
);
|
||||||
expect(personMock.createFaces).not.toHaveBeenCalled();
|
|
||||||
expect(jobMock.queue).not.toHaveBeenCalled();
|
expect(jobMock.queue).not.toHaveBeenCalled();
|
||||||
expect(jobMock.queueAll).not.toHaveBeenCalled();
|
expect(jobMock.queueAll).not.toHaveBeenCalled();
|
||||||
|
|
||||||
|
@ -733,7 +732,6 @@ describe(PersonService.name, () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should create a face with no person and queue recognition job', async () => {
|
it('should create a face with no person and queue recognition job', async () => {
|
||||||
personMock.createFaces.mockResolvedValue([faceStub.face1.id]);
|
|
||||||
machineLearningMock.detectFaces.mockResolvedValue(detectFaceMock);
|
machineLearningMock.detectFaces.mockResolvedValue(detectFaceMock);
|
||||||
assetMock.getByIds.mockResolvedValue([assetStub.image]);
|
assetMock.getByIds.mockResolvedValue([assetStub.image]);
|
||||||
|
|
||||||
|
@ -761,7 +759,6 @@ describe(PersonService.name, () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should add new face and delete an existing face not among the new detected faces', async () => {
|
it('should add new face and delete an existing face not among the new detected faces', async () => {
|
||||||
personMock.createFaces.mockResolvedValue([faceStub.face1.id]);
|
|
||||||
machineLearningMock.detectFaces.mockResolvedValue(detectFaceMock);
|
machineLearningMock.detectFaces.mockResolvedValue(detectFaceMock);
|
||||||
assetMock.getByIds.mockResolvedValue([{ ...assetStub.image, faces: [faceStub.primaryFace1] }]);
|
assetMock.getByIds.mockResolvedValue([{ ...assetStub.image, faces: [faceStub.primaryFace1] }]);
|
||||||
|
|
||||||
|
@ -816,7 +813,6 @@ describe(PersonService.name, () => {
|
||||||
|
|
||||||
expect(personMock.reassignFaces).not.toHaveBeenCalled();
|
expect(personMock.reassignFaces).not.toHaveBeenCalled();
|
||||||
expect(personMock.create).not.toHaveBeenCalled();
|
expect(personMock.create).not.toHaveBeenCalled();
|
||||||
expect(personMock.createFaces).not.toHaveBeenCalled();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should fail if face does not have asset', async () => {
|
it('should fail if face does not have asset', async () => {
|
||||||
|
@ -827,7 +823,6 @@ describe(PersonService.name, () => {
|
||||||
|
|
||||||
expect(personMock.reassignFaces).not.toHaveBeenCalled();
|
expect(personMock.reassignFaces).not.toHaveBeenCalled();
|
||||||
expect(personMock.create).not.toHaveBeenCalled();
|
expect(personMock.create).not.toHaveBeenCalled();
|
||||||
expect(personMock.createFaces).not.toHaveBeenCalled();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should skip if face already has an assigned person', async () => {
|
it('should skip if face already has an assigned person', async () => {
|
||||||
|
@ -837,7 +832,6 @@ describe(PersonService.name, () => {
|
||||||
|
|
||||||
expect(personMock.reassignFaces).not.toHaveBeenCalled();
|
expect(personMock.reassignFaces).not.toHaveBeenCalled();
|
||||||
expect(personMock.create).not.toHaveBeenCalled();
|
expect(personMock.create).not.toHaveBeenCalled();
|
||||||
expect(personMock.createFaces).not.toHaveBeenCalled();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should match existing person', async () => {
|
it('should match existing person', async () => {
|
||||||
|
|
51
server/test/fixtures/album.stub.ts
vendored
51
server/test/fixtures/album.stub.ts
vendored
|
@ -155,55 +155,4 @@ export const albumStub = {
|
||||||
isActivityEnabled: true,
|
isActivityEnabled: true,
|
||||||
order: AssetOrder.DESC,
|
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,
|
|
||||||
}),
|
|
||||||
};
|
};
|
||||||
|
|
4
server/test/fixtures/api-key.stub.ts
vendored
4
server/test/fixtures/api-key.stub.ts
vendored
|
@ -11,7 +11,3 @@ export const keyStub = {
|
||||||
user: userStub.admin,
|
user: userStub.admin,
|
||||||
} as APIKeyEntity),
|
} as APIKeyEntity),
|
||||||
};
|
};
|
||||||
|
|
||||||
export const apiKeyCreateStub = {
|
|
||||||
name: 'API Key',
|
|
||||||
};
|
|
||||||
|
|
92
server/test/fixtures/asset.stub.ts
vendored
92
server/test/fixtures/asset.stub.ts
vendored
|
@ -523,37 +523,6 @@ export const assetStub = {
|
||||||
},
|
},
|
||||||
} as AssetEntity),
|
} 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({
|
livePhotoStillAsset: Object.freeze({
|
||||||
id: 'live-photo-still-asset',
|
id: 'live-photo-still-asset',
|
||||||
status: AssetStatus.ACTIVE,
|
status: AssetStatus.ACTIVE,
|
||||||
|
@ -570,22 +539,6 @@ export const assetStub = {
|
||||||
},
|
},
|
||||||
} as AssetEntity),
|
} 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({
|
livePhotoWithOriginalFileName: Object.freeze({
|
||||||
id: 'live-photo-still-asset',
|
id: 'live-photo-still-asset',
|
||||||
status: AssetStatus.ACTIVE,
|
status: AssetStatus.ACTIVE,
|
||||||
|
@ -645,6 +598,7 @@ export const assetStub = {
|
||||||
duplicateId: null,
|
duplicateId: null,
|
||||||
isOffline: false,
|
isOffline: false,
|
||||||
}),
|
}),
|
||||||
|
|
||||||
sidecar: Object.freeze<AssetEntity>({
|
sidecar: Object.freeze<AssetEntity>({
|
||||||
id: 'asset-id',
|
id: 'asset-id',
|
||||||
status: AssetStatus.ACTIVE,
|
status: AssetStatus.ACTIVE,
|
||||||
|
@ -679,6 +633,7 @@ export const assetStub = {
|
||||||
duplicateId: null,
|
duplicateId: null,
|
||||||
isOffline: false,
|
isOffline: false,
|
||||||
}),
|
}),
|
||||||
|
|
||||||
sidecarWithoutExt: Object.freeze<AssetEntity>({
|
sidecarWithoutExt: Object.freeze<AssetEntity>({
|
||||||
id: 'asset-id',
|
id: 'asset-id',
|
||||||
status: AssetStatus.ACTIVE,
|
status: AssetStatus.ACTIVE,
|
||||||
|
@ -751,45 +706,7 @@ export const assetStub = {
|
||||||
duplicateId: null,
|
duplicateId: null,
|
||||||
isOffline: false,
|
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>({
|
hasFileExtension: Object.freeze<AssetEntity>({
|
||||||
id: 'asset-id',
|
id: 'asset-id',
|
||||||
status: AssetStatus.ACTIVE,
|
status: AssetStatus.ACTIVE,
|
||||||
|
@ -829,6 +746,7 @@ export const assetStub = {
|
||||||
duplicateId: null,
|
duplicateId: null,
|
||||||
isOffline: false,
|
isOffline: false,
|
||||||
}),
|
}),
|
||||||
|
|
||||||
imageDng: Object.freeze<AssetEntity>({
|
imageDng: Object.freeze<AssetEntity>({
|
||||||
id: 'asset-id',
|
id: 'asset-id',
|
||||||
status: AssetStatus.ACTIVE,
|
status: AssetStatus.ACTIVE,
|
||||||
|
@ -868,6 +786,7 @@ export const assetStub = {
|
||||||
duplicateId: null,
|
duplicateId: null,
|
||||||
isOffline: false,
|
isOffline: false,
|
||||||
}),
|
}),
|
||||||
|
|
||||||
hasEmbedding: Object.freeze<AssetEntity>({
|
hasEmbedding: Object.freeze<AssetEntity>({
|
||||||
id: 'asset-id-embedding',
|
id: 'asset-id-embedding',
|
||||||
status: AssetStatus.ACTIVE,
|
status: AssetStatus.ACTIVE,
|
||||||
|
@ -909,6 +828,7 @@ export const assetStub = {
|
||||||
},
|
},
|
||||||
isOffline: false,
|
isOffline: false,
|
||||||
}),
|
}),
|
||||||
|
|
||||||
hasDupe: Object.freeze<AssetEntity>({
|
hasDupe: Object.freeze<AssetEntity>({
|
||||||
id: 'asset-id-dupe',
|
id: 'asset-id-dupe',
|
||||||
status: AssetStatus.ACTIVE,
|
status: AssetStatus.ACTIVE,
|
||||||
|
|
16
server/test/fixtures/audit.stub.ts
vendored
16
server/test/fixtures/audit.stub.ts
vendored
|
@ -3,22 +3,6 @@ import { DatabaseAction, EntityType } from 'src/enum';
|
||||||
import { authStub } from 'test/fixtures/auth.stub';
|
import { authStub } from 'test/fixtures/auth.stub';
|
||||||
|
|
||||||
export const auditStub = {
|
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>({
|
delete: Object.freeze<AuditEntity>({
|
||||||
id: 3,
|
id: 3,
|
||||||
entityId: 'asset-deleted',
|
entityId: 'asset-deleted',
|
||||||
|
|
57
server/test/fixtures/auth.stub.ts
vendored
57
server/test/fixtures/auth.stub.ts
vendored
|
@ -35,17 +35,6 @@ export const authStub = {
|
||||||
id: 'token-id',
|
id: 'token-id',
|
||||||
} as SessionEntity,
|
} 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>({
|
adminSharedLink: Object.freeze<AuthDto>({
|
||||||
user: {
|
user: {
|
||||||
id: 'admin_id',
|
id: 'admin_id',
|
||||||
|
@ -76,20 +65,6 @@ export const authStub = {
|
||||||
key: Buffer.from('shared-link-key'),
|
key: Buffer.from('shared-link-key'),
|
||||||
} as SharedLinkEntity,
|
} 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>({
|
passwordSharedLink: Object.freeze<AuthDto>({
|
||||||
user: {
|
user: {
|
||||||
id: 'admin_id',
|
id: 'admin_id',
|
||||||
|
@ -106,35 +81,3 @@ export const authStub = {
|
||||||
} as SharedLinkEntity,
|
} 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,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
15
server/test/fixtures/face.stub.ts
vendored
15
server/test/fixtures/face.stub.ts
vendored
|
@ -51,21 +51,6 @@ export const faceStub = {
|
||||||
sourceType: SourceType.MACHINE_LEARNING,
|
sourceType: SourceType.MACHINE_LEARNING,
|
||||||
faceSearch: { faceId: 'assetFaceId3', embedding: [1, 2, 3, 4] },
|
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>>({
|
start: Object.freeze<NonNullableProperty<AssetFaceEntity>>({
|
||||||
id: 'assetFaceId5',
|
id: 'assetFaceId5',
|
||||||
assetId: assetStub.image.id,
|
assetId: assetStub.image.id,
|
||||||
|
|
17
server/test/fixtures/library.stub.ts
vendored
17
server/test/fixtures/library.stub.ts
vendored
|
@ -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 { LibraryEntity } from 'src/entities/library.entity';
|
||||||
import { userStub } from 'test/fixtures/user.stub';
|
import { userStub } from 'test/fixtures/user.stub';
|
||||||
|
|
||||||
|
@ -53,18 +50,6 @@ export const libraryStub = {
|
||||||
refreshedAt: null,
|
refreshedAt: null,
|
||||||
exclusionPatterns: [],
|
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>({
|
patternPath: Object.freeze<LibraryEntity>({
|
||||||
id: 'library-id1337',
|
id: 'library-id1337',
|
||||||
name: 'importpath-exclusion-library1',
|
name: 'importpath-exclusion-library1',
|
||||||
|
@ -83,7 +68,7 @@ export const libraryStub = {
|
||||||
assets: [],
|
assets: [],
|
||||||
owner: userStub.admin,
|
owner: userStub.admin,
|
||||||
ownerId: 'user-id',
|
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'),
|
createdAt: new Date('2023-01-01'),
|
||||||
updatedAt: new Date('2023-01-01'),
|
updatedAt: new Date('2023-01-01'),
|
||||||
refreshedAt: null,
|
refreshedAt: null,
|
||||||
|
|
14
server/test/fixtures/person.stub.ts
vendored
14
server/test/fixtures/person.stub.ts
vendored
|
@ -44,20 +44,6 @@ export const personStub = {
|
||||||
faceAsset: null,
|
faceAsset: null,
|
||||||
isHidden: false,
|
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>({
|
withBirthDate: Object.freeze<PersonEntity>({
|
||||||
id: 'person-1',
|
id: 'person-1',
|
||||||
createdAt: new Date('2021-01-01'),
|
createdAt: new Date('2021-01-01'),
|
||||||
|
|
15
server/test/fixtures/shared-link.stub.ts
vendored
15
server/test/fixtures/shared-link.stub.ts
vendored
|
@ -309,21 +309,6 @@ export const sharedLinkResponseStub = {
|
||||||
type: SharedLinkType.ALBUM,
|
type: SharedLinkType.ALBUM,
|
||||||
userId: 'admin_id',
|
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>({
|
readonlyNoMetadata: Object.freeze<SharedLinkResponseDto>({
|
||||||
id: '123',
|
id: '123',
|
||||||
userId: 'admin_id',
|
userId: 'admin_id',
|
||||||
|
|
40
server/test/fixtures/user.stub.ts
vendored
40
server/test/fixtures/user.stub.ts
vendored
|
@ -2,30 +2,6 @@ import { UserEntity } from 'src/entities/user.entity';
|
||||||
import { UserAvatarColor, UserMetadataKey } from 'src/enum';
|
import { UserAvatarColor, UserMetadataKey } from 'src/enum';
|
||||||
import { authStub } from 'test/fixtures/auth.stub';
|
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 = {
|
export const userStub = {
|
||||||
admin: Object.freeze<UserEntity>({
|
admin: Object.freeze<UserEntity>({
|
||||||
...authStub.admin.user,
|
...authStub.admin.user,
|
||||||
|
@ -100,22 +76,6 @@ export const userStub = {
|
||||||
quotaSizeInBytes: null,
|
quotaSizeInBytes: null,
|
||||||
quotaUsageInBytes: 0,
|
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>({
|
profilePath: Object.freeze<UserEntity>({
|
||||||
...authStub.user1.user,
|
...authStub.user1.user,
|
||||||
password: 'immich_password',
|
password: 'immich_password',
|
||||||
|
|
|
@ -17,7 +17,6 @@ export const newAssetRepositoryMock = (): Mocked<IAssetRepository> => {
|
||||||
getByChecksum: vitest.fn(),
|
getByChecksum: vitest.fn(),
|
||||||
getByChecksums: vitest.fn(),
|
getByChecksums: vitest.fn(),
|
||||||
getUploadAssetIdByChecksum: vitest.fn(),
|
getUploadAssetIdByChecksum: vitest.fn(),
|
||||||
getWith: vitest.fn(),
|
|
||||||
getRandom: vitest.fn(),
|
getRandom: vitest.fn(),
|
||||||
getLastUpdatedAssetForAlbumId: vitest.fn(),
|
getLastUpdatedAssetForAlbumId: vitest.fn(),
|
||||||
getAll: vitest.fn().mockResolvedValue({ items: [], hasNextPage: false }),
|
getAll: vitest.fn().mockResolvedValue({ items: [], hasNextPage: false }),
|
||||||
|
|
|
@ -9,7 +9,6 @@ export const newDatabaseRepositoryMock = (): Mocked<IDatabaseRepository> => {
|
||||||
getPostgresVersion: vitest.fn().mockResolvedValue('14.10 (Debian 14.10-1.pgdg120+1)'),
|
getPostgresVersion: vitest.fn().mockResolvedValue('14.10 (Debian 14.10-1.pgdg120+1)'),
|
||||||
getPostgresVersionRange: vitest.fn().mockReturnValue('>=14.0.0'),
|
getPostgresVersionRange: vitest.fn().mockReturnValue('>=14.0.0'),
|
||||||
createExtension: vitest.fn().mockResolvedValue(void 0),
|
createExtension: vitest.fn().mockResolvedValue(void 0),
|
||||||
updateExtension: vitest.fn(),
|
|
||||||
updateVectorExtension: vitest.fn(),
|
updateVectorExtension: vitest.fn(),
|
||||||
reindex: vitest.fn(),
|
reindex: vitest.fn(),
|
||||||
shouldReindex: vitest.fn(),
|
shouldReindex: vitest.fn(),
|
||||||
|
|
|
@ -6,6 +6,5 @@ export const newMapRepositoryMock = (): Mocked<IMapRepository> => {
|
||||||
init: vitest.fn(),
|
init: vitest.fn(),
|
||||||
reverseGeocode: vitest.fn(),
|
reverseGeocode: vitest.fn(),
|
||||||
getMapMarkers: vitest.fn(),
|
getMapMarkers: vitest.fn(),
|
||||||
fetchStyle: vitest.fn(),
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -16,7 +16,6 @@ export const newPersonRepositoryMock = (): Mocked<IPersonRepository> => {
|
||||||
update: vitest.fn(),
|
update: vitest.fn(),
|
||||||
updateAll: vitest.fn(),
|
updateAll: vitest.fn(),
|
||||||
delete: vitest.fn(),
|
delete: vitest.fn(),
|
||||||
deleteAll: vitest.fn(),
|
|
||||||
deleteFaces: vitest.fn(),
|
deleteFaces: vitest.fn(),
|
||||||
|
|
||||||
getStatistics: vitest.fn(),
|
getStatistics: vitest.fn(),
|
||||||
|
@ -26,7 +25,6 @@ export const newPersonRepositoryMock = (): Mocked<IPersonRepository> => {
|
||||||
|
|
||||||
reassignFaces: vitest.fn(),
|
reassignFaces: vitest.fn(),
|
||||||
unassignFaces: vitest.fn(),
|
unassignFaces: vitest.fn(),
|
||||||
createFaces: vitest.fn(),
|
|
||||||
refreshFaces: vitest.fn(),
|
refreshFaces: vitest.fn(),
|
||||||
getFaces: vitest.fn(),
|
getFaces: vitest.fn(),
|
||||||
reassignFace: vitest.fn(),
|
reassignFace: vitest.fn(),
|
||||||
|
|
Loading…
Reference in a new issue