feat(docker): prepare portable images with runtime hotel configuration
CI / check (push) Successful in 1m6s
CI / deploy (push) Successful in 1m23s

This commit is contained in:
Simo committed 2026-09-07 22:37:53 +02:00
1 parent 745d0b7247
commit c4496e710b
28 files changed
+622 -104

No files matched your search

+44
View File
@@ -0,0 +1,44 @@
import { NextRequest } from "next/server";
import { afterEach, expect, it, vi } from "vitest";
import { GET } from "../app/api/imaging/avatar/route";
afterEach(() => {
vi.unstubAllEnvs();
vi.unstubAllGlobals();
});
it("forwards multicolor figures and preserves configured query options at runtime", async () => {
const figure = "hr-11782-40-40.hd-180-7-14.ch-11592-66.lg-10726-79-1408";
const fetcher = vi.fn(
async (_input: string | URL) =>
new Response(new Uint8Array([1, 2, 3]), {
headers: { "content-type": "image/png" },
}),
);
vi.stubGlobal("fetch", fetcher);
for (const hotel of ["alpha", "beta"]) {
vi.stubEnv("IMAGER_URL", `https://${hotel}.test/avatar?renderer=custom`);
const result = await GET(
new NextRequest(
`https://hotel.test/api/imaging/avatar?figure=${figure}&headonly=1&effect=0`,
),
);
expect(result.status).toBe(200);
const target = new URL(String(fetcher.mock.calls.at(-1)?.[0]));
expect(target.origin).toBe(`https://${hotel}.test`);
expect(target.searchParams.get("figure")).toBe(figure);
expect(target.searchParams.get("renderer")).toBe("custom");
expect(target.searchParams.get("headonly")).toBe("1");
}
});
it("rejects malformed figure input without contacting a renderer", async () => {
const fetcher = vi.fn();
vi.stubGlobal("fetch", fetcher);
expect(
(
await GET(
new NextRequest("https://hotel.test/api/imaging/avatar?figure=../bad"),
)
).status,
).toBe(400);
expect(fetcher).not.toHaveBeenCalled();
});