Refactor checklist module structure
All checks were successful
Deploy Sokko G / deploy (push) Successful in 15s

This commit is contained in:
Shinuwa 2026-08-24 22:19:11 +02:00
parent f2c88ee891
commit ed710b3399
5 changed files with 396 additions and 352 deletions

View file

@ -178,6 +178,9 @@ test("toolbox module registry and modules expose expected behavior", async () =>
const equipmentPlannerSummary = await readFile("website/src/features/toolboxes/modules/EquipmentPlannerSummary.jsx", "utf8");
const equipmentPlannerOptions = await readFile("website/src/features/toolboxes/modules/equipmentPlannerOptions.js", "utf8");
const checklistModule = await readFile("website/src/features/toolboxes/modules/ChecklistModule.jsx", "utf8");
const checklistParts = await readFile("website/src/features/toolboxes/modules/ChecklistParts.jsx", "utf8");
const checklistUtils = await readFile("website/src/features/toolboxes/modules/checklistUtils.js", "utf8");
const checklistBundle = `${checklistModule}\n${checklistParts}\n${checklistUtils}`;
const imagesModule = await readFile("website/src/features/toolboxes/modules/ImagesModule.jsx", "utf8");
const imageAnnotationModule = await readFile("website/src/features/toolboxes/modules/ImageAnnotationModule.jsx", "utf8");
const linksModule = await readFile("website/src/features/toolboxes/modules/LinksModule.jsx", "utf8");
@ -437,21 +440,21 @@ test("toolbox module registry and modules expose expected behavior", async () =>
assert.match(checklistModule, /export function ChecklistModule/);
assert.match(checklistModule, /TextExchangeActions/);
assert.match(checklistModule, /editing &&/);
assert.match(checklistModule, /ChecklistItem/);
assert.match(checklistModule, /ChecklistSection/);
assert.match(checklistModule, /chevron-down/);
assert.match(checklistModule, /chevron-up/);
assert.match(checklistModule, /checklist-qty-current/);
assert.match(checklistModule, /checklist-delete-button danger/);
assert.match(checklistParts, /ChecklistItem/);
assert.match(checklistParts, /export function ChecklistSection/);
assert.match(checklistParts, /chevron-down/);
assert.match(checklistParts, /chevron-up/);
assert.match(checklistParts, /checklist-qty-current/);
assert.match(checklistParts, /checklist-delete-button danger/);
assert.match(checklistModule, /useGroupedReorder/);
assert.match(checklistModule, /getItemProps/);
assert.match(checklistModule, /getGroupProps/);
assert.match(checklistBundle, /getItemProps/);
assert.match(checklistParts, /getGroupProps/);
assert.match(checklistModule, /getGroupBoundaryProps/);
assert.match(checklistModule, /checklist-category-boundary-drop-zone/);
assert.match(checklistModule, /itemReorder\.startDrag/);
assert.match(checklistModule, /groupReorder\.startDrag/);
assert.match(checklistModule, /useInlineEdit/);
assert.match(checklistModule, /moveChecklistItemToCategory/);
assert.match(checklistParts, /itemReorder\.startDrag/);
assert.match(checklistParts, /groupReorder\.startDrag/);
assert.match(checklistParts, /useInlineEdit/);
assert.match(checklistUtils, /export function moveChecklistItemToCategory/);
assert.match(textImportModal, /createPortal/);
assert.match(textImportModal, /lockBodyScroll/);
assert.match(textImportModal, /has-error/);

View file

@ -8,6 +8,7 @@ import { getEffectiveGoalTreeProgressMode, getVisibleGoalTreeEdges } from "../we
import { calculateGoalTreeFormula, evaluateGoalTreeNodes } from "../website/src/features/toolboxes/modules/goalTreeUtils.js";
import { createDefaultDraft, getDateSpanDays, getDraftSelection, normalizeDraftAlertOffsets, normalizeDraftMonthlyRepeatBy } from "../website/src/features/toolboxes/modules/calendarDraft.js";
import { getMonthOccurrenceSegments, getWeekGridLayout, getWeekMinutePosition, layoutConcurrentOccurrences } from "../website/src/features/toolboxes/modules/calendarLayout.js";
import { appendChecklistItems, moveChecklistItem, moveChecklistItemToCategory, renameChecklistSection } from "../website/src/features/toolboxes/modules/checklistUtils.js";
import { getTimePatternRecurrenceMs, getTimePatternTargetMs } from "../website/src/features/toolboxes/modules/timerUtils.js";
import { compactModuleDataForStorage, createToolboxExportPayload, normalizeCalculatorData, normalizeChecklistData, normalizeCombosData, normalizeCountersData, normalizeEquipmentPlannerData, normalizeGoalTreeData, normalizeImageAnnotationData, normalizeLinksData, normalizeModuleOrder, normalizeNotepadData, normalizeTableData, normalizeTaskPlannerData, normalizeTimerData, normalizeToolbox, normalizeUrl, summarizeEquipmentPlannerData } from "../website/src/features/toolboxes/storage/toolboxStorage.js";
import { applyGroupedReorderOperation, completeGroupOrder, getBoundaryItemId, getGroupedEntries, moveGroupOrder, moveGroupOrderToEnd, moveGroupOrderToStart, moveItem, moveItemGroup } from "../website/src/hooks/useGroupedReorder.js";
@ -789,6 +790,27 @@ test("checklist data drops empty titled sections", () => {
assert.deepEqual(compact.sections.map((section) => section.id), ["filled"]);
});
test("checklist helpers merge categories and move items deterministically", () => {
const context = { uid: (prefix) => `${prefix}-new` };
const sections = [
{ id: "s1", title: "Alpha", items: [{ id: "i1", label: "One" }, { id: "i2", label: "Two" }] },
{ id: "s2", title: "Beta", items: [{ id: "i3", label: "Three" }] }
];
assert.deepEqual(appendChecklistItems(sections, "alpha", [{ id: "i4", label: "Four" }], context)[0].items.map((item) => item.id), ["i1", "i2", "i4"]);
assert.deepEqual(renameChecklistSection(sections, "s1", "Beta").map((section) => [section.title, section.items.map((item) => item.id)]), [
["Beta", ["i3", "i1", "i2"]]
]);
assert.deepEqual(moveChecklistItemToCategory(sections, "i2", "Gamma", context).map((section) => [section.title, section.items.map((item) => item.id)]), [
["Alpha", ["i1"]],
["Beta", ["i3"]],
["Gamma", ["i2"]]
]);
assert.deepEqual(moveChecklistItem(sections, { sourceId: "i1", targetType: "item", targetId: "i3", placement: "after" }, context).map((section) => [section.title, section.items.map((item) => item.id)]), [
["Alpha", ["i2"]],
["Beta", ["i3", "i1"]]
]);
});
test("combos storage normalizes devices, steps and compact export ids", () => {
const longText = "x".repeat(120);
const normalized = normalizeCombosData({