Include traits on PF2e ability blocks

Parse and display traits (concentrate, divine, polymorph, etc.)
on ability entries, matching how attack traits are already shown.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Lukas
2026-04-07 16:29:08 +02:00
parent 3e62e54274
commit f9cfaa2570
2 changed files with 82 additions and 3 deletions

View File

@@ -170,6 +170,68 @@ describe("normalizePf2eBestiary", () => {
});
});
describe("ability traits formatting", () => {
it("includes traits from abilities in the text", () => {
const [creature] = normalizePf2eBestiary({
creature: [
minimalCreature({
abilities: {
bot: [
{
name: "Change Shape",
traits: [
"concentrate",
"divine",
"polymorph",
"transmutation",
],
entries: [
"The naunet can take the appearance of any creature.",
],
},
],
},
}),
],
});
const ability = creature.abilitiesBot?.[0];
expect(ability).toBeDefined();
expect(ability?.segments[0]).toEqual(
expect.objectContaining({
type: "text",
value: expect.stringContaining(
"(Concentrate, Divine, Polymorph, Transmutation)",
),
}),
);
});
it("renders ability without traits normally", () => {
const [creature] = normalizePf2eBestiary({
creature: [
minimalCreature({
abilities: {
bot: [
{
name: "Constrict",
entries: ["1d8+8 bludgeoning, DC 26"],
},
],
},
}),
],
});
const ability = creature.abilitiesBot?.[0];
expect(ability).toBeDefined();
expect(ability?.segments[0]).toEqual(
expect.objectContaining({
type: "text",
value: "1d8+8 bludgeoning, DC 26",
}),
);
});
});
describe("resistances formatting", () => {
it("formats resistance without amount", () => {
const [creature] = normalizePf2eBestiary({