49 lines
1.4 KiB
TypeScript
49 lines
1.4 KiB
TypeScript
import { afterAll, beforeAll, describe, expect, test } from "vitest";
|
|
import { createFakeImmichServer } from "./server";
|
|
|
|
describe("createFakeImmichServer", () => {
|
|
const fakeImmich = createFakeImmichServer({ port: 0 });
|
|
let baseUrl = "";
|
|
|
|
beforeAll(async () => {
|
|
baseUrl = await fakeImmich.start();
|
|
});
|
|
|
|
afterAll(async () => {
|
|
await fakeImmich.stop();
|
|
});
|
|
|
|
test("serves album list", async () => {
|
|
const res = await fetch(`${baseUrl}/api/albums`, {
|
|
headers: { "x-api-key": "test-immich-api-key" },
|
|
});
|
|
expect(res.status).toBe(200);
|
|
const body = await res.json();
|
|
expect(body).toHaveLength(1);
|
|
expect(body[0].albumName).toBe("Presse 2026");
|
|
});
|
|
|
|
test("serves metadata search with album filter", async () => {
|
|
const res = await fetch(`${baseUrl}/api/search/metadata`, {
|
|
method: "POST",
|
|
headers: {
|
|
"content-type": "application/json",
|
|
"x-api-key": "test-immich-api-key",
|
|
},
|
|
body: JSON.stringify({ albumIds: ["album-1"], type: "IMAGE" }),
|
|
});
|
|
expect(res.status).toBe(200);
|
|
const body = await res.json();
|
|
expect(body.assets.total).toBe(2);
|
|
});
|
|
|
|
test("simulates outage mode", async () => {
|
|
fakeImmich.setOutage(true);
|
|
const res = await fetch(`${baseUrl}/api/albums`, {
|
|
headers: { "x-api-key": "test-immich-api-key" },
|
|
});
|
|
expect(res.status).toBe(503);
|
|
fakeImmich.setOutage(false);
|
|
});
|
|
});
|