Fix issue #96: When right clicking actor on foundry, show action to force sync to dragonroll
All checks were successful
Test / test (push) Successful in 2s

This commit is contained in:
Gitea OpenCode Agent
2026-10-15 22:53:03 +00:00
parent dcc6d7a14b
commit 967c704801
7 changed files with 115 additions and 14 deletions

View File

@@ -410,6 +410,36 @@ test("an actor that holds no traits does not clear what the campaign has", () =>
assert.ok(!("traits" in character), "a live edit that knows nothing about traits leaves the tab as it is");
});
// A forced actor sync from the module's context menu replaces everything the campaign
// holds for that actor (Syndria98/dragonroll#96): the fields a live edit leaves out when
// the world says nothing are written empty instead of kept, and the campaign's own text
// on the actor's flag does not survive it.
test("a forced sync writes empty the fields a live edit would leave out", () => {
const actor = {
name: "Thalia",
system: {},
items: [],
flags: { [MODULE_ID]: { traits: "What the campaign typed", proficiencies: "Armour, tools" } },
};
const live = foundryActorToCharacter(actor);
assert.equal(live.traits, "What the campaign typed", "a live edit fills the traits tab from the actor's flag");
assert.equal(live.proficiencies, "Armour, tools", "and the free-text proficiencies from it too");
assert.ok(
!("tools" in live) && !("languages" in live) && !("skills" in live) && !("savingThrows" in live) && !("currency" in live),
"and says nothing about the toggles and lists the world has no data for"
);
const replaced = foundryActorToCharacter(actor, true);
assert.equal(replaced.traits, "", "a forced sync clears the traits the campaign typed");
assert.equal(replaced.proficiencies, "", "down to the free-text proficiencies");
assert.deepEqual(replaced.tools, []);
assert.deepEqual(replaced.languages, []);
assert.deepEqual(replaced.skills, {});
assert.deepEqual(replaced.savingThrows, {});
assert.deepEqual(replaced.currency, {});
});
// --- The module sends the names a sheet outside Foundry can read -----------------
function makeWorld({ actor, config = {}, worldItems = [] }) {