Skip to content

test: extract parsing helpers into a tested module (audit bucket 4a — H2 part 1) - #4

Merged
CR0CKER merged 1 commit into
mainfrom
test/extract-parsing-suite
Jul 20, 2026
Merged

CR0CKER merged 1 commit into
mainfrom
test/extract-parsing-suite

Conversation

@CR0CKER

@CR0CKER CR0CKER commented Jul 20, 2026

Copy link
Copy Markdown
Owner

What changed

Audit bucket 4, part 1 (finding H2). Splits the big H2 into a reviewable first PR: extract the pure helpers and test them. The recurrence/timezone engine follows in part 2.

  • New parsing.ts — extracted sortDate, shouldFilterDeclinedEvent, getAttendeeName, formatParticipants, isCancelledEvent, parseLocation, templateFormatter from index.ts. They no longer read the logseq global; settings are passed in by the caller. Behavior unchanged.
  • New parsing.test.ts — 31 Jest tests, including a regression test for L1 (repeated template variable replaced everywhere), verified to fail red against the pre-fix String.replace code.
  • New blocking test CI job; npm test → jest.
  • types/url-regex-safe.d.ts — types for the untyped package.
  • Extraction dropped tsc errors 65 → 50; parsing.ts is strict-clean.

Why

H2: the date/recurrence/timezone core had zero tests, and the code was untestable because it's coupled to the logseq global with module-level side effects. Extracting the pure logic makes it testable and starts shrinking the type-debt.

Testing

  • npm test: 31 passed. L1 regression test confirmed to fail against .replace, pass against .replaceAll.
  • npm run typecheck: 50 errors (down from 65); parsing.ts = 0.
  • Build verified via CI (this host's arm64 can't build the native deps).

Follow-up

  • Part 2: extract + fixture-test the rawParser recurrence/timezone/EXDATE engine.
  • typecheck flips to a required gate after part 2 (rawParser still untyped until then).

Reviewer note

No automated PR reviewer configured; self-reviewed — extraction is behavior-preserving (settings threaded through as params), tests are role/behavior-based, no secrets, blast radius is the parsing module + its callers.

🤖 Generated with Claude Code

https://claude.ai/code/session_019cVCdCtNzUJmy1yen3JyBk

Extract the framework-free helpers (sortDate, shouldFilterDeclinedEvent,
getAttendeeName, formatParticipants, isCancelledEvent, parseLocation,
templateFormatter) from index.ts into parsing.ts so they can be unit-tested
without a live Logseq environment. They no longer read the logseq global —
hideDeclinedEvents / participantEmailFallback are passed in by the caller.
Behavior unchanged; extraction dropped the tsc error count 65 -> 50 and
parsing.ts is strict-clean.

Add a Jest + ts-jest suite (31 tests) exercising every extracted function,
including a regression test for L1 (a repeated template variable must be
replaced at every occurrence) that was verified to fail red against the
pre-fix String.replace code. Wire 'npm test' to jest and add a blocking
'test' CI job.

Also adds types/url-regex-safe.d.ts (the package ships no types).

The recurrence/timezone engine in rawParser is extracted+tested separately
in part 2. typecheck stays non-blocking until that lands (rawParser still
untyped). Tests + typecheck run locally green; build verified via CI (arm64
host can't build the native deps).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019cVCdCtNzUJmy1yen3JyBk
@CR0CKER
CR0CKER merged commit 7a9d8a3 into main Jul 20, 2026
2 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant