Add toolbox spaces and recover from stale asset bundles
All checks were successful
Deploy Sokko G / deploy (push) Successful in 18s
All checks were successful
Deploy Sokko G / deploy (push) Successful in 18s
This commit is contained in:
parent
0959c6740b
commit
0acf5ecf21
30 changed files with 1252 additions and 179 deletions
|
|
@ -15,6 +15,7 @@ import { createBalancedTeams, drawWeightedEntries, filterExclusionsForPlayers, g
|
|||
import { calculateAtLeastOneProbability, calculateDrawsForChance, calculateRngCostSummary, calculateRngRealDrawsSummary, calculateRngSummary, getAveragePositionStatus, getDurationPresetsForAverageHours, getEffectiveRate, normalizeCostString, normalizeRateString, simulateRngDraws } from "../website/src/features/toolboxes/modules/rngSimulatorUtils.js";
|
||||
import { getTimePatternRecurrenceMs, getTimePatternTargetMs } from "../website/src/features/toolboxes/modules/timerUtils.js";
|
||||
import { compactModuleDataForStorage, createToolboxExportPayload, moduleStorageKey, normalizeCalculatorData, normalizeChecklistData, normalizeCombosData, normalizeCountersData, normalizeEquipmentPlannerData, normalizeGoalTreeData, normalizeImageAnnotationData, normalizeLinksData, normalizeMemosData, normalizeModuleOrder, normalizeNotepadData, normalizeRandomizerData, normalizeRngSimulatorData, normalizeTableData, normalizeTaskPlannerData, normalizeTimerData, normalizeToolbox, normalizeUrl, summarizeEquipmentPlannerData } from "../website/src/features/toolboxes/storage/toolboxStorage.js";
|
||||
import { createToolboxSpace, deleteToolboxSpace, moveToolboxModule, reorderToolboxSpaces } from "../website/src/features/toolboxes/toolboxSpaceUtils.js";
|
||||
import { applyGroupedReorderOperation, completeGroupOrder, getBoundaryItemId, getGroupedEntries, moveGroupOrder, moveGroupOrderToEnd, moveGroupOrderToStart, moveItem, moveItemGroup } from "../website/src/hooks/useGroupedReorder.js";
|
||||
|
||||
function createTextImportContext() {
|
||||
|
|
@ -989,6 +990,48 @@ test("toolbox modules preserve only active shell display options", () => {
|
|||
assert.equal("collapsed" in toolbox.modules[1], false);
|
||||
});
|
||||
|
||||
test("legacy toolbox order becomes a persistent default space", () => {
|
||||
const toolbox = normalizeToolbox({
|
||||
id: "legacy",
|
||||
modules: [{ id: "a", type: "notepad" }, { id: "b", type: "links" }],
|
||||
moduleOrder: { one: ["b", "a"], two: [["a"], ["b"]] }
|
||||
});
|
||||
assert.equal(toolbox.spaces.length, 1);
|
||||
assert.equal(toolbox.spaces[0].name, "Défaut");
|
||||
assert.equal(toolbox.defaultSpaceId, toolbox.spaces[0].id);
|
||||
assert.equal(toolbox.activeSpaceId, toolbox.spaces[0].id);
|
||||
assert.deepEqual(toolbox.spaces[0].moduleOrder, { one: ["b", "a"], two: [["a"], ["b"]] });
|
||||
});
|
||||
|
||||
test("spaces move modules, preserve inactive orders and merge deleted spaces into default", () => {
|
||||
let toolbox = normalizeToolbox({
|
||||
id: "spaces",
|
||||
modules: ["a", "b", "c"].map((id) => ({ id, type: "counters" })),
|
||||
moduleOrder: { one: ["a", "b", "c"], two: [["a", "b"], ["c"]] }
|
||||
});
|
||||
toolbox = createToolboxSpace(toolbox, "Boss");
|
||||
const bossId = toolbox.activeSpaceId;
|
||||
toolbox = moveToolboxModule(toolbox, "b", { targetSpaceId: bossId, moduleColumns: 1 });
|
||||
assert.deepEqual(toolbox.spaces[0].moduleOrder, { one: ["a", "c"], two: [["a"], ["c"]] });
|
||||
assert.deepEqual(toolbox.spaces[1].moduleOrder, { one: ["b"], two: [["b"], []] });
|
||||
toolbox = deleteToolboxSpace(toolbox, bossId);
|
||||
assert.deepEqual(toolbox.spaces[0].moduleOrder, { one: ["a", "c", "b"], two: [["a", "b"], ["c"]] });
|
||||
});
|
||||
|
||||
test("the default space stays first when secondary spaces are reordered", () => {
|
||||
let toolbox = normalizeToolbox({ modules: [] });
|
||||
toolbox = createToolboxSpace(toolbox, "Deux");
|
||||
const secondId = toolbox.activeSpaceId;
|
||||
toolbox = createToolboxSpace(toolbox, "Trois");
|
||||
const thirdId = toolbox.activeSpaceId;
|
||||
toolbox = reorderToolboxSpaces(toolbox, thirdId, secondId, "before");
|
||||
assert.equal(toolbox.spaces[0].id, toolbox.defaultSpaceId);
|
||||
assert.deepEqual(toolbox.spaces.slice(1).map((space) => space.id), [thirdId, secondId]);
|
||||
toolbox = createToolboxSpace(createToolboxSpace(toolbox, "Quatre"), "Cinq");
|
||||
assert.equal(toolbox.spaces.length, 5);
|
||||
assert.equal(createToolboxSpace(toolbox, "Six").spaces.length, 5);
|
||||
});
|
||||
|
||||
test("toolbox export remaps module order ids", () => {
|
||||
const payload = createToolboxExportPayload(
|
||||
{
|
||||
|
|
@ -1004,11 +1047,32 @@ test("toolbox export remaps module order ids", () => {
|
|||
);
|
||||
|
||||
assert.deepEqual(payload.toolbox.modules.map((module) => module.id), ["m1", "m2", "m3"]);
|
||||
assert.deepEqual(payload.toolbox.moduleOrder, {
|
||||
assert.equal(payload.version, 2);
|
||||
assert.deepEqual(payload.toolbox.spaces[0].moduleOrder, {
|
||||
one: ["m3", "m1", "m2"],
|
||||
two: [["m2"], ["m3", "m1"]]
|
||||
});
|
||||
assert.deepEqual(normalizeToolbox(payload.toolbox).moduleOrder, payload.toolbox.moduleOrder);
|
||||
assert.deepEqual(normalizeToolbox(payload.toolbox).spaces[0].moduleOrder, payload.toolbox.spaces[0].moduleOrder);
|
||||
});
|
||||
|
||||
test("toolbox export remaps space ids and preserves the active space", () => {
|
||||
const payload = createToolboxExportPayload({
|
||||
id: "toolbox-spaces",
|
||||
name: "Spaces",
|
||||
modules: [{ id: "module1", type: "notepad" }, { id: "module2", type: "links" }],
|
||||
spaces: [
|
||||
{ id: "default", name: "Défaut", moduleOrder: { one: ["module1"], two: [["module1"], []] } },
|
||||
{ id: "boss", name: "Boss", moduleOrder: { one: ["module2"], two: [[], ["module2"]] } }
|
||||
],
|
||||
defaultSpaceId: "default",
|
||||
activeSpaceId: "boss"
|
||||
}, {});
|
||||
assert.equal(payload.toolbox.spaces.length, 2);
|
||||
assert.notEqual(payload.toolbox.defaultSpaceId, "default");
|
||||
assert.notEqual(payload.toolbox.activeSpaceId, "boss");
|
||||
assert.equal(payload.toolbox.defaultSpaceId, payload.toolbox.spaces[0].id);
|
||||
assert.equal(payload.toolbox.activeSpaceId, payload.toolbox.spaces[1].id);
|
||||
assert.deepEqual(payload.toolbox.spaces.map((space) => space.moduleOrder.one), [["m1"], ["m2"]]);
|
||||
});
|
||||
|
||||
test("toolbox export remaps randomizer multi-target exclusions", () => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue