feat(docker): prepare portable images with runtime hotel configuration
This commit is contained in:
1 parent
745d0b7247
commit
c4496e710b
28 files changed
+622
-104
No files matched your search
+4
-28
@@ -1,32 +1,10 @@
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { getAvatarUrl, resolveImagerBase } from "./imager";
|
||||
import { getAvatarUrl } from "./imager";
|
||||
|
||||
afterEach(() => {
|
||||
vi.unstubAllEnvs();
|
||||
});
|
||||
|
||||
describe("resolveImagerBase", () => {
|
||||
beforeEach(() => {
|
||||
vi.stubEnv("NEXT_PUBLIC_IMAGER_URL", "https://img.example.com");
|
||||
});
|
||||
|
||||
it("returns configured imager env var", () => {
|
||||
expect(resolveImagerBase()).toBe("https://img.example.com");
|
||||
});
|
||||
|
||||
it("strips trailing slashes", () => {
|
||||
vi.stubEnv("NEXT_PUBLIC_IMAGER_URL", "https://img.example.com/");
|
||||
expect(resolveImagerBase()).toBe("https://img.example.com");
|
||||
});
|
||||
|
||||
it("falls back to epicnabbo.nl when env var is not set", () => {
|
||||
vi.stubEnv("NEXT_PUBLIC_IMAGER_URL", "");
|
||||
expect(resolveImagerBase()).toBe(
|
||||
"https://epicnabbo.nl/imaging/avatarimage",
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("getAvatarUrl", () => {
|
||||
beforeEach(() => {
|
||||
vi.stubEnv("NEXT_PUBLIC_IMAGER_URL", "https://img.example.com");
|
||||
@@ -34,7 +12,7 @@ describe("getAvatarUrl", () => {
|
||||
|
||||
it("builds a query string with defaults (omits default params)", () => {
|
||||
const url = getAvatarUrl("hd-180-1");
|
||||
expect(url.startsWith("https://img.example.com?")).toBe(true);
|
||||
expect(url.startsWith("/api/imaging/avatar?")).toBe(true);
|
||||
expect(url).toContain("figure=hd-180-1");
|
||||
expect(url).not.toContain("direction=2");
|
||||
expect(url).not.toContain("head_direction=3");
|
||||
@@ -75,12 +53,10 @@ describe("getAvatarUrl", () => {
|
||||
expect(url).toContain("effect=0");
|
||||
});
|
||||
|
||||
it("uses epicnabbo.nl when no env var is set", () => {
|
||||
it("uses the local runtime proxy when no env var is set", () => {
|
||||
vi.stubEnv("NEXT_PUBLIC_IMAGER_URL", "");
|
||||
const url = getAvatarUrl("hd-180-1");
|
||||
expect(url.startsWith("https://epicnabbo.nl/imaging/avatarimage?")).toBe(
|
||||
true,
|
||||
);
|
||||
expect(url.startsWith("/api/imaging/avatar?")).toBe(true);
|
||||
expect(url).toContain("img_format=apng");
|
||||
expect(url).toContain("effect=14");
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user