refactor: small face tests (#26340)

This commit is contained in:
Daniel Dietzler
2026-02-19 14:51:18 +01:00
committed by GitHub
parent e0bb5f70ec
commit d0ed76dc37
9 changed files with 287 additions and 394 deletions

View File

@@ -1,3 +1,6 @@
import { Selectable } from 'kysely';
import { AssetTable } from 'src/schema/tables/asset.table';
import { AssetFaceFactory } from 'test/factories/asset-face.factory';
import { AssetFactory } from 'test/factories/asset.factory';
export const getForStorageTemplate = (asset: ReturnType<AssetFactory['build']>) => {
@@ -20,3 +23,29 @@ export const getForStorageTemplate = (asset: ReturnType<AssetFactory['build']>)
isEdited: asset.isEdited,
};
};
export const getAsDetectedFace = (face: ReturnType<AssetFaceFactory['build']>) => ({
faces: [
{
boundingBox: {
x1: face.boundingBoxX1,
y1: face.boundingBoxY1,
x2: face.boundingBoxX2,
y2: face.boundingBoxY2,
},
embedding: '[1, 2, 3, 4]',
score: 0.2,
},
],
imageHeight: face.imageHeight,
imageWidth: face.imageWidth,
});
export const getForFacialRecognitionJob = (
face: ReturnType<AssetFaceFactory['build']>,
asset: Pick<Selectable<AssetTable>, 'ownerId' | 'visibility' | 'fileCreatedAt'> | null,
) => ({
...face,
asset,
faceSearch: { faceId: face.id, embedding: '[1, 2, 3, 4]' },
});