Merge branch 'master' into ai/issue-98
All checks were successful
Test / test (push) Successful in 2s
All checks were successful
Test / test (push) Successful in 2s
This commit is contained in:
@@ -329,6 +329,46 @@ test("an actor the world has never been seen as becomes one row, and the next im
|
||||
assert.equal(sync.models["../models/Actor"].rows[0].foundryActorId, "actor-9");
|
||||
});
|
||||
|
||||
// A forced sync from the module's context menu (Syndria98/dragonroll#96) replaces
|
||||
// everything the campaign holds for the actor; a live change is a merge and leaves the
|
||||
// fields the world says nothing about to the campaign.
|
||||
test("a forced actor sync clears what the campaign wrote; a live change keeps it", async () => {
|
||||
const sync = loadFoundryWriters({
|
||||
seed: { actors: [{
|
||||
_id: "actor-1",
|
||||
name: "Thalia",
|
||||
foundryActorId: "actor-1",
|
||||
traits: "A trait the campaign wrote",
|
||||
tools: ["Thieves' tools"],
|
||||
languages: ["Elvish"],
|
||||
skills: { perception: true },
|
||||
savingThrows: { dex: true },
|
||||
currency: { gp: 50 },
|
||||
}] },
|
||||
});
|
||||
// The world says nothing about any of those: the fields a live edit leaves out.
|
||||
const worldActor = { _id: "actor-1", name: "Thalia", type: "character", system: {} };
|
||||
|
||||
await sync.writers.saveFoundryActor(sync.campaign, worldActor, false, false);
|
||||
let row = sync.models["../models/Actor"].rows[0];
|
||||
assert.equal(row.traits, "A trait the campaign wrote", "a live push leaves what the campaign wrote alone");
|
||||
assert.deepEqual(row.tools, ["Thieves' tools"]);
|
||||
assert.deepEqual(row.languages, ["Elvish"]);
|
||||
assert.deepEqual(row.skills, { perception: true });
|
||||
assert.deepEqual(row.savingThrows, { dex: true });
|
||||
assert.deepEqual(row.currency, { gp: 50 });
|
||||
|
||||
await sync.writers.saveFoundryActor(sync.campaign, worldActor, false, true);
|
||||
row = sync.models["../models/Actor"].rows[0];
|
||||
assert.equal(row.name, "Thalia", "the actor is still the one the world sent");
|
||||
assert.equal(row.traits, "", "a forced sync clears the trait the campaign wrote");
|
||||
assert.deepEqual(row.tools, [], "and the tools, languages, skills, saving throws and coin it held");
|
||||
assert.deepEqual(row.languages, []);
|
||||
assert.deepEqual(row.skills, {});
|
||||
assert.deepEqual(row.savingThrows, {});
|
||||
assert.deepEqual(row.currency, {});
|
||||
});
|
||||
|
||||
test("a hand-made item folds into the import instead of doubling, and keeps being updated", async () => {
|
||||
const sync = loadFoundryWriters({
|
||||
seed: { items: [{ _id: "item-1", name: "Longsword", quantity: 1 }] },
|
||||
|
||||
Reference in New Issue
Block a user