Skip to content

Fixture/snapshot tests for split, merge, overlap, and the analyzer - #13

Merged
willscott-v2 merged 1 commit into
mainfrom
feature/fixture-tests
Jul 25, 2026
Merged

willscott-v2 merged 1 commit into
mainfrom
feature/fixture-tests

Conversation

@willscott-v2

Copy link
Copy Markdown
Collaborator

Stacked on #12 (v3.4). Merge order: #10 → #11 → #12 → #13, retargeting each to main as its base lands.

Why

Deferred since v3.1 — and now overdue: the Chunkability score makes chunking behavior load-bearing, so an accidental change to splitting, merging, overlap, or extraction silently changes client-facing scores. Now it fails a test instead. 30 tests, ~0.6s, node:test only — zero new dependencies. Run with npm test.

What's covered

Unit — chunking primitives (tests/chunking.test.js): recursiveSplit (respects limits, preserves every word in order, prefers paragraph boundaries, force-splits giant sentences), mergeSmallChunks, addOverlap (prefix equals the previous chunk's tail, overlap_word_count recorded, the exact 29-word clamp case from the page Chuck screenshotted, no-op paths), initialism, and Flesch-Kincaid determinism/ordering.

Unit — analyzer (tests/analyzer.test.js): one isolated scenario per flag — dangling-reference, thin, oversized, generic-heading (and its answer-buried skip), answer-buried (and the single-word-heading skip), no-entity-anchor (and UWM-style initialism anchoring), near-duplicate (flags both chunks, counted once as a pair), overlap-prefix exclusion from duplicate/thin checks, readability info flags — plus the per-chunk-average score math (85/B case with exact top_fixes), full determinism, and empty input → null.

Fixture snapshots (tests/fixture-snapshot.test.js): two committed HTML fixtures run through the full offline pipeline (extractSourceMetadata → buildChunks → enhanceChunks → analyzeChunks), with the entire result deep-equaled against committed *.snapshot.json. Intentional behavior changes regenerate with UPDATE_SNAPSHOTS=1 npm test, so the diff shows up in review. nested-sections.html is the dedicated regression fixture for the v3.3 parent-swallows-child extraction fix, with explicit asserts on top of the snapshot. Snapshots use the estimate tokenizer so they don't churn with gpt-tokenizer releases.

Plumbing

  • api/chunk.js gains a named-export block for the test surface — runtime unchanged (Vercel only uses the default handler; verified the running API afterward)
  • .github/workflows/test.yml runs npm ci && npm test on PRs and pushes to main (Node 22)
  • npm test uses a quoted glob because the directory form of node --test fails silently on Node 22.22

🤖 Generated with Claude Code

Deferred since v3.1; now that the Chunkability score makes chunking
behavior load-bearing, any change to it should fail a test. 30 tests,
node:test only — no new dependencies. Run: npm test.

- api/chunk.js gains named exports for the test surface; runtime is
  unchanged (Vercel only uses the default handler)
- tests/chunking.test.js: recursiveSplit limits/ordering/paragraph
  preference/force-split, mergeSmallChunks, addOverlap (prefix content,
  recorded count, the exact 29-word clamp from the page that started
  this, no-op paths), initialism, Flesch-Kincaid ordering
- tests/analyzer.test.js: one isolated scenario per flag, including the
  single-word-heading skip, UWM initialism anchoring, near-duplicates
  counted once per pair, and overlap-prefix exclusion; per-chunk-average
  score math; determinism; empty input
- tests/fixture-snapshot.test.js: two committed HTML fixtures through
  the full offline pipeline, deep-equal against committed snapshots
  (UPDATE_SNAPSHOTS=1 npm test to regenerate intentionally).
  nested-sections.html is the regression fixture for the v3.3
  parent-swallows-child extraction fix
- Snapshots use the estimate tokenizer so they don't churn with
  gpt-tokenizer versions
- .github/workflows/test.yml runs the suite on PRs and main pushes
- npm test uses a glob: the directory form of node --test fails
  silently on Node 22.22

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@vercel

vercel Bot commented Jul 25, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
getchunks Ready Ready Preview, Comment Jul 25, 2026 9:17pm

Request Review

@willscott-v2
willscott-v2 changed the base branch from feature/chunk-quality-v3.4 to main July 25, 2026 21:21
@willscott-v2
willscott-v2 merged commit c8c6e62 into main Jul 25, 2026
5 checks passed
@willscott-v2
willscott-v2 deleted the feature/fixture-tests branch July 25, 2026 21:21

This branch was successfully deployed

1 active deployment
Preview — 8b2223ba Deployed Jul 25, 2026 by vercel[bot]
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