Refactor NPC dialogue handling in project document JSON tests

This commit is contained in:
2026-04-15 09:32:33 +02:00
parent 8e2f38e2da
commit b304d604a2

View File

@@ -119,9 +119,8 @@ describe("project document JSON", () => {
const npc = createNpcEntity({ const npc = createNpcEntity({
id: "entity-npc-merchant", id: "entity-npc-merchant",
actorId: "actor-merchant", actorId: "actor-merchant",
dialogueId: "dialogue-market" dialogues: [
}); {
document.dialogues.dialogues["dialogue-market"] = {
id: "dialogue-market", id: "dialogue-market",
title: "Market", title: "Market",
lines: [ lines: [
@@ -131,7 +130,10 @@ describe("project document JSON", () => {
text: "Fresh bread." text: "Fresh bread."
} }
] ]
}; }
],
defaultDialogueId: "dialogue-market"
});
document.scenes[document.activeSceneId]!.entities[npc.id] = npc; document.scenes[document.activeSceneId]!.entities[npc.id] = npc;
expect(parseProjectDocumentJson(serializeProjectDocument(document))).toEqual( expect(parseProjectDocumentJson(serializeProjectDocument(document))).toEqual(
@@ -139,7 +141,7 @@ describe("project document JSON", () => {
); );
}); });
it("migrates project NPCs without dialogue references from v50 to null dialogue ids", () => { it("migrates project NPCs without dialogue references from v50 to null NPC dialogue defaults", () => {
const document = createEmptyProjectDocument({ const document = createEmptyProjectDocument({
name: "Legacy NPC Dialogue Project" name: "Legacy NPC Dialogue Project"
}); });
@@ -177,7 +179,8 @@ describe("project document JSON", () => {
expect(migratedNpc).toEqual( expect(migratedNpc).toEqual(
expect.objectContaining({ expect.objectContaining({
kind: "npc", kind: "npc",
dialogueId: null dialogues: [],
defaultDialogueId: null
}) })
); );
}); });
@@ -191,7 +194,10 @@ describe("project document JSON", () => {
actorId: "actor-vendor" actorId: "actor-vendor"
}); });
document.dialogues.dialogues["dialogue-market"] = { document.scenes[document.activeSceneId]!.entities[npc.id] = createNpcEntity({
...npc,
dialogues: [
{
id: "dialogue-market", id: "dialogue-market",
title: "Market Greeting", title: "Market Greeting",
lines: [ lines: [
@@ -201,15 +207,18 @@ describe("project document JSON", () => {
text: "Fresh fruit." text: "Fresh fruit."
} }
] ]
}; }
document.scenes[document.activeSceneId]!.entities[npc.id] = npc; ],
defaultDialogueId: "dialogue-market"
});
document.sequences.sequences["sequence-market-dialogue"] = createProjectSequence({ document.sequences.sequences["sequence-market-dialogue"] = createProjectSequence({
id: "sequence-market-dialogue", id: "sequence-market-dialogue",
title: "Market Greeting Sequence", title: "Market Greeting Sequence",
steps: [ steps: [
{ {
stepClass: "impulse", stepClass: "impulse",
type: "startDialogue", type: "makeNpcTalk",
npcEntityId: npc.id,
dialogueId: "dialogue-market" dialogueId: "dialogue-market"
} }
] ]