- Remove .prettierrc (dead config, Biome replaces Prettier) - Rename lighthouserc.json to lighthouserc.cjs with module.exports for ESM compat - Add logger.warn to empty catch blocks in auth, register, site-settings, prisma-cache, redis, security, rate-limit - Unify ActionResult type: action-helper.ts uses 'ok' consistent with safe-action-shared.ts - Add noUnusedLocals + noUnusedParameters to tsconfig + fix 25 pre-existing unused vars - Replace barrel export src/types/index.ts with direct @/types/common imports - Make trustHost conditional (development only) in auth.ts - Add pre-flight URL validation to update-Nitrov3.sh to catch image.library.url misconfigurations - Improve NITRO_IMAGE_LIBRARY_URL content validation in pre-flight & post-compute checks
51 lines
1.6 KiB
TypeScript
51 lines
1.6 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { getAvatarUrl, resolveImagerBase, resolveUpstreamBase } from "./imager";
|
|
|
|
describe("resolveImagerBase", () => {
|
|
it("defaults to /imaging when no public URL env is set", () => {
|
|
expect(resolveImagerBase()).toBe("/imaging");
|
|
expect(resolveImagerBase("")).toBe("/imaging");
|
|
expect(resolveImagerBase(null)).toBe("/imaging");
|
|
});
|
|
|
|
it("rejects the broken self-hosted proxy", () => {
|
|
expect(resolveImagerBase("/api/imaging/avatar")).toBe("/imaging");
|
|
expect(
|
|
resolveImagerBase("https://www.epicnabbo.nl/api/imaging/avatar"),
|
|
).toBe("/imaging");
|
|
});
|
|
|
|
it("accepts /imaging as a valid configured URL", () => {
|
|
expect(resolveImagerBase("/imaging")).toBe("/imaging");
|
|
});
|
|
|
|
it("keeps a custom Habbo-compatible base", () => {
|
|
expect(
|
|
resolveImagerBase("https://www.habbo.com/habbo-imaging/avatarimage/"),
|
|
).toBe("https://www.habbo.com/habbo-imaging/avatarimage");
|
|
});
|
|
});
|
|
|
|
describe("resolveUpstreamBase", () => {
|
|
it("defaults to Habbo's public imager", () => {
|
|
const url = resolveUpstreamBase();
|
|
expect(url).toBe("https://www.habbo.com/habbo-imaging/avatarimage");
|
|
});
|
|
});
|
|
|
|
describe("getAvatarUrl", () => {
|
|
it("builds an imager URL", () => {
|
|
const url = getAvatarUrl("hr-115-42.hd-180-1", {
|
|
size: "l",
|
|
headOnly: true,
|
|
direction: 2,
|
|
});
|
|
expect(url.startsWith("/imaging?")).toBe(true);
|
|
expect(url).toContain("figure=hr-115-42.hd-180-1");
|
|
expect(url).toContain("size=l");
|
|
expect(url).toContain("headonly=1");
|
|
expect(url).toContain("direction=2");
|
|
expect(url).toContain("img_format=png");
|
|
});
|
|
});
|