perf : cache
CI / Verify (push) Successful in 1m56s
CI / Build immutable images and deploy (push) Successful in 3m12s

This commit is contained in:
2026-10-08 23:21:34 +07:00 Unverified
parent 36063fc214
commit 9580407a90
58 changed files with 5797 additions and 5336 deletions
+17 -3
View File
@@ -1,11 +1,12 @@
import { beforeEach, describe, expect, it, vi } from "vitest";
const mocks = vi.hoisted(() => ({ reads: [] as unknown[], rows: new Map<unknown, unknown[]>() }));
const mocks = vi.hoisted(() => ({ reads: [] as unknown[], selections: [] as unknown[], rows: new Map<unknown, unknown[]>() }));
vi.mock("server-only", () => ({}));
vi.mock("@/lib/media/storage", () => ({ publicMediaUrl: (key: string) => `/media/${key}` }));
vi.mock("@/db", () => ({
getDb: () => ({
select: () => {
select: (columns?: unknown) => {
mocks.selections.push(columns);
let table: unknown;
const query = {
from(value: unknown) { table = value; return query; },
@@ -29,10 +30,11 @@ import {
guides, guideSections, teamCompositions, teamConditions, teamMembers, weaponConditions,
catalogCharacters, catalogMaterials, guidePosterBleeding, media, weaponRecommendations, artifactRecommendations,
} from "@/db/schema";
import { getActiveCatalog, getAdminGuideContent, getPublicGuide, listAdminTeamImportsForCharacter } from "./queries";
import { getActiveCatalog, getCatalogOptions, getAdminGuideContent, getPublicGuide, listAdminTeamImportsForCharacter } from "./queries";
beforeEach(() => {
mocks.reads.length = 0;
mocks.selections.length = 0;
mocks.rows.clear();
mocks.rows.set(guides, [{
guide: { id: "guide", slug: "test", posterArtMediaId: null },
@@ -202,3 +204,15 @@ describe("public overview build summary", () => {
expect(mocks.reads).not.toContain(weaponRecommendations);
});
});
describe("catalog picker reads", () => {
it("selects only character picker and export artwork fields", async () => {
mocks.rows.set(catalogCharacters, [{ key: "test", name: "Test", imageKey: "avatar", coopImageKey: "splash" }]);
const catalog = await getCatalogOptions();
expect(catalog?.characters[0].splashImageUrl).toBe("/media/splash");
expect(mocks.reads).not.toContain(catalogMaterials);
expect(Object.keys(mocks.selections[0] as object).sort()).toEqual([
"key", "name", "rarity", "weaponType", "element", "imageKey", "elementIconKey", "coopImageKey",
].sort());
});
});