feat : Con more reaible

This commit is contained in:
2026-09-26 20:54:40 +07:00 Unverified
parent bfd9f1765d
commit 17c4f21948
11 changed files with 325 additions and 24 deletions
+54
View File
@@ -8,6 +8,7 @@ import {
characterDetailSchema,
cleanLunarisText,
constellationSnapshot,
parseLunarisText,
nameCardImageName,
splashImageName,
supportsWeaponType,
@@ -41,6 +42,58 @@ describe("Lunaris character data", () => {
expect(cleanLunarisText("First line\\n\\n<i>Second line</i>")).toBe("First line\n\nSecond line");
});
it("parses Lunaris links and colors into safe display nodes", () => {
const links = new Map([["N11500003", {
name: "Marvelous Splendor",
description: "A special stack effect.",
}]]);
expect(parseLunarisText(
"Gain {LINK#N11500003}Marvelous Splendor{/LINK} and deal <color=#99FFFFFF>Cryo AoE DMG</color>.",
links,
)).toEqual([
{ type: "text", value: "Gain " },
{
type: "link",
target: "N11500003",
detail: { name: "Marvelous Splendor", description: "A special stack effect." },
children: [{ type: "text", value: "Marvelous Splendor" }],
},
{ type: "text", value: " and deal " },
{
type: "color",
value: "#99FFFFFF",
children: [{ type: "text", value: "Cryo AoE DMG" }],
},
{ type: "text", value: "." },
]);
});
it("resolves named skill links and ignores malformed display tags", () => {
const skills = new Map([["Slow Dance", {
name: "Slow Dance",
description: "Skill detail",
}]]);
expect(parseLunarisText(
"{LINK#S11502}<color=#FFD780FF>Slow Dance</color>{/LINK}</color>\n<color=javascript:alert(1)>Safe</color>",
new Map(),
skills,
)).toEqual([
{
type: "link",
target: "S11502",
detail: { name: "Slow Dance", description: "Skill detail" },
children: [{
type: "color",
value: "#FFD780FF",
children: [{ type: "text", value: "Slow Dance" }],
}],
},
{ type: "text", value: "\nSafe" },
]);
});
it("normalizes constellation levels and icon keys", () => {
const result = constellationSnapshot({
constellations: {
@@ -51,6 +104,7 @@ describe("Lunaris character data", () => {
level: 1,
name: "First",
description: "Detail",
descriptionNodes: [{ type: "text", value: "Detail" }],
iconKey: "catalog/1/constellations/UI_Talent_Test_01.webp",
}]);
});