Allow toolbox tools to collapse into their headers
All checks were successful
Deploy Sokko G / deploy (push) Successful in 17s

This commit is contained in:
Shinuwa 2026-09-24 14:05:17 +02:00
parent 1df7b32dbb
commit b5901b31e3
8 changed files with 228 additions and 166 deletions

View file

@ -92,7 +92,8 @@ test("toolbox module registry and modules expose expected behavior", async () =>
const moduleComponents = await readFile("website/src/features/toolboxes/modules/toolboxModuleComponents.jsx", "utf8");
const addToolControls = await readFile("website/src/features/toolboxes/modules/AddToolControls.jsx", "utf8");
const toolboxModules = await readFile("website/src/features/toolboxes/modules/ToolboxModules.jsx", "utf8");
const moduleRegistryBundle = `${moduleRegistry}\n${moduleComponents}\n${addToolControls}\n${toolboxModules}`;
const moduleShell = await readFile("website/src/features/toolboxes/modules/ModuleShell.jsx", "utf8");
const moduleRegistryBundle = `${moduleRegistry}\n${moduleComponents}\n${addToolControls}\n${toolboxModules}\n${moduleShell}`;
const moduleMetadataRegistry = await readFile("website/src/features/toolboxes/toolboxModuleRegistry.js", "utf8");
const notepadModule = await readFile("website/src/features/toolboxes/modules/NotepadModule.jsx", "utf8");
const notepadToolbar = await readFile("website/src/features/toolboxes/modules/NotepadToolbar.jsx", "utf8");
@ -189,6 +190,7 @@ test("toolbox module registry and modules expose expected behavior", async () =>
[
["AddToolControls.jsx", addToolControls],
["ToolboxModules.jsx", toolboxModules],
["ModuleShell.jsx", moduleShell],
["useCalendarController.js", calendarController],
["useCalendarDraftControls.js", calendarDraftControls],
["calendarEventActions.js", calendarEventActions],
@ -212,21 +214,24 @@ test("toolbox module registry and modules expose expected behavior", async () =>
assert.match(moduleRegistry, /export \{ AddToolControls \}/);
assert.match(moduleRegistry, /export \{ ToolboxModules \}/);
assert.match(moduleComponents, /MODULE_COMPONENTS/);
assert.match(toolboxModules, /Suspense fallback=\{<ModuleLoadingFallback label=\{label\} \/>\}/);
assert.match(moduleShell, /Suspense fallback=\{<ModuleLoadingFallback label=\{label\} \/>\}/);
assert.match(moduleMetadataRegistry, /Planificateur d'équipements/);
assert.match(moduleMetadataRegistry, /Annotation d'images/);
assert.match(toolboxModules, /module-edit-button/);
assert.match(toolboxModules, /itemReorder\.startDrag/);
assert.match(moduleShell, /module-edit-button/);
assert.match(moduleShell, /itemReorder\.startDrag/);
assert.match(moduleRegistryBundle, /onPointerDown/);
assert.match(toolboxModules, /useGroupedReorder/);
assert.match(toolboxModules, /useInlineEdit/);
assert.match(toolboxModules, /getContentEditableProps/);
assert.match(moduleShell, /useInlineEdit/);
assert.match(moduleShell, /getContentEditableProps/);
assert.match(addToolControls, /tool-add-card/);
assert.match(addToolControls, /tool-quick-add-button/);
assert.match(addToolControls, /tool-add-quick-toggle/);
assert.match(moduleMetadataRegistry, /scrollable: true/);
assert.match(toolboxModules, /module-content/);
assert.match(toolboxModules, /module-scroll-button/);
assert.match(moduleShell, /module-content/);
assert.match(moduleShell, /module-scroll-button/);
assert.match(moduleShell, /module-collapse-button/);
assert.match(moduleShell, /aria-expanded=\{!collapsed\}/);
assert.match(moduleShell, /!collapsed &&/);
assert.match(addToolControls, /Icon name="dropdown"/);
assert.match(addToolControls, /CompactDropdown/);
assert.doesNotMatch(source, /<select value="" onChange=\{\(event\) => addModule/);

View file

@ -968,6 +968,19 @@ test("toolbox module order normalizes one and two column layouts", () => {
}, modules).two, [["a", "b", "c", "d"], []]);
});
test("toolbox modules preserve only active shell display options", () => {
const toolbox = normalizeToolbox({
modules: [
{ id: "collapsed", type: "notepad", collapsed: true, scrollable: true },
{ id: "expanded", type: "links", collapsed: false }
]
});
assert.equal(toolbox.modules[0].collapsed, true);
assert.equal(toolbox.modules[0].scrollable, true);
assert.equal("collapsed" in toolbox.modules[1], false);
});
test("toolbox export remaps module order ids", () => {
const payload = createToolboxExportPayload(
{