Share toolbox components and fix image and calendar updates
Some checks failed
Deploy Sokko G / deploy (push) Failing after 2s

This commit is contained in:
Shinuwa 2026-09-10 14:19:55 +02:00
parent 865a4ffd97
commit 34524d2961
13 changed files with 117 additions and 93 deletions

View file

@ -84,8 +84,7 @@ test("vite entrypoint and app shell are wired", async () => {
assert.match(aboutPage, /about-tool-examples/);
assert.match(libraryPage, /export function LibraryPage/);
assert.match(libraryPage, /LIBRARY_TOOLBOX_ID/);
assert.match(libraryPage, /TOOLBOX_MODULE_LOADERS/);
assert.match(libraryPage, /Object\.entries\(TOOLBOX_MODULE_LOADERS\)/);
assert.match(libraryPage, /toolboxModuleComponents\.jsx/);
assert.match(moduleRegistry, /export const TOOLBOX_MODULE_LOADERS/);
assert.match(moduleRegistry, /taskPlanner: \(\) => import\("\.\/modules\/TaskPlannerModule\.jsx"\)/);
assert.match(moduleRegistry, /equipmentPlanner: \(\) => import\("\.\/modules\/EquipmentPlannerModule\.jsx"\)/);

View file

@ -311,31 +311,9 @@ 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(moduleComponents, /lazy\(\(\) => import\("\.\/CombosModule\.jsx"\)/);
assert.match(moduleComponents, /lazy\(\(\) => import\("\.\/CalendarModule\.jsx"\)/);
assert.match(moduleComponents, /lazy\(\(\) => import\("\.\/GoalTreeModule\.jsx"\)/);
assert.match(moduleComponents, /lazy\(\(\) => import\("\.\/EquipmentPlannerModule\.jsx"\)/);
assert.match(toolboxModules, /Suspense fallback=\{<ModuleLoadingFallback label=\{label\} \/>\}/);
assert.match(moduleComponents, /LAZY_MODULE_TYPES/);
assert.match(moduleComponents, /notepad:/);
assert.match(moduleComponents, /checklist:/);
assert.match(moduleComponents, /images:/);
assert.match(moduleComponents, /links:/);
assert.match(moduleComponents, /counters:/);
assert.match(moduleComponents, /combos:/);
assert.match(moduleComponents, /CombosModule/);
assert.match(moduleComponents, /calculator:/);
assert.match(moduleComponents, /table:/);
assert.match(moduleComponents, /table: \{ \.\.\.TOOLBOX_MODULE_DEFINITIONS\.table, Component: TableModule \}/);
assert.match(moduleComponents, /timer:/);
assert.match(moduleComponents, /calendar:/);
assert.match(moduleComponents, /taskPlanner:/);
assert.match(moduleComponents, /goalTree:/);
assert.match(moduleComponents, /equipmentPlanner:/);
assert.match(moduleMetadataRegistry, /Planificateur d'équipements/);
assert.match(moduleComponents, /imageAnnotation:/);
assert.match(moduleMetadataRegistry, /Annotation d'images/);
assert.match(moduleComponents, /notepad: \{ \.\.\.TOOLBOX_MODULE_DEFINITIONS\.notepad, Component: NotepadModule \}/);
assert.match(toolboxModules, /module-edit-button/);
assert.match(toolboxModules, /itemReorder\.startDrag/);
assert.match(moduleRegistryBundle, /onPointerDown/);

View file

@ -0,0 +1,41 @@
// Rôle : vérifie la fusion des ajouts d'images pendant une compression asynchrone.
import { test } from "node:test";
import assert from "node:assert/strict";
import { useToolboxActions } from "../website/src/features/toolboxes/useToolboxActions.js";
test("concurrent image batches preserve intervening edits and completed additions", async (t) => {
const descriptors = Object.fromEntries(["document", "createImageBitmap"].map((key) => [
key, Object.getOwnPropertyDescriptor(globalThis, key)
]));
t.after(() => {
for (const [key, descriptor] of Object.entries(descriptors)) {
if (descriptor) Object.defineProperty(globalThis, key, descriptor);
else delete globalThis[key];
}
});
const pending = new Map();
globalThis.createImageBitmap = (file) => new Promise((resolve) => pending.set(file.name, resolve));
globalThis.document = {
createElement: () => ({
getContext: () => ({ drawImage() {} }),
toDataURL: () => "data:image/jpeg;base64,dGVzdA=="
})
};
let current = { images: [{ id: "old", label: "Old" }] };
const actions = useToolboxActions({
store: {
getModuleData: () => current,
updateModuleData: (_toolboxId, _moduleId, value) => { current = value; return true; }
}
});
const first = actions.addImageFiles("toolbox", "images", [{ name: "First.png", type: "image/png" }]);
const second = actions.addImageFiles("toolbox", "images", [{ name: "Second.png", type: "image/png" }]);
current = { images: [{ id: "old", label: "Renamed" }], annotation: "Keep me" };
pending.get("Second.png")({ width: 10, height: 10 });
assert.equal(await second, true);
pending.get("First.png")({ width: 10, height: 10 });
assert.equal(await first, true);
assert.deepEqual(current.images.map((image) => image.label), ["First", "Second", "Renamed"]);
assert.equal(current.annotation, "Keep me");
assert.equal(await actions.addImageFiles("toolbox", "images", [{ type: "text/plain" }]), false);
});