Merge branch 'master' into ai/issue-64
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:
@@ -23,6 +23,7 @@ let updatingPairingStatus = false;
|
||||
let linkedCampaignName = "";
|
||||
let linkProblem = "";
|
||||
let actorSyncTimeout;
|
||||
let characterSyncRetryTimeout;
|
||||
let characterSyncRunning = false;
|
||||
let actorSyncErrorLogged = false;
|
||||
const syncingActorIds = new Set();
|
||||
@@ -1269,6 +1270,14 @@ async function reconcileDragonrollCharacters() {
|
||||
}
|
||||
}
|
||||
|
||||
// Both sides converge on a timer that only runs while the world is open, so a
|
||||
// round that could not reach Dragonroll is asked for again in a while instead of
|
||||
// leaving the campaign with whatever it happened to receive.
|
||||
function scheduleDragonrollCharacterSync(delay = 15000) {
|
||||
clearTimeout(characterSyncRetryTimeout);
|
||||
characterSyncRetryTimeout = setTimeout(reconcileDragonrollCharacters, delay);
|
||||
}
|
||||
|
||||
async function initializeCharacterSync() {
|
||||
if (!getSyncToken() || !game.user?.isGM || !game.world || !isAutoSyncEnabled()) return;
|
||||
try {
|
||||
|
||||
@@ -34,6 +34,13 @@ $themes: (
|
||||
green: #98c379,
|
||||
gray: #cccccc,
|
||||
|
||||
// The rarity of an item colours its row in the sidebar (Syndria98/dragonroll#63).
|
||||
rarity-common: #ffffff,
|
||||
rarity-uncommon: #1eff00,
|
||||
rarity-rare: #2f81f7,
|
||||
rarity-very-rare: #a855f7,
|
||||
rarity-legendary: #ff8000,
|
||||
|
||||
icon-invert: 100%,
|
||||
|
||||
search-background: #20202077,
|
||||
@@ -72,6 +79,13 @@ $themes: (
|
||||
green: #98c379,
|
||||
gray: #cccccc,
|
||||
|
||||
// Same rarities as the dark map, darkened to stay readable on a light background.
|
||||
rarity-common: #1e1e1e,
|
||||
rarity-uncommon: #157f2b,
|
||||
rarity-rare: #1d4ed8,
|
||||
rarity-very-rare: #7e22ce,
|
||||
rarity-legendary: #c05621,
|
||||
|
||||
icon-invert: 0%,
|
||||
|
||||
search-background: #f0f0f0aa,
|
||||
|
||||
@@ -279,8 +279,13 @@ function entrySummary(actor) {
|
||||
return bits.join(' · ');
|
||||
}
|
||||
|
||||
function itemSummary(item) {
|
||||
return `${t(`campaigns.item.categories.${item.category}`)} · ${t(`campaigns.item.rarities.${item.rarity}`)} · ${t('campaigns.item.quantity-short')} ${item.quantity}`;
|
||||
// The rarity of an item colours the text of its row instead of listing category, rarity and
|
||||
// quantity (Syndria98/dragonroll#63): common white, uncommon green, rare blue, very rare purple,
|
||||
// legendary orange. Anything else (artifact) keeps the default text colour.
|
||||
function rarityClass(item) {
|
||||
return ['common', 'uncommon', 'rare', 'very-rare', 'legendary'].includes(item.rarity)
|
||||
? `rarity-${item.rarity}`
|
||||
: '';
|
||||
}
|
||||
|
||||
// An item's icon in the sidebar: an uploaded filename served from /api/public, or a full URL
|
||||
@@ -681,9 +686,8 @@ onBeforeUnmount(() => {
|
||||
<span v-if="row.item.image" class="entity-entry-image" aria-hidden="true">
|
||||
<img :src="itemImageUrl(row.item.image)" alt="">
|
||||
</span>
|
||||
<span class="entity-entry-name">{{ row.item.name }}</span>
|
||||
<span class="entity-entry-name" :class="rarityClass(row.item)">{{ row.item.name }}</span>
|
||||
</span>
|
||||
<span class="entity-entry-meta">{{ itemSummary(row.item) }}</span>
|
||||
</div>
|
||||
</template>
|
||||
</template>
|
||||
@@ -877,6 +881,13 @@ onBeforeUnmount(() => {
|
||||
/* An item row leads with the item's own icon on the left of its name, standing in for the
|
||||
"SYNCED" text it used to show (Syndria98/dragonroll#53). */
|
||||
.entity-entry-title { display: flex; align-items: center; gap: 9px; min-width: 0; }
|
||||
/* The rarity of an item colours the text of its row (Syndria98/dragonroll#63): common white,
|
||||
uncommon green, rare blue, very rare purple, legendary orange. */
|
||||
.entity-entry-name.rarity-common { color: var(--color-rarity-common); }
|
||||
.entity-entry-name.rarity-uncommon { color: var(--color-rarity-uncommon); }
|
||||
.entity-entry-name.rarity-rare { color: var(--color-rarity-rare); }
|
||||
.entity-entry-name.rarity-very-rare { color: var(--color-rarity-very-rare); }
|
||||
.entity-entry-name.rarity-legendary { color: var(--color-rarity-legendary); }
|
||||
.entity-entry-image {
|
||||
flex: 0 0 30px; width: 30px; height: 30px; box-sizing: border-box;
|
||||
display: grid; place-items: center; overflow: hidden;
|
||||
|
||||
@@ -20,13 +20,13 @@ function initialForm() {
|
||||
if (!editing) {
|
||||
return {
|
||||
name: '', type: 'character', species: '', className: '', level: '', background: '', challengeRating: '',
|
||||
category: 'adventuring-gear', rarity: 'common', quantity: 1, weight: '', properties: '', description: ''
|
||||
category: 'adventuring-gear', rarity: 'common', weight: '', properties: '', description: ''
|
||||
};
|
||||
}
|
||||
return {
|
||||
name: editing.name ?? '', type: 'character', species: '', className: '', level: '', background: '', challengeRating: '',
|
||||
category: editing.category ?? 'adventuring-gear', rarity: editing.rarity ?? 'common',
|
||||
quantity: editing.quantity ?? 1, weight: editing.weight ?? '', properties: editing.properties ?? '',
|
||||
weight: editing.weight ?? '', properties: editing.properties ?? '',
|
||||
description: editing.description ?? ''
|
||||
};
|
||||
}
|
||||
@@ -49,7 +49,7 @@ async function saveEntry() {
|
||||
? { name: form.value.name.trim(), campaign: data.campaign }
|
||||
: { name: form.value.name.trim(), ...(editing ? { id: editing._id } : { campaign: data.campaign }) };
|
||||
if (!isActor) {
|
||||
for (const field of ['category', 'rarity', 'quantity', 'weight', 'properties', 'description']) {
|
||||
for (const field of ['category', 'rarity', 'weight', 'properties', 'description']) {
|
||||
payload[field] = form.value[field];
|
||||
}
|
||||
}
|
||||
@@ -105,10 +105,6 @@ async function saveEntry() {
|
||||
<option value="artifact">{{ $t('campaigns.item.rarities.artifact') }}</option>
|
||||
</select>
|
||||
</label>
|
||||
<label class="form-field">
|
||||
<span>{{ $t('campaigns.item.quantity') }}</span>
|
||||
<input v-model.number="form.quantity" type="number" min="1" required>
|
||||
</label>
|
||||
<label class="form-field">
|
||||
<span>{{ $t('campaigns.item.weight') }}</span>
|
||||
<input v-model="form.weight" type="number" min="0" step="0.1">
|
||||
|
||||
@@ -22,7 +22,6 @@ function normalizeItem(item) {
|
||||
name: item?.name ?? '',
|
||||
category: item?.category ?? 'adventuring-gear',
|
||||
rarity: item?.rarity ?? 'common',
|
||||
quantity: Number(item?.quantity ?? 1),
|
||||
weight: item?.weight ?? '',
|
||||
properties: item?.properties ?? '',
|
||||
description: item?.description ?? '',
|
||||
@@ -161,11 +160,9 @@ async function removeIcon() {
|
||||
<input ref="photoInput" class="photo-input" type="file" accept="image/*" @change="onIconSelected">
|
||||
</div>
|
||||
|
||||
<!-- Quantity is the actor inventory's business (Syndria98/dragonroll#63); the item
|
||||
sheet only states what the item itself is. -->
|
||||
<dl class="item-facts">
|
||||
<div class="item-fact">
|
||||
<dt>{{ $t('campaigns.item.quantity') }}</dt>
|
||||
<dd>{{ form.quantity }}</dd>
|
||||
</div>
|
||||
<div v-if="form.weight !== '' && form.weight !== undefined" class="item-fact">
|
||||
<dt>{{ $t('campaigns.item.weight') }}</dt>
|
||||
<dd>{{ Number(form.weight).toFixed(1) }} lb</dd>
|
||||
|
||||
@@ -65,8 +65,8 @@
|
||||
},
|
||||
"item": {
|
||||
"new": "Objecte nou", "edit": "Edita l'objecte", "foundry-sync-note": "Els canvis en aquest objecte també s'apliquen al món del Foundry vinculat.",
|
||||
"category": "Categoria", "rarity": "Raresa", "quantity": "Quantitat",
|
||||
"quantity-short": "Quant.", "weight": "Pes (lb)", "properties": "Propietats", "properties-placeholder": "Per exemple, versàtil, subtil",
|
||||
"category": "Categoria", "rarity": "Raresa",
|
||||
"weight": "Pes (lb)", "properties": "Propietats", "properties-placeholder": "Per exemple, versàtil, subtil",
|
||||
"sheet": {
|
||||
"icon": "Icona de l'objecte", "choose-icon": "Tria la teva pròpia icona", "change-icon": "Canvia la icona",
|
||||
"uploading": "Pujant...", "upload-error": "No s'ha pogut pujar aquesta icona.",
|
||||
|
||||
@@ -69,8 +69,8 @@
|
||||
},
|
||||
"item": {
|
||||
"new": "New item", "edit": "Edit item", "foundry-sync-note": "Changes to this item are also applied in the linked Foundry world.",
|
||||
"category": "Category", "rarity": "Rarity", "quantity": "Quantity",
|
||||
"quantity-short": "Qty", "weight": "Weight (lb)", "properties": "Properties", "properties-placeholder": "For example, versatile, finesse",
|
||||
"category": "Category", "rarity": "Rarity",
|
||||
"weight": "Weight (lb)", "properties": "Properties", "properties-placeholder": "For example, versatile, finesse",
|
||||
"sheet": {
|
||||
"icon": "Item icon", "choose-icon": "Choose your own icon", "change-icon": "Change icon",
|
||||
"uploading": "Uploading...", "upload-error": "Unable to upload this icon.",
|
||||
|
||||
@@ -65,8 +65,8 @@
|
||||
},
|
||||
"item": {
|
||||
"new": "Nuevo objeto", "edit": "Editar objeto", "foundry-sync-note": "Los cambios en este objeto también se aplican al mundo de Foundry vinculado.",
|
||||
"category": "Categoría", "rarity": "Rareza", "quantity": "Cantidad",
|
||||
"quantity-short": "Cant.", "weight": "Peso (lb)", "properties": "Propiedades", "properties-placeholder": "Por ejemplo, versátil, sutil",
|
||||
"category": "Categoría", "rarity": "Rareza",
|
||||
"weight": "Peso (lb)", "properties": "Propiedades", "properties-placeholder": "Por ejemplo, versátil, sutil",
|
||||
"sheet": {
|
||||
"icon": "Icono del objeto", "choose-icon": "Elegir tu propio icono", "change-icon": "Cambiar icono",
|
||||
"uploading": "Subiendo...", "upload-error": "No se pudo subir este icono.",
|
||||
|
||||
@@ -57,7 +57,7 @@ function matches(document, filter = {}) {
|
||||
});
|
||||
}
|
||||
|
||||
function fakeModel(table, seed = []) {
|
||||
function fakeModel(table, seed = [], campaignId) {
|
||||
const rows = [];
|
||||
let counter = 0;
|
||||
|
||||
@@ -76,7 +76,9 @@ function fakeModel(table, seed = []) {
|
||||
Object.defineProperty(Document.prototype, "id", { get() { return this._id; } });
|
||||
|
||||
for (const data of seed) {
|
||||
const row = new Document({ [table === "folder" ? "target" : "name"]: undefined, ...data });
|
||||
// A seeded row belongs to the campaign the requests are made against unless the
|
||||
// seed says otherwise: the routes scope every lookup by campaign.
|
||||
const row = new Document({ campaign: campaignId, [table === "folder" ? "target" : "name"]: undefined, ...data });
|
||||
row.isNew = false;
|
||||
rows.push(row);
|
||||
}
|
||||
@@ -373,9 +375,12 @@ test("every folder listing says which campaign list it belongs to", () => {
|
||||
// field existed carry none at all. tests/entry-folders.test.js runs these routes.
|
||||
for (const route of ["note.js", "folder.js"]) {
|
||||
const source = read("backend", "src", "routes", route);
|
||||
const listings = source.match(/Folder\.find\(/g) ?? [];
|
||||
// The listings that gather a campaign's folders are the ones shown as a section's
|
||||
// tree. A walk of one folder's own children (`parentFolder`) is inside a single
|
||||
// list already: folders are only ever nested within their own section.
|
||||
const listings = source.match(/Folder\.find\(\{\s*campaign/g) ?? [];
|
||||
assert.ok(listings.length, `${route} lists folders`);
|
||||
const filtered = source.match(/Folder\.find\(\{[^{]*Folder\.filterForTarget\((?:'note'|target)\)/g) ?? [];
|
||||
const filtered = source.match(/Folder\.find\(\{\s*campaign[^{]*Folder\.filterForTarget\((?:'note'|target)\)/g) ?? [];
|
||||
assert.equal(filtered.length, listings.length, `${route} has a folder listing that names no campaign list`);
|
||||
}
|
||||
});
|
||||
@@ -725,13 +730,15 @@ test("items are grouped under the folder they stand in, nested", () => {
|
||||
row.kind, row.kind === "folder" ? row.folder.name : row.item.name, row.depth,
|
||||
]);
|
||||
|
||||
// Every folder is followed by what stands in it, one step deeper, and the items that
|
||||
// stand at the root come last (see BuildItemRows).
|
||||
assert.deepEqual(shape, [
|
||||
["folder", "Melee Weapons", 0],
|
||||
["item", "Longsword", 1],
|
||||
["folder", "Ranged Weapons", 0],
|
||||
["folder", "Powder Weapons", 1],
|
||||
["item", "Pistol", 1],
|
||||
["item", "Pistol", 2],
|
||||
["item", "Torch", 0],
|
||||
["item", "Longsword", 1],
|
||||
]);
|
||||
});
|
||||
|
||||
@@ -758,9 +765,9 @@ test("an item whose folder is gone, or a folder nested in itself, reads as a roo
|
||||
);
|
||||
|
||||
const shape = rows.map((row) => [row.kind, row.kind === "folder" ? row.folder.name : row.item.name]);
|
||||
assert.ok(shape.includes(["item", "Torch"]), "the item is not lost with the folder that was removed");
|
||||
assert.ok(shape.some(([kind, name]) => kind === "item" && name === "Torch"), "the item is not lost with the folder that was removed");
|
||||
assert.deepEqual(new Set(shape.filter(([kind]) => kind === "folder").map(([, name]) => name)), new Set(["A", "B"]));
|
||||
assert.equal(rows.filter(([kind]) => kind === "folder").length, 2, "a broken tree is walked once, not forever");
|
||||
assert.equal(shape.filter(([kind]) => kind === "folder").length, 2, "a broken tree is walked once, not forever");
|
||||
});
|
||||
|
||||
test("every locale labels the folder row", () => {
|
||||
|
||||
89
tests/item-rarity-entry.test.js
Normal file
89
tests/item-rarity-entry.test.js
Normal file
@@ -0,0 +1,89 @@
|
||||
// Tests for Syndria98/dragonroll#63: the item rows in the campaign sidebar dropped the text
|
||||
// listing category, rarity and quantity — the rarity colours the text of the entry instead
|
||||
// (common white, uncommon green, rare blue, very rare purple, legendary orange) — and the
|
||||
// quantity left the item surfaces altogether, since it only belongs to an actor's inventory.
|
||||
//
|
||||
// The repository root installs no dependencies, so these read the sources the way
|
||||
// tests/item-entry-display.test.js does — the checks are about the markup and style.
|
||||
//
|
||||
// Run with `npm test` from the repository root, or `node --test tests/`.
|
||||
|
||||
const { test } = require("node:test");
|
||||
const assert = require("node:assert/strict");
|
||||
const fs = require("node:fs");
|
||||
const path = require("node:path");
|
||||
|
||||
const read = (...parts) => fs.readFileSync(path.join(__dirname, "..", ...parts), "utf8");
|
||||
|
||||
const sidebarSource = read("frontend", "app", "components", "partials", "ContentSidebar.vue");
|
||||
const itemWindowSource = read("frontend", "app", "components", "windows", "ItemSheetWindow.vue");
|
||||
const entryFormSource = read("frontend", "app", "components", "windows", "CreateCampaignEntryWindow.vue");
|
||||
const sheetSource = read("frontend", "app", "components", "windows", "CharacterSheetWindow.vue");
|
||||
const colorsSource = read("frontend", "app", "assets", "css", "colors.scss");
|
||||
|
||||
// The block that renders the item rows, as in tests/item-entry-display.test.js.
|
||||
const itemSection =
|
||||
/<template v-else-if="activeSection === 'items'">([\s\S]*?)<\/template>\s*\n\s*<template v-else>/.exec(sidebarSource)?.[1] ?? "";
|
||||
|
||||
const rarities = ["common", "uncommon", "rare", "very-rare", "legendary"];
|
||||
|
||||
// `selector` is inserted verbatim, so escape the `.` of a class combination. Comments are dropped:
|
||||
// they explain a rule, they are not part of it.
|
||||
function ruleFor(selector) {
|
||||
const rule = new RegExp(`\\.${selector}\\s*\\{([^}]*)\\}`).exec(sidebarSource)?.[0];
|
||||
return rule?.replace(/\/\*[\s\S]*?\*\//g, "");
|
||||
}
|
||||
|
||||
test("the item entry no longer lists the category, rarity and quantity as text", () => {
|
||||
assert.ok(itemSection, "expected to find the items section of the sidebar");
|
||||
assert.doesNotMatch(itemSection, /entity-entry-meta/, "the item row must not render a meta line");
|
||||
assert.doesNotMatch(itemSection, /campaigns\.item\.(categories|rarities|quantity)/, "the item row must not render item meta text");
|
||||
assert.doesNotMatch(sidebarSource, /itemSummary/, "the removed summary helper must not be kept around");
|
||||
});
|
||||
|
||||
test("the rarity of an item picks a class for the text of its entry", () => {
|
||||
assert.match(
|
||||
itemSection,
|
||||
/<span class="entity-entry-name" :class="rarityClass\(row\.item\)"/,
|
||||
"the item name must carry the class picked from its rarity"
|
||||
);
|
||||
const helper = /function rarityClass\(item\)\s*\{[\s\S]*?\n\}/.exec(sidebarSource)?.[0] ?? "";
|
||||
assert.ok(helper, "expected a rarityClass helper");
|
||||
for (const rarity of rarities) {
|
||||
assert.ok(helper.includes(`'${rarity}'`), `rarityClass must know about '${rarity}'`);
|
||||
}
|
||||
});
|
||||
|
||||
test("each rarity colours the entry text with its own theme colour", () => {
|
||||
for (const rarity of rarities) {
|
||||
const rule = ruleFor(`entity-entry-name\\.rarity-${rarity}`);
|
||||
assert.ok(rule, `expected a colour rule for .entity-entry-name.rarity-${rarity}`);
|
||||
assert.match(rule, new RegExp(`color:\\s*var\\(--color-rarity-${rarity}\\)`));
|
||||
}
|
||||
});
|
||||
|
||||
test("both theme maps carry the rarity colours", () => {
|
||||
for (const rarity of rarities) {
|
||||
const declarations = colorsSource.match(new RegExp(`rarity-${rarity}:\\s*#[0-9a-fA-F]{6}`, "g")) || [];
|
||||
assert.equal(declarations.length, 2, `expected rarity-${rarity} in both the dark and the light map`);
|
||||
}
|
||||
});
|
||||
|
||||
test("the quantity only shows in an actor's inventory", () => {
|
||||
assert.doesNotMatch(itemWindowSource, /quantity/, "the item window must not list the quantity");
|
||||
assert.doesNotMatch(entryFormSource, /quantity/, "the item create/edit form must not offer the quantity");
|
||||
// the character sheet's inventory table keeps it.
|
||||
assert.match(sheetSource, /campaigns\.character-sheet\.quantity/);
|
||||
assert.match(sheetSource, /\{\{ item\.quantity \}\}/);
|
||||
});
|
||||
|
||||
test("no locale keeps the removed item quantity strings", () => {
|
||||
for (const locale of ["en", "es", "ca"]) {
|
||||
const campaigns = JSON.parse(read("frontend", "i18n", "locales", locale, "campaigns.json"));
|
||||
assert.ok(campaigns.item, `${locale} is missing the campaigns.item block`);
|
||||
assert.equal(campaigns.item.quantity, undefined, `${locale} still has campaigns.item.quantity`);
|
||||
assert.equal(campaigns.item["quantity-short"], undefined, `${locale} still has campaigns.item.quantity-short`);
|
||||
// the character sheet's inventory keeps its own quantity column label
|
||||
assert.ok(campaigns["character-sheet"]?.quantity, `${locale} is missing campaigns.character-sheet.quantity`);
|
||||
}
|
||||
});
|
||||
@@ -66,17 +66,19 @@ test("the item routes accept the icon and upload one", () => {
|
||||
test("the item info window is registered and opens on a sidebar click", () => {
|
||||
assert.match(windowDefsSource, /item_sheet:\s*{\s*title:[^}]*ItemSheetWindow\.vue/s);
|
||||
// clicking (or Enter/Space on) an item row opens the window instead of expanding inline.
|
||||
// Since #44 the rows come from the folder tree the world synced, so the row holds the item.
|
||||
assert.match(sidebarSource, /v-for="row in itemRows"[\s\S]*?@click="openItemSheet\(row\.item\)"/);
|
||||
// The rows come from the item list's folder tree, so the row holds the item.
|
||||
assert.match(sidebarSource, /v-for="row in entryRows\.item\.value"[\s\S]*?@click="openItemSheet\(row\.item\)"/);
|
||||
assert.match(sidebarSource, /CreateWindow\(['"]item_sheet['"],\s*\{ item \}\)/);
|
||||
assert.doesNotMatch(sidebarSource, /toggleEntryDetails/);
|
||||
});
|
||||
|
||||
test("the item window shows the info and offers both icon sources", () => {
|
||||
// info: name, category, rarity, quantity, weight, properties, description
|
||||
for (const key of ["form.name", "form.category", "form.rarity", "form.quantity", "form.weight", "form.properties", "form.description"]) {
|
||||
// info: name, category, rarity, weight, properties, description — quantity is gone
|
||||
// (#63 keeps it for the actors' inventories).
|
||||
for (const key of ["form.name", "form.category", "form.rarity", "form.weight", "form.properties", "form.description"]) {
|
||||
assert.ok(itemWindowSource.includes(key), `expected the window to render ${key}`);
|
||||
}
|
||||
assert.doesNotMatch(itemWindowSource, /quantity/, "the item window must not list the quantity");
|
||||
// own icon: upload through the item route like the character sheet does its photo
|
||||
assert.match(itemWindowSource, /\/item\/upload-image\?item=/);
|
||||
// Foundry icon: switch the item image back to the one the world sent
|
||||
|
||||
@@ -85,6 +85,9 @@ function loadMapRoutes({ ownsCampaign = true, maps = [], notes = [] } = {}) {
|
||||
},
|
||||
// The pins do not ask after actors, only the token routes below do.
|
||||
"../models/Actor": { findOne: () => mongooseQuery(null) },
|
||||
// The map list's own folder tree: `/list` reads it and `/update` checks a move
|
||||
// against it, so the pins need the model to answer, never what it answers.
|
||||
"../models/Folder": { find: () => mongooseQuery([]), belongsToSection: async () => true },
|
||||
});
|
||||
}
|
||||
|
||||
@@ -181,7 +184,12 @@ function loadNoteRoutes({ ownsCampaign = true, notes = [], folders = [], deleted
|
||||
findById: (id) => mongooseQuery(notes.find((note) => note._id === id) ?? null),
|
||||
deleteOne: () => mongooseQuery({ deletedCount }),
|
||||
},
|
||||
"../models/Folder": { find: () => mongooseQuery(folders) },
|
||||
"../models/Folder": {
|
||||
find: () => mongooseQuery(folders),
|
||||
// models/Folder.js: the note tree is every folder that is not one of the other
|
||||
// campaign lists, whose rows carry no target at all.
|
||||
filterForTarget: (target) => (target === "note" ? { target: { $nin: ["actor", "item", "map"] } } : { target }),
|
||||
},
|
||||
"../models/Map": {
|
||||
// The driver drops the pins of the note from every map holding one; what is worth
|
||||
// keeping here is the filter it is asked to do that with.
|
||||
|
||||
@@ -82,6 +82,9 @@ function loadMapRoutes({ ownsCampaign = true, maps = [], actors = [] } = {}) {
|
||||
: null
|
||||
),
|
||||
},
|
||||
// The map list's own folder tree: `/list` reads it and `/update` checks a move
|
||||
// against it, so the tokens need the model to answer, never what it answers.
|
||||
"../models/Folder": { find: () => mongooseQuery([]), belongsToSection: async () => true },
|
||||
});
|
||||
}
|
||||
|
||||
@@ -188,6 +191,8 @@ function loadActorRoutes({ ownsCampaign = true, actors = [], deletedCount = 1 }
|
||||
return { modifiedCount: 1 };
|
||||
},
|
||||
},
|
||||
// The actor list's own folder tree, which the delete does not ask after.
|
||||
"../models/Folder": { find: () => mongooseQuery([]), belongsToSection: async () => true },
|
||||
});
|
||||
return { api, tokensPulled };
|
||||
}
|
||||
@@ -299,10 +304,14 @@ function mapViewerTokenWiringTests() {
|
||||
const sidebar = readRepoFile("frontend", "app", "components", "partials", "ContentSidebar.vue");
|
||||
|
||||
test("an actor row of the sidebar can be dragged out of it", () => {
|
||||
const actorRow = /<div v-for="actor in actors"[^>]*>/.exec(sidebar)?.[0];
|
||||
// The actors' block of the sidebar: since the entry lists got their folders the rows
|
||||
// come from that tree, so the actor row holds its actor as `row.item`.
|
||||
const actorSection = /<template v-else-if="activeSection === 'actors'">([\s\S]*?)<\/template>\s*\n\s*<template v-else-if="activeSection === 'items'">/
|
||||
.exec(sidebar)?.[1] ?? "";
|
||||
const actorRow = /<div v-else class="entity-entry"[^>]*>/.exec(actorSection)?.[0];
|
||||
assert.ok(actorRow, "expected the actor rows of the sidebar");
|
||||
assert.match(actorRow, /draggable="true"/);
|
||||
assert.match(actorRow, /@dragstart="startActorDrag\(\$event, actor\)"/);
|
||||
assert.match(actorRow, /@dragstart="startActorDrag\(\$event, row\.item\)"/);
|
||||
assert.match(sidebar, /setData\(ACTOR_DRAG_TYPE, String\(actor\._id\)\)/);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user