feat : add image generator
CI / Verify (push) Successful in 1m11s
CI / Build immutable images and deploy (push) Successful in 5m17s

This commit is contained in:
2026-09-06 02:22:19 +07:00 Unverified
parent 201a1478fc
commit d3e5e6c04f
7 changed files with 932 additions and 193 deletions
+32
View File
@@ -2,8 +2,13 @@ import { describe, expect, it } from "vitest";
import {
accentGradient,
detectThemeColorsFromPixels,
elementGlowColor,
elementGradientColors,
elementOrder,
normalizeHex,
overviewFileName,
overviewBlendModes,
weaponTypeIconPath,
} from "@/lib/overview-image";
@@ -42,10 +47,37 @@ describe("overview image generator", () => {
expect(weaponTypeIconPath(null)).toBeNull();
});
it("maps every element to gradient and fixed glow colors", () => {
for (const element of elementOrder) {
const [start, end] = elementGradientColors(element);
expect(normalizeHex(start)).toBe(start);
expect(normalizeHex(end)).toBe(end);
expect(normalizeHex(elementGlowColor(element))).toBe(
elementGlowColor(element),
);
}
expect(elementGradientColors("Unknown")).toEqual(["#FFFFFF", "#FFFFFF"]);
expect(elementGlowColor(null)).toBe("#FFFFFF");
});
it("creates a safe PNG filename", () => {
expect(overviewFileName("Traveler / Pyro", "Main DPS")).toBe(
"overview-Traveler-Pyro-main-dps.png",
);
});
it("supports every Tailwind blend mode and detects top and bottom themes", () => {
expect(overviewBlendModes.map((mode) => mode.value)).toHaveLength(18);
const pixels = new Uint8ClampedArray([
255, 0, 0, 255, 255, 0, 0, 255,
255, 255, 0, 255, 255, 255, 0, 255,
0, 0, 255, 255, 0, 0, 255, 255,
0, 255, 255, 255, 0, 255, 255, 255,
]);
expect(detectThemeColorsFromPixels(pixels, 2, 4)).toEqual({
top: ["#FF0000", "#FFFF00"],
bottom: ["#0000FF", "#00FFFF"],
});
});
});