refactor(guides) : consolidate duplicate guide and Stygian logic
This commit is contained in:
@@ -27,9 +27,9 @@ vi.mock("@/db", () => ({
|
||||
import {
|
||||
artifactConditions, artifactProfiles, constellationConditions, extraSectionRows,
|
||||
guides, guideSections, teamCompositions, teamConditions, teamMembers, weaponConditions,
|
||||
catalogMaterials, guidePosterBleeding, media,
|
||||
catalogCharacters, catalogMaterials, guidePosterBleeding, media,
|
||||
} from "@/db/schema";
|
||||
import { getAdminGuideContent, listAdminTeamImportsForCharacter } from "./queries";
|
||||
import { getActiveCatalog, getAdminGuideContent, listAdminTeamImportsForCharacter } from "./queries";
|
||||
|
||||
beforeEach(() => {
|
||||
mocks.reads.length = 0;
|
||||
@@ -103,6 +103,48 @@ describe("admin section reads", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("character material metadata", () => {
|
||||
it.each(["catalog", "overview"] as const)(
|
||||
"preserves ascension and leveling metadata in the %s read",
|
||||
async (read) => {
|
||||
const character = {
|
||||
key: "test", imageKey: "character", constellations: [], talents: [],
|
||||
ascension: [{ type: "ascension", items: [{ key: "known", amount: 2 }, { key: "missing/key", amount: 3 }] }],
|
||||
leveling: [{ type: "leveling", items: [{ key: "missing/key", amount: 5 }, { key: "known", amount: 7 }] }],
|
||||
};
|
||||
const original = structuredClone(character);
|
||||
mocks.rows.set(catalogCharacters, [character]);
|
||||
mocks.rows.set(guides, [{
|
||||
guide: { id: "guide", slug: "test", posterArtMediaId: null },
|
||||
cover: { objectKey: "cover", status: "ready" },
|
||||
character,
|
||||
}]);
|
||||
mocks.rows.set(catalogMaterials, [{
|
||||
key: "known", name: "Known material", description: "Description",
|
||||
rarity: 4, type: "upgrade", imageKey: "material.webp",
|
||||
}]);
|
||||
|
||||
const result = read === "catalog"
|
||||
? (await getActiveCatalog())?.characters[0]
|
||||
: (await getAdminGuideContent("test", "overview"))?.character;
|
||||
const known = {
|
||||
key: "known", name: "Known material", description: "Description",
|
||||
rarity: 4, type: "upgrade", imageUrl: "/media/material.webp",
|
||||
lunarisUrl: "https://lunaris.moe/material/known", available: true,
|
||||
};
|
||||
const missing = {
|
||||
key: "missing/key", name: "missing/key", description: null,
|
||||
rarity: null, type: null, imageUrl: null,
|
||||
lunarisUrl: "https://lunaris.moe/material/missing%2Fkey", available: false,
|
||||
};
|
||||
expect(result?.ascension).toEqual([{ type: "ascension", items: [{ ...known, amount: 2 }, { ...missing, amount: 3 }] }]);
|
||||
expect(result?.leveling).toEqual([{ type: "leveling", items: [{ ...missing, amount: 5 }, { ...known, amount: 7 }] }]);
|
||||
expect(mocks.reads.filter((table) => table === catalogMaterials)).toHaveLength(1);
|
||||
expect(character).toEqual(original);
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
describe("team import lookup", () => {
|
||||
it("hydrates matching teams and source labels with one member read", async () => {
|
||||
mocks.rows.set(teamCompositions, [{
|
||||
|
||||
Reference in New Issue
Block a user