From ea4074af8fefeee97073ae724a11f11ebbf321b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hartmut=20N=C3=B6renberg?= Date: Wed, 1 Apr 2026 09:52:23 +0200 Subject: [PATCH] test(repo): guard timeline drag helper boundaries --- scripts/check-architecture-guardrails.mjs | 61 +++++++++++++++++++ .../check-architecture-guardrails.test.mjs | 21 +++++++ 2 files changed, 82 insertions(+) diff --git a/scripts/check-architecture-guardrails.mjs b/scripts/check-architecture-guardrails.mjs index c0512f6..373964b 100644 --- a/scripts/check-architecture-guardrails.mjs +++ b/scripts/check-architecture-guardrails.mjs @@ -119,6 +119,51 @@ export const rules = [ ], forbidden: [], }, + { + file: "apps/web/src/hooks/timelineTouch.ts", + maxLines: 80, + required: [ + { + pattern: /\bexport function getTouchPoint\b/, + message: "timeline touch helpers must keep touch coordinate fallback centralized", + }, + { + pattern: /\bexport function resolveTouchDragDecision\b/, + message: "timeline touch helpers must keep scroll-vs-drag disambiguation centralized", + }, + ], + forbidden: [], + }, + { + file: "apps/web/src/hooks/timelineMultiSelect.ts", + maxLines: 90, + required: [ + { + pattern: /\bexport function createMultiSelectState\b/, + message: "timeline multi-select helpers must keep selection bootstrap centralized", + }, + { + pattern: /\bexport function finalizeMultiSelectDraft\b/, + message: "timeline multi-select helpers must keep minimal-drag reset logic centralized", + }, + ], + forbidden: [], + }, + { + file: "apps/web/src/hooks/timelineRangeSelection.ts", + maxLines: 90, + required: [ + { + pattern: /\bexport function updateRangeSelectionDraft\b/, + message: "timeline range helpers must keep preview date derivation centralized", + }, + { + pattern: /\bexport function finalizeRangeSelection\b/, + message: "timeline range helpers must keep ordered range finalization centralized", + }, + ], + forbidden: [], + }, { file: "apps/web/src/hooks/useTimelineDrag.ts", required: [ @@ -126,12 +171,28 @@ export const rules = [ pattern: /from "\.\/timelineLivePreview\.js"/, message: "timeline drag must keep live preview behavior delegated to the extracted helper module", }, + { + pattern: /from "\.\/timelineTouch\.js"/, + message: "timeline drag must keep touch fallback and drag disambiguation delegated to the extracted helper module", + }, + { + pattern: /from "\.\/timelineMultiSelect\.js"/, + message: "timeline drag must keep multi-select rectangle lifecycle delegated to the extracted helper module", + }, + { + pattern: /from "\.\/timelineRangeSelection\.js"/, + message: "timeline drag must keep range preview and finalization delegated to the extracted helper module", + }, ], forbidden: [ { pattern: /\bfunction (?:toPxValue|joinTransforms|captureLivePreviewTargets|renderLivePreview|scheduleLivePreview|clearLivePreview|datesMatch|preserveLivePreview)\b/, message: "timeline drag must not re-inline live preview helper implementations", }, + { + pattern: /\bfunction toClientX\b/, + message: "timeline drag must not re-inline touch coordinate fallback helpers", + }, ], }, { diff --git a/scripts/check-architecture-guardrails.test.mjs b/scripts/check-architecture-guardrails.test.mjs index cd13cd1..7877853 100644 --- a/scripts/check-architecture-guardrails.test.mjs +++ b/scripts/check-architecture-guardrails.test.mjs @@ -71,12 +71,21 @@ describe("architecture guardrails", () => { it("guards the extracted timeline live preview ownership boundary", () => { const dragRule = rules.find((rule) => rule.file === "apps/web/src/hooks/useTimelineDrag.ts"); const livePreviewRule = rules.find((rule) => rule.file === "apps/web/src/hooks/timelineLivePreview.ts"); + const touchRule = rules.find((rule) => rule.file === "apps/web/src/hooks/timelineTouch.ts"); + const multiSelectRule = rules.find((rule) => rule.file === "apps/web/src/hooks/timelineMultiSelect.ts"); + const rangeRule = rules.find((rule) => rule.file === "apps/web/src/hooks/timelineRangeSelection.ts"); assert.ok(dragRule); assert.ok(livePreviewRule); + assert.ok(touchRule); + assert.ok(multiSelectRule); + assert.ok(rangeRule); assert.deepEqual(evaluateRule(dragRule, "function clearLivePreview() {}\n"), [ "apps/web/src/hooks/useTimelineDrag.ts: missing guardrail anchor: timeline drag must keep live preview behavior delegated to the extracted helper module", + "apps/web/src/hooks/useTimelineDrag.ts: missing guardrail anchor: timeline drag must keep touch fallback and drag disambiguation delegated to the extracted helper module", + "apps/web/src/hooks/useTimelineDrag.ts: missing guardrail anchor: timeline drag must keep multi-select rectangle lifecycle delegated to the extracted helper module", + "apps/web/src/hooks/useTimelineDrag.ts: missing guardrail anchor: timeline drag must keep range preview and finalization delegated to the extracted helper module", "apps/web/src/hooks/useTimelineDrag.ts: forbidden pattern matched: timeline drag must not re-inline live preview helper implementations", ]); @@ -84,5 +93,17 @@ describe("architecture guardrails", () => { "apps/web/src/hooks/timelineLivePreview.ts: missing guardrail anchor: timeline live preview helpers must keep preview reset logic centralized", "apps/web/src/hooks/timelineLivePreview.ts: missing guardrail anchor: timeline live preview helpers must keep snapshot preservation centralized", ]); + + assert.deepEqual(evaluateRule(touchRule, "export function getTouchPoint() {}\n"), [ + "apps/web/src/hooks/timelineTouch.ts: missing guardrail anchor: timeline touch helpers must keep scroll-vs-drag disambiguation centralized", + ]); + + assert.deepEqual(evaluateRule(multiSelectRule, "export function createMultiSelectState() {}\n"), [ + "apps/web/src/hooks/timelineMultiSelect.ts: missing guardrail anchor: timeline multi-select helpers must keep minimal-drag reset logic centralized", + ]); + + assert.deepEqual(evaluateRule(rangeRule, "export function updateRangeSelectionDraft() {}\n"), [ + "apps/web/src/hooks/timelineRangeSelection.ts: missing guardrail anchor: timeline range helpers must keep ordered range finalization centralized", + ]); }); });