Skip to content

High performance self-hosted photo and video management solution.

refactor: e2e client (#7324)

Jason Rasmussen2ebb57cbd405
diff --git a/server/e2e/api/specs/asset.e2e-spec.ts b/server/e2e/api/specs/asset.e2e-spec.ts
index 7789881206..0e09a68be5 100644
--- a/server/e2e/api/specs/asset.e2e-spec.ts
+++ b/server/e2e/api/specs/asset.e2e-spec.ts
@@ -531,8 +531,8 @@ describe(`${AssetController.name} (e2e)`, () => {
expect(status).toBe(200);
expect(body.length).toBe(assets.length);
- for (let i = 0; i < assets.length; i++) {
- expect(body[i]).toEqual(expect.objectContaining({ id: assets[i].id }));
+ for (const [i, asset] of assets.entries()) {
+ expect(body[i]).toEqual(expect.objectContaining({ id: asset.id }));
}
});
}
@@ -699,7 +699,7 @@ describe(`${AssetController.name} (e2e)`, () => {
it("should not upload to another user's library", async () => {
const content = randomBytes(32);
- const library = (await api.libraryApi.getAll(server, user2.accessToken))[0];
+ const [library] = await api.libraryApi.getAll(server, user2.accessToken);
await api.assetApi.upload(server, user1.accessToken, 'example-image', { content });
const { body, status } = await request(server)
diff --git a/server/e2e/api/specs/search.e2e-spec.ts b/server/e2e/api/specs/search.e2e-spec.ts
index 74988396d7..0e5cc428cc 100644
--- a/server/e2e/api/specs/search.e2e-spec.ts
+++ b/server/e2e/api/specs/search.e2e-spec.ts
@@ -44,7 +44,7 @@ describe(`${SearchController.name}`, () => {
describe('GET /search (exif)', () => {
beforeEach(async () => {
- const assetId = (await assetRepository.create(generateAsset(loginResponse.userId, libraries))).id;
+ const { id: assetId } = await assetRepository.create(generateAsset(loginResponse.userId, libraries));
await assetRepository.upsertExif({ assetId, ...searchStub.exif });
const assetWithMetadata = await assetRepository.getById(assetId, { exifInfo: true });
@@ -166,7 +166,7 @@ describe(`${SearchController.name}`, () => {
describe('GET /search (smart info)', () => {
beforeEach(async () => {
- const assetId = (await assetRepository.create(generateAsset(loginResponse.userId, libraries))).id;
+ const { id: assetId } = await assetRepository.create(generateAsset(loginResponse.userId, libraries));
await assetRepository.upsertExif({ assetId, ...searchStub.exif });
await smartInfoRepository.upsert({ assetId, ...searchStub.smartInfo }, Array.from({ length: 512 }, Math.random));
@@ -215,7 +215,7 @@ describe(`${SearchController.name}`, () => {
describe('GET /search (file name)', () => {
beforeEach(async () => {
- const assetId = (await assetRepository.create(generateAsset(loginResponse.userId, libraries))).id;
+ const { id: assetId } = await assetRepository.create(generateAsset(loginResponse.userId, libraries));
await assetRepository.upsertExif({ assetId, ...searchStub.exif });
const assetWithMetadata = await assetRepository.getById(assetId, { exifInfo: true });
diff --git a/server/e2e/client/activity-api.ts b/server/e2e/client/activity-api.ts
deleted file mode 100644
index f7cac45624..0000000000
--- a/server/e2e/client/activity-api.ts
+++ /dev/null
@@ -1,14 +0,0 @@
-import { ActivityCreateDto, ActivityResponseDto } from '@app/domain';
-import request from 'supertest';
-
-export const activityApi = {
- create: async (server: any, accessToken: string, dto: ActivityCreateDto) => {
- const res = await request(server).post('/activity').set('Authorization', `Bearer ${accessToken}`).send(dto);
- expect(res.status === 200 || res.status === 201).toBe(true);
- return res.body as ActivityResponseDto;
- },
- delete: async (server: any, accessToken: string, id: string) => {
- const res = await request(server).delete(`/activity/${id}`).set('Authorization', `Bearer ${accessToken}`);
- expect(res.status).toEqual(204);
- },
-};
diff --git a/server/e2e/client/album-api.ts b/server/e2e/client/album-api.ts
deleted file mode 100644
index 92c75dc64b..0000000000
--- a/server/e2e/client/album-api.ts
+++ /dev/null
@@ -1,28 +0,0 @@
-import { AddUsersDto, AlbumResponseDto, BulkIdResponseDto, BulkIdsDto, CreateAlbumDto } from '@app/domain';
-import request from 'supertest';
-
-export const albumApi = {
- create: async (server: any, accessToken: string, dto: CreateAlbumDto) => {
- const res = await request(server).post('/album').set('Authorization', `Bearer ${accessToken}`).send(dto);
- expect(res.status).toEqual(201);
- return res.body as AlbumResponseDto;
- },
- addAssets: async (server: any, accessToken: string, id: string, dto: BulkIdsDto) => {
- const res = await request(server)
- .put(`/album/${id}/assets`)
- .set('Authorization', `Bearer ${accessToken}`)
- .send(dto);
- expect(res.status).toEqual(200);
- return res.body as BulkIdResponseDto[];
- },
- addUsers: async (server: any, accessToken: string, id: string, dto: AddUsersDto) => {
- const res = await request(server).put(`/album/${id}/users`).set('Authorization', `Bearer ${accessToken}`).send(dto);
- expect(res.status).toEqual(200);
- return res.body as AlbumResponseDto;
- },
- getAllAlbums: async (server: any, accessToken: string) => {
- const res = await request(server).get(`/album/`).set('Authorization', `Bearer ${accessToken}`).send();
- expect(res.status).toEqual(200);
- return res.body as AlbumResponseDto[];
- },
-};
diff --git a/server/e2e/client/api-key-api.ts b/server/e2e/client/api-key-api.ts
deleted file mode 100644
index a35f13f7d9..0000000000
--- a/server/e2e/client/api-key-api.ts
+++ /dev/null
@@ -1,16 +0,0 @@
-import { APIKeyCreateResponseDto } from '@app/domain';
-import { apiKeyCreateStub } from '@test';
-import request from 'supertest';
-
-export const apiKeyApi = {
- createApiKey: async (server: any, accessToken: string) => {
- const { status, body } = await request(server)
- .post('/api-key')
- .set('Authorization', `Bearer ${accessToken}`)
- .send(apiKeyCreateStub);
-
- expect(status).toBe(201);
-
- return body as APIKeyCreateResponseDto;
- },
-};
diff --git a/server/e2e/client/auth-api.ts b/server/e2e/client/auth-api.ts
index 3043c941f2..f0206d3376 100644
--- a/server/e2e/client/auth-api.ts
+++ b/server/e2e/client/auth-api.ts
@@ -1,4 +1,4 @@
-import { AuthDeviceResponseDto, LoginCredentialDto, LoginResponseDto, UserResponseDto } from '@app/domain';
+import { LoginCredentialDto, LoginResponseDto, UserResponseDto } from '@app/domain';
import { adminSignupStub, loginResponseStub, loginStub } from '@test';
import request from 'supertest';
@@ -27,19 +27,4 @@ export const authApi = {
return body as LoginResponseDto;
},
- getAuthDevices: async (server: any, accessToken: string) => {
- const { status, body } = await request(server).get('/auth/devices').set('Authorization', `Bearer ${accessToken}`);
-
- expect(body).toEqual(expect.any(Array));
- expect(status).toBe(200);
-
- return body as AuthDeviceResponseDto[];
- },
- validateToken: async (server: any, accessToken: string) => {
- const { status, body } = await request(server)
- .post('/auth/validateToken')
- .set('Authorization', `Bearer ${accessToken}`);
- expect(body).toEqual({ authStatus: true });
- expect(status).toBe(200);
- },
};
diff --git a/server/e2e/client/index.ts b/server/e2e/client/index.ts
index b9c0f2ff38..b0464a34d8 100644
--- a/server/e2e/client/index.ts
+++ b/server/e2e/client/index.ts
@@ -1,25 +1,15 @@
-import { activityApi } from './activity-api';
-import { albumApi } from './album-api';
-import { apiKeyApi } from './api-key-api';
import { assetApi } from './asset-api';
import { authApi } from './auth-api';
import { libraryApi } from './library-api';
-import { partnerApi } from './partner-api';
-import { serverInfoApi } from './server-info-api';
import { sharedLinkApi } from './shared-link-api';
import { trashApi } from './trash-api';
import { userApi } from './user-api';
export const api = {
- activityApi,
authApi,
- apiKeyApi,
assetApi,
libraryApi,
- serverInfoApi,
sharedLinkApi,
trashApi,
- albumApi,
userApi,
- partnerApi,
};
diff --git a/server/e2e/client/partner-api.ts b/server/e2e/client/partner-api.ts
deleted file mode 100644
index 97a9558c5f..0000000000
--- a/server/e2e/client/partner-api.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-import { PartnerResponseDto } from '@app/domain';
-import request from 'supertest';
-
-export const partnerApi = {
- create: async (server: any, accessToken: string, id: string) => {
- const { status, body } = await request(server).post(`/partner/${id}`).set('Authorization', `Bearer ${accessToken}`);
- expect(status).toBe(201);
- return body as PartnerResponseDto;
- },
-};
diff --git a/server/e2e/client/server-info-api.ts b/server/e2e/client/server-info-api.ts
deleted file mode 100644
index f885bc856f..0000000000
--- a/server/e2e/client/server-info-api.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-import { ServerConfigDto } from '@app/domain';
-import request from 'supertest';
-
-export const serverInfoApi = {
- getConfig: async (server: any) => {
- const res = await request(server).get('/server-info/config');
- expect(res.status).toBe(200);
- return res.body as ServerConfigDto;
- },
-};
diff --git a/server/e2e/client/shared-link-api.ts b/server/e2e/client/shared-link-api.ts
index d6179f6b6f..c34093b0ac 100644
--- a/server/e2e/client/shared-link-api.ts
+++ b/server/e2e/client/shared-link-api.ts
@@ -10,11 +10,4 @@ export const sharedLinkApi = {
expect(status).toBe(201);
return body as SharedLinkResponseDto;
},
-
- getMySharedLink: async (server: any, key: string) => {
- const { status, body } = await request(server).get('/shared-link/me').query({ key });
-
- expect(status).toBe(200);
- return body as SharedLinkResponseDto;
- },
};
diff --git a/server/e2e/client/user-api.ts b/server/e2e/client/user-api.ts
index 5ed0838f75..9123b06219 100644
--- a/server/e2e/client/user-api.ts
+++ b/server/e2e/client/user-api.ts
@@ -18,16 +18,6 @@ export const userApi = {
return body as UserResponseDto;
},
- get: async (server: any, accessToken: string, id: string) => {
- const { status, body } = await request(server)
- .get(`/user/info/${id}`)
- .set('Authorization', `Bearer ${accessToken}`);
-
- expect(status).toBe(200);
- expect(body).toMatchObject({ id });
-
- return body as UserResponseDto;
- },
update: async (server: any, accessToken: string, dto: UpdateUserDto) => {
const { status, body } = await request(server).put('/user').set('Authorization', `Bearer ${accessToken}`).send(dto);
@@ -39,12 +29,4 @@ export const userApi = {
setExternalPath: async (server: any, accessToken: string, id: string, externalPath: string) => {
return await userApi.update(server, accessToken, { id, externalPath });
},
- delete: async (server: any, accessToken: string, id: string) => {
- const { status, body } = await request(server).delete(`/user/${id}`).set('Authorization', `Bearer ${accessToken}`);
-
- expect(status).toBe(200);
- expect(body).toMatchObject({ id, deletedAt: expect.any(String) });
-
- return body as UserResponseDto;
- },
};
diff --git a/server/e2e/jobs/specs/formats.e2e-spec.ts b/server/e2e/jobs/specs/formats.e2e-spec.ts
index 5f6ffba311..c8b14d588a 100644
--- a/server/e2e/jobs/specs/formats.e2e-spec.ts
+++ b/server/e2e/jobs/specs/formats.e2e-spec.ts
@@ -1,7 +1,7 @@
import { LoginResponseDto } from '@app/domain';
import { AssetType } from '@app/infra/entities';
-import { readFile } from 'fs/promises';
-import { basename, join } from 'path';
+import { readFile } from 'node:fs/promises';
+import { basename, join } from 'node:path';
import { IMMICH_TEST_ASSET_PATH, testApp } from '../../../src/test-utils/utils';
import { api } from '../../client';
@@ -19,7 +19,7 @@ const JPEG = {
iso: 200,
fNumber: 11,
exposureTime: '1/160',
- fileSizeInByte: 53493,
+ fileSizeInByte: 53_493,
make: 'SONY',
model: 'DSLR-A550',
orientation: null,
@@ -42,11 +42,11 @@ const tests = [
exifImageWidth: 4032,
exifImageHeight: 3024,
latitude: 41.2203,
- longitude: -96.071625,
+ longitude: -96.071_625,
make: 'Apple',
model: 'iPhone 7',
lensModel: 'iPhone 7 back camera 3.99mm f/1.8',
- fileSizeInByte: 880703,
+ fileSizeInByte: 880_703,
exposureTime: '1/887',
iso: 20,
focalLength: 3.99,
@@ -66,7 +66,7 @@ const tests = [
exifImageHeight: 800,
latitude: null,
longitude: null,
- fileSizeInByte: 25408,
+ fileSizeInByte: 25_408,
},
},
},
@@ -84,7 +84,7 @@ const tests = [
fNumber: 10,
focalLength: 18,
iso: 100,
- fileSizeInByte: 9057784,
+ fileSizeInByte: 9_057_784,
dateTimeOriginal: '2010-07-20T17:27:12.000Z',
latitude: null,
longitude: null,
@@ -106,7 +106,7 @@ const tests = [
fNumber: 11,
focalLength: 85,
iso: 200,
- fileSizeInByte: 15856335,
+ fileSizeInByte: 15_856_335,
dateTimeOriginal: '2016-09-22T22:10:29.060Z',
latitude: null,
longitude: null,
diff --git a/server/e2e/jobs/specs/library-watcher.e2e-spec.ts b/server/e2e/jobs/specs/library-watcher.e2e-spec.ts
index cb7dd5f894..0215a4976e 100644
--- a/server/e2e/jobs/specs/library-watcher.e2e-spec.ts
+++ b/server/e2e/jobs/specs/library-watcher.e2e-spec.ts
@@ -1,7 +1,7 @@
import { LibraryResponseDto, LibraryService, LoginResponseDto } from '@app/domain';
import { AssetType, LibraryType } from '@app/infra/entities';
-import fs from 'fs/promises';
-import path from 'path';
+import fs from 'node:fs/promises';
+import path from 'node:path';
import {
IMMICH_TEST_ASSET_PATH,
IMMICH_TEST_ASSET_TEMP_PATH,
@@ -20,7 +20,8 @@ describe(`Library watcher (e2e)`, () => {
beforeAll(async () => {
process.env.IMMICH_CONFIG_FILE = path.normalize(`${__dirname}/../config/library-watcher-e2e-config.json`);
- server = (await testApp.create()).getHttpServer();
+ const app = await testApp.create();
+ server = app.getHttpServer();
libraryService = testApp.get(LibraryService);
});