diff --git a/server/test/medium.factory.ts b/server/test/medium.factory.ts index cf863db2f0..53bf78b5b8 100644 --- a/server/test/medium.factory.ts +++ b/server/test/medium.factory.ts @@ -3,6 +3,7 @@ import { Insertable, Kysely } from 'kysely'; import { DateTime } from 'luxon'; import { createHash, randomBytes } from 'node:crypto'; import { Stats } from 'node:fs'; +import { resolve } from 'node:path'; import { Writable } from 'node:stream'; import { AssetFace } from 'src/database'; import { AuthDto, LoginResponseDto } from 'src/dtos/auth.dto'; @@ -78,6 +79,9 @@ import { factory, newDate, newEmbedding, newUuid } from 'test/small.factory'; import { automock, wait } from 'test/utils'; import { Mocked } from 'vitest'; +// eslint-disable-next-line unicorn/prefer-module +export const testAssetsDir = resolve(__dirname, '../../e2e/test-assets'); + interface ClassConstructor extends Function { new (...args: any[]): T; } diff --git a/server/test/medium/specs/exif/exif-date-time.spec.ts b/server/test/medium/specs/exif/exif-date-time.spec.ts index e46f17855e..3341800b30 100644 --- a/server/test/medium/specs/exif/exif-date-time.spec.ts +++ b/server/test/medium/specs/exif/exif-date-time.spec.ts @@ -2,7 +2,7 @@ import { Kysely } from 'kysely'; import { DateTime } from 'luxon'; import { resolve } from 'node:path'; import { DB } from 'src/schema'; -import { ExifTestContext } from 'test/medium.factory'; +import { ExifTestContext, testAssetsDir } from 'test/medium.factory'; import { getKyselyDB } from 'test/utils'; let database: Kysely; @@ -11,7 +11,7 @@ const setup = async (testAssetPath: string) => { const ctx = new ExifTestContext(database); const { user } = await ctx.newUser(); - const originalPath = resolve(`../e2e/test-assets/${testAssetPath}`); + const originalPath = resolve(testAssetsDir, testAssetPath); const { asset } = await ctx.newAsset({ ownerId: user.id, originalPath }); return { ctx, sut: ctx.sut, asset }; diff --git a/server/test/medium/specs/exif/exif-gps.spec.ts b/server/test/medium/specs/exif/exif-gps.spec.ts index 651321b599..91326be28c 100644 --- a/server/test/medium/specs/exif/exif-gps.spec.ts +++ b/server/test/medium/specs/exif/exif-gps.spec.ts @@ -1,7 +1,7 @@ import { Kysely } from 'kysely'; import { resolve } from 'node:path'; import { DB } from 'src/schema'; -import { ExifTestContext } from 'test/medium.factory'; +import { ExifTestContext, testAssetsDir } from 'test/medium.factory'; import { getKyselyDB } from 'test/utils'; let database: Kysely; @@ -10,7 +10,7 @@ const setup = async (testAssetPath: string) => { const ctx = new ExifTestContext(database); const { user } = await ctx.newUser(); - const originalPath = resolve(`../e2e/test-assets/${testAssetPath}`); + const originalPath = resolve(testAssetsDir, testAssetPath); const { asset } = await ctx.newAsset({ ownerId: user.id, originalPath }); return { ctx, sut: ctx.sut, asset }; diff --git a/server/test/medium/specs/exif/exif-tags.spec.ts b/server/test/medium/specs/exif/exif-tags.spec.ts index 33a81d24b6..c65d4b3f7e 100644 --- a/server/test/medium/specs/exif/exif-tags.spec.ts +++ b/server/test/medium/specs/exif/exif-tags.spec.ts @@ -1,7 +1,7 @@ import { Kysely } from 'kysely'; import { resolve } from 'node:path'; import { DB } from 'src/schema'; -import { ExifTestContext } from 'test/medium.factory'; +import { ExifTestContext, testAssetsDir } from 'test/medium.factory'; import { getKyselyDB } from 'test/utils'; let database: Kysely; @@ -10,7 +10,7 @@ const setup = async (testAssetPath: string) => { const ctx = new ExifTestContext(database); const { user } = await ctx.newUser(); - const originalPath = resolve(`../e2e/test-assets/${testAssetPath}`); + const originalPath = resolve(testAssetsDir, testAssetPath); const { asset } = await ctx.newAsset({ ownerId: user.id, originalPath }); return { ctx, sut: ctx.sut, asset };