mirror of
https://github.com/immich-app/immich.git
synced 2025-07-09 09:12:57 +02:00
refactor(server): e2e (#7265)
* refactor: activity e2e * refactor: person e2e * refactor: shared link e2e
This commit is contained in:
parent
a1bc74cdd6
commit
f798e037d5
5 changed files with 573 additions and 459 deletions
e2e/src
|
@ -2,13 +2,15 @@ import {
|
|||
AssetResponseDto,
|
||||
CreateAssetDto,
|
||||
CreateUserDto,
|
||||
LoginResponseDto,
|
||||
PersonUpdateDto,
|
||||
createApiKey,
|
||||
createPerson,
|
||||
createUser,
|
||||
defaults,
|
||||
login,
|
||||
setAdminOnboarding,
|
||||
signUpAdmin,
|
||||
updatePerson,
|
||||
} from '@immich/sdk';
|
||||
import { BrowserContext } from '@playwright/test';
|
||||
import { spawn } from 'child_process';
|
||||
|
@ -45,7 +47,36 @@ export const asKeyAuth = (key: string) => ({ 'x-api-key': key });
|
|||
let client: pg.Client | null = null;
|
||||
|
||||
export const dbUtils = {
|
||||
reset: async () => {
|
||||
createFace: async ({
|
||||
assetId,
|
||||
personId,
|
||||
}: {
|
||||
assetId: string;
|
||||
personId: string;
|
||||
}) => {
|
||||
if (!client) {
|
||||
return;
|
||||
}
|
||||
|
||||
const vector = Array.from({ length: 512 }, Math.random);
|
||||
const embedding = `[${vector.join(',')}]`;
|
||||
|
||||
await client.query(
|
||||
'INSERT INTO asset_faces ("assetId", "personId", "embedding") VALUES ($1, $2, $3)',
|
||||
[assetId, personId, embedding]
|
||||
);
|
||||
},
|
||||
setPersonThumbnail: async (personId: string) => {
|
||||
if (!client) {
|
||||
return;
|
||||
}
|
||||
|
||||
await client.query(
|
||||
`UPDATE "person" set "thumbnailPath" = '/my/awesome/thumbnail.jpg' where "id" = $1`,
|
||||
[personId]
|
||||
);
|
||||
},
|
||||
reset: async (tables?: string[]) => {
|
||||
try {
|
||||
if (!client) {
|
||||
client = new pg.Client(
|
||||
|
@ -54,14 +85,20 @@ export const dbUtils = {
|
|||
await client.connect();
|
||||
}
|
||||
|
||||
for (const table of [
|
||||
tables = tables || [
|
||||
'shared_links',
|
||||
'person',
|
||||
'albums',
|
||||
'assets',
|
||||
'asset_faces',
|
||||
'activity',
|
||||
'api_keys',
|
||||
'user_token',
|
||||
'users',
|
||||
'system_metadata',
|
||||
]) {
|
||||
];
|
||||
|
||||
for (const table of tables) {
|
||||
await client.query(`DELETE FROM ${table} CASCADE;`);
|
||||
}
|
||||
} catch (error) {
|
||||
|
@ -165,6 +202,15 @@ export const apiUtils = {
|
|||
|
||||
return body as AssetResponseDto;
|
||||
},
|
||||
createPerson: async (accessToken: string, dto: PersonUpdateDto) => {
|
||||
// TODO fix createPerson to accept a body
|
||||
const { id } = await createPerson({ headers: asBearerAuth(accessToken) });
|
||||
await dbUtils.setPersonThumbnail(id);
|
||||
return updatePerson(
|
||||
{ id, personUpdateDto: dto },
|
||||
{ headers: asBearerAuth(accessToken) }
|
||||
);
|
||||
},
|
||||
};
|
||||
|
||||
export const cliUtils = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue