Split remaining toolbox modules by responsibility
All checks were successful
Deploy Sokko G / deploy (push) Successful in 16s

This commit is contained in:
Shinuwa 2026-08-25 09:33:15 +02:00
parent 43a9e791c5
commit a0d7e80a1a
25 changed files with 2199 additions and 1992 deletions

View file

@ -11,6 +11,10 @@ import { getCalendarOccurrences, getCurrentCalendarOccurrence, getMonthEnd, getM
import { exportModuleText, importModuleText } from "../website/src/features/toolboxes/modules/textImport.js";
import { compactCalendarDataForStorage, normalizeCalendarData } from "../website/src/features/toolboxes/storage/modules/calendar.js";
function countLines(source) {
return source.trimEnd().split("\n").length;
}
test("toolbox storage, cards and pages are wired", async () => {
const source = await readFile("website/src/main.jsx", "utf8");
const toolboxCard = await readFile("website/src/features/toolboxes/ToolboxCard.jsx", "utf8");
@ -142,6 +146,10 @@ test("toolbox storage, cards and pages are wired", async () => {
test("toolbox module registry and modules expose expected behavior", async () => {
const source = await readFile("website/src/main.jsx", "utf8");
const moduleRegistry = await readFile("website/src/features/toolboxes/modules/index.jsx", "utf8");
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 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");
@ -169,30 +177,44 @@ test("toolbox module registry and modules expose expected behavior", async () =>
const tableFormulaEngine = await readFile("website/src/features/toolboxes/modules/tableFormulaEngine.js", "utf8");
const timerModule = await readFile("website/src/features/toolboxes/modules/TimerModule.jsx", "utf8");
const timerParts = await readFile("website/src/features/toolboxes/modules/TimerParts.jsx", "utf8");
const timerCountdown = await readFile("website/src/features/toolboxes/modules/TimerCountdown.jsx", "utf8");
const timerSharedControls = await readFile("website/src/features/toolboxes/modules/TimerSharedControls.jsx", "utf8");
const timerStopwatch = await readFile("website/src/features/toolboxes/modules/TimerStopwatch.jsx", "utf8");
const timerBundle = `${timerModule}\n${timerParts}\n${timerCountdown}\n${timerSharedControls}\n${timerStopwatch}`;
const timerOptions = await readFile("website/src/features/toolboxes/modules/timerOptions.js", "utf8");
const calendarModule = await readFile("website/src/features/toolboxes/modules/CalendarModule.jsx", "utf8");
const calendarController = await readFile("website/src/features/toolboxes/modules/useCalendarController.js", "utf8");
const calendarDraftControls = await readFile("website/src/features/toolboxes/modules/useCalendarDraftControls.js", "utf8");
const calendarEventActions = await readFile("website/src/features/toolboxes/modules/calendarEventActions.js", "utf8");
const calendarLifecycle = await readFile("website/src/features/toolboxes/modules/useCalendarLifecycle.js", "utf8");
const calendarModeChoice = await readFile("website/src/features/toolboxes/modules/CalendarModeChoice.jsx", "utf8");
const calendarContent = await readFile("website/src/features/toolboxes/modules/CalendarContent.jsx", "utf8");
const calendarDraft = await readFile("website/src/features/toolboxes/modules/calendarDraft.js", "utf8");
const calendarEventForm = await readFile("website/src/features/toolboxes/modules/CalendarEventForm.jsx", "utf8");
const calendarEventControls = await readFile("website/src/features/toolboxes/modules/CalendarEventControls.jsx", "utf8");
const calendarMonthDatePicker = await readFile("website/src/features/toolboxes/modules/CalendarMonthDatePicker.jsx", "utf8");
const calendarViews = await readFile("website/src/features/toolboxes/modules/CalendarViews.jsx", "utf8");
const calendarBundle = `${calendarModule}\n${calendarContent}\n${calendarDraft}\n${calendarEventForm}\n${calendarEventControls}\n${calendarMonthDatePicker}\n${calendarViews}`;
const calendarBundle = `${calendarModule}\n${calendarController}\n${calendarDraftControls}\n${calendarEventActions}\n${calendarLifecycle}\n${calendarModeChoice}\n${calendarContent}\n${calendarDraft}\n${calendarEventForm}\n${calendarEventControls}\n${calendarMonthDatePicker}\n${calendarViews}`;
const calendarUtils = await readFile("website/src/features/toolboxes/modules/calendarUtils.js", "utf8");
const taskPlannerModule = await readFile("website/src/features/toolboxes/modules/TaskPlannerModule.jsx", "utf8");
const taskPlannerItems = await readFile("website/src/features/toolboxes/modules/TaskPlannerItems.jsx", "utf8");
const taskPlannerBranch = await readFile("website/src/features/toolboxes/modules/TaskPlannerBranch.jsx", "utf8");
const taskPlannerItem = await readFile("website/src/features/toolboxes/modules/TaskPlannerItem.jsx", "utf8");
const taskPlannerItemPanels = await readFile("website/src/features/toolboxes/modules/TaskPlannerItemPanels.jsx", "utf8");
const taskPlannerReorder = await readFile("website/src/features/toolboxes/modules/useTaskPlannerReorder.js", "utf8");
const taskPlannerTopbar = await readFile("website/src/features/toolboxes/modules/TaskPlannerTopbar.jsx", "utf8");
const taskPlannerSettings = await readFile("website/src/features/toolboxes/modules/TaskPlannerSettings.jsx", "utf8");
const taskPlannerBundle = `${taskPlannerItems}\n${taskPlannerItemPanels}\n${taskPlannerReorder}\n${taskPlannerTopbar}\n${taskPlannerSettings}`;
const taskPlannerBundle = `${taskPlannerItems}\n${taskPlannerBranch}\n${taskPlannerItem}\n${taskPlannerItemPanels}\n${taskPlannerReorder}\n${taskPlannerTopbar}\n${taskPlannerSettings}`;
const taskPlannerUtils = await readFile("website/src/features/toolboxes/modules/taskPlannerUtils.js", "utf8");
const goalTreeModule = await readFile("website/src/features/toolboxes/modules/GoalTreeModule.jsx", "utf8");
const goalTreeEditor = await readFile("website/src/features/toolboxes/modules/GoalTreeEditor.jsx", "utf8");
const goalTreeParts = await readFile("website/src/features/toolboxes/modules/GoalTreeParts.jsx", "utf8");
const goalTreeBranch = await readFile("website/src/features/toolboxes/modules/GoalTreeBranch.jsx", "utf8");
const goalTreeEditorFields = await readFile("website/src/features/toolboxes/modules/GoalTreeEditorFields.jsx", "utf8");
const goalTreeNodeContent = await readFile("website/src/features/toolboxes/modules/GoalTreeNodeContent.jsx", "utf8");
const goalTreeController = await readFile("website/src/features/toolboxes/modules/useGoalTreeController.js", "utf8");
const goalTreeView = await readFile("website/src/features/toolboxes/modules/GoalTreeView.jsx", "utf8");
const goalTreeBundle = `${goalTreeModule}\n${goalTreeEditor}\n${goalTreeParts}\n${goalTreeController}\n${goalTreeView}`;
const goalTreeBundle = `${goalTreeModule}\n${goalTreeEditor}\n${goalTreeParts}\n${goalTreeBranch}\n${goalTreeEditorFields}\n${goalTreeNodeContent}\n${goalTreeController}\n${goalTreeView}`;
const goalTreeDisplay = await readFile("website/src/features/toolboxes/modules/goalTreeDisplay.js", "utf8");
const goalTreeUtils = await readFile("website/src/features/toolboxes/modules/goalTreeUtils.js", "utf8");
const equipmentPlannerModule = await readFile("website/src/features/toolboxes/modules/EquipmentPlannerModule.jsx", "utf8");
@ -222,51 +244,81 @@ test("toolbox module registry and modules expose expected behavior", async () =>
const textImportTime = await readFile("website/src/features/toolboxes/modules/textImport/time.js", "utf8");
const imageViewer = await readFile("website/src/components/ImageViewer.jsx", "utf8");
[
["CalendarModule.jsx", calendarModule],
["modules/index.jsx", moduleRegistry],
["GoalTreeParts.jsx", goalTreeParts],
["TimerParts.jsx", timerParts],
["TaskPlannerItems.jsx", taskPlannerItems]
].forEach(([fileName, fileSource]) => {
assert.ok(countLines(fileSource) <= 220, `${fileName} must remain a short orchestrator/barrel`);
});
[
["AddToolControls.jsx", addToolControls],
["ToolboxModules.jsx", toolboxModules],
["useCalendarController.js", calendarController],
["useCalendarDraftControls.js", calendarDraftControls],
["calendarEventActions.js", calendarEventActions],
["useCalendarLifecycle.js", calendarLifecycle],
["CalendarModeChoice.jsx", calendarModeChoice],
["GoalTreeBranch.jsx", goalTreeBranch],
["GoalTreeEditorFields.jsx", goalTreeEditorFields],
["GoalTreeNodeContent.jsx", goalTreeNodeContent],
["TimerCountdown.jsx", timerCountdown],
["TimerSharedControls.jsx", timerSharedControls],
["TimerStopwatch.jsx", timerStopwatch],
["TaskPlannerBranch.jsx", taskPlannerBranch],
["TaskPlannerItem.jsx", taskPlannerItem]
].forEach(([fileName, fileSource]) => {
assert.ok(countLines(fileSource) <= 300, `${fileName} must stay focused; split by responsibility before growing further`);
});
assert.match(moduleMetadataRegistry, /export const TOOLBOX_MODULES/);
assert.match(moduleMetadataRegistry, /export const TOOLBOX_MODULE_DEFINITIONS/);
assert.match(moduleMetadataRegistry, /export function getDefaultModuleTitle/);
assert.match(moduleRegistry, /export function AddToolControls/);
assert.match(moduleRegistry, /export function ToolboxModules/);
assert.match(moduleRegistry, /MODULE_COMPONENTS/);
assert.match(moduleRegistry, /lazy\(\(\) => import\("\.\/CombosModule\.jsx"\)/);
assert.match(moduleRegistry, /lazy\(\(\) => import\("\.\/CalendarModule\.jsx"\)/);
assert.match(moduleRegistry, /lazy\(\(\) => import\("\.\/GoalTreeModule\.jsx"\)/);
assert.match(moduleRegistry, /lazy\(\(\) => import\("\.\/EquipmentPlannerModule\.jsx"\)/);
assert.match(moduleRegistry, /Suspense fallback=\{<ModuleLoadingFallback label=\{label\} \/>\}/);
assert.match(moduleRegistry, /LAZY_MODULE_TYPES/);
assert.match(moduleRegistry, /notepad:/);
assert.match(moduleRegistry, /checklist:/);
assert.match(moduleRegistry, /images:/);
assert.match(moduleRegistry, /links:/);
assert.match(moduleRegistry, /counters:/);
assert.match(moduleRegistry, /combos:/);
assert.match(moduleRegistry, /CombosModule/);
assert.match(moduleRegistry, /calculator:/);
assert.match(moduleRegistry, /table:/);
assert.match(moduleRegistry, /table: \{ \.\.\.TOOLBOX_MODULE_DEFINITIONS\.table, Component: TableModule \}/);
assert.match(moduleRegistry, /timer:/);
assert.match(moduleRegistry, /calendar:/);
assert.match(moduleRegistry, /taskPlanner:/);
assert.match(moduleRegistry, /goalTree:/);
assert.match(moduleRegistry, /equipmentPlanner:/);
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(moduleRegistry, /imageAnnotation:/);
assert.match(moduleComponents, /imageAnnotation:/);
assert.match(moduleMetadataRegistry, /Annotation d'images/);
assert.match(moduleRegistry, /notepad: \{ \.\.\.TOOLBOX_MODULE_DEFINITIONS\.notepad, Component: NotepadModule \}/);
assert.match(moduleRegistry, /module-edit-button/);
assert.match(moduleRegistry, /itemReorder\.startDrag/);
assert.match(moduleRegistry, /onPointerDown/);
assert.match(moduleRegistry, /useGroupedReorder/);
assert.match(moduleRegistry, /useInlineEdit/);
assert.match(moduleRegistry, /getContentEditableProps/);
assert.match(moduleRegistry, /tool-add-card/);
assert.match(moduleRegistry, /tool-quick-add-button/);
assert.match(moduleRegistry, /tool-add-quick-toggle/);
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/);
assert.match(toolboxModules, /useGroupedReorder/);
assert.match(toolboxModules, /useInlineEdit/);
assert.match(toolboxModules, /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(moduleRegistry, /module-content/);
assert.match(moduleRegistry, /module-scroll-button/);
assert.match(moduleRegistry, /Icon name="dropdown"/);
assert.match(moduleRegistry, /CompactDropdown/);
assert.match(toolboxModules, /module-content/);
assert.match(toolboxModules, /module-scroll-button/);
assert.match(addToolControls, /Icon name="dropdown"/);
assert.match(addToolControls, /CompactDropdown/);
assert.doesNotMatch(source, /<select value="" onChange=\{\(event\) => addModule/);
assert.match(notepadModule, /export function NotepadModule/);
assert.match(notepadModule, /TextExchangeActions/);
@ -364,7 +416,7 @@ test("toolbox module registry and modules expose expected behavior", async () =>
assert.match(timerModule, /Tabs/);
assert.match(timerModule, /stopwatch/);
assert.match(timerModule, /countdown/);
assert.match(timerParts, /useInlineEdit/);
assert.match(timerBundle, /useInlineEdit/);
assert.match(timerModule, /useDraftForm/);
assert.match(timerModule, /normalizeTimerData/);
assert.match(timerModule, /TextExchangeActions/);
@ -378,16 +430,16 @@ test("toolbox module registry and modules expose expected behavior", async () =>
assert.match(calendarBundle, /MonthDateDropdown/);
assert.match(calendarBundle, /MonthEventRepeatSwitch/);
assert.match(calendarBundle, /monthlyRepeatBy/);
assert.match(calendarModule, /displayedMonth/);
assert.match(calendarModule, /deleteOccurrence/);
assert.match(calendarController, /displayedMonth/);
assert.match(calendarController, /deleteOccurrence/);
assert.match(calendarBundle, /onPointerDown/);
assert.match(calendarModule, /copyEvent/);
assert.match(calendarController, /copyEvent/);
assert.match(calendarBundle, /calendar-repeat-switch/);
assert.match(calendarBundle, /layout-switch calendar-month-repeat-switch/);
assert.match(calendarBundle, /WEEK_TIME_INPUT_STEP_MINUTES \* 60/);
assert.match(calendarBundle, /durationMinutes < 120/);
assert.match(calendarBundle, /is-compact/);
assert.match(calendarModule, /handleKeyDown/);
assert.match(calendarController, /handleKeyDown/);
assert.match(calendarContent, /TextExchangeActions/);
assert.match(calendarContent, /type="calendar"/);
assert.match(calendarBundle, /repeatLabel/);
@ -408,8 +460,8 @@ test("toolbox module registry and modules expose expected behavior", async () =>
assert.match(taskPlannerModule, /useDraftForm/);
assert.match(taskPlannerBundle, /TextExchangeActions/);
assert.match(taskPlannerBundle, /reorderFeatures/);
assert.match(taskPlannerItems, /export function TaskPlannerBranch/);
assert.match(taskPlannerItems, /function TaskPlannerItem/);
assert.match(taskPlannerBranch, /export function TaskPlannerBranch/);
assert.match(taskPlannerItem, /export function TaskPlannerItem/);
assert.match(taskPlannerBundle, /task-planner-warning/);
assert.match(taskPlannerBundle, /useInlineEdit/);
assert.match(taskPlannerBundle, /commitOnEnter: false/);
@ -428,14 +480,14 @@ test("toolbox module registry and modules expose expected behavior", async () =>
assert.match(goalTreeEditor, /Tabs/);
assert.match(goalTreeEditor, /GoalTreeFormulaInput/);
assert.match(goalTreeEditor, /GoalTreePrerequisitePicker/);
assert.match(goalTreeParts, /Tooltip/);
assert.match(goalTreeParts, /export function GoalTreeIconPicker/);
assert.match(goalTreeParts, /export function GoalTreeContentEditor/);
assert.match(goalTreeParts, /function GoalTreeNodeContentPreview/);
assert.match(goalTreeBranch, /Tooltip/);
assert.match(goalTreeEditorFields, /export function GoalTreeIconPicker/);
assert.match(goalTreeEditorFields, /export function GoalTreeContentEditor/);
assert.match(goalTreeNodeContent, /export function GoalTreeNodeContentPreview/);
assert.doesNotMatch(goalTreeBundle, /\.slice\(0, 3\)/);
assert.match(goalTreeParts, /GoalTreeChecklistInlineControl/);
assert.match(goalTreeParts, /GoalTreeStepLeafControl/);
assert.match(goalTreeParts, /export function GoalTreePrerequisitePicker/);
assert.match(goalTreeNodeContent, /GoalTreeChecklistInlineControl/);
assert.match(goalTreeNodeContent, /GoalTreeStepLeafControl/);
assert.match(goalTreeEditorFields, /export function GoalTreePrerequisitePicker/);
assert.match(goalTreeBundle, /function toggleBranch/);
assert.match(goalTreeBundle, /function editNode/);
assert.match(goalTreeBundle, /function addNodeContentItem/);
@ -453,7 +505,7 @@ test("toolbox module registry and modules expose expected behavior", async () =>
assert.match(goalTreeDisplay, /progress\.current/);
assert.match(goalTreeDisplay, /label: textContent\.itemLabelPlaceholder \|\| "Élément"/);
assert.doesNotMatch(goalTreeUtils, /"calculator"/);
assert.match(goalTreeParts, /getItemProps\(\{ itemId: node\.id, parentId \}\)/);
assert.match(goalTreeBranch, /getItemProps\(\{ itemId: node\.id, parentId \}\)/);
assert.match(goalTreeUtils, /export function calculateGoalTreeFormula/);
assert.match(goalTreeUtils, /export function evaluateGoalTreeNodes/);
assert.match(equipmentPlannerModule, /export function EquipmentPlannerModule/);
@ -540,10 +592,10 @@ test("toolbox module registry and modules expose expected behavior", async () =>
assert.match(timerModule, /useGroupedReorder/);
assert.match(timerModule, /reorderEnabled={!data\.sortResults}/);
assert.match(timerModule, /parentId=\{moduleId\}/);
assert.match(timerParts, /timer-drag-handle/);
assert.match(timerParts, /export function StopwatchControls/);
assert.match(timerParts, /export function CountdownControls/);
assert.match(timerParts, /export function CountdownList/);
assert.match(timerCountdown, /timer-drag-handle/);
assert.match(timerStopwatch, /export function StopwatchControls/);
assert.match(timerCountdown, /export function CountdownControls/);
assert.match(timerCountdown, /export function CountdownList/);
assert.match(timerOptions, /export const ALERT_MIN_DELAY_MS/);
assert.match(textImport, /export \{ parseColonImportLines \}/);
assert.match(textImport, /export function exportModuleText/);