chore: audit cleanup leftovers — generate-views/node->hiccup splits + tests#14
Merged
chore: audit cleanup leftovers — generate-views/node->hiccup splits + tests#14
Conversation
Adds unit coverage for the v0.2.0 modules that landed without test files. Pure helpers only — modal mounting, focus management, and the x-command-palette wiring stay browser-only and out of unit scope. cheat-sheet: - group-rows promoted from defn- to defn so tests can pin its output without going through the modal lifecycle. - 5 tests cover empty info, single category, declared-order preservation, dropped-empty-category, and a smoke test against the live shortcut-info / category-labels data. command-palette: - curated-commands, wrap-commands, ->item promoted to defn. - ->item: 3 tests cover field projection, synthetic id format, keywords-default-to-empty-string. - curated-commands: 3 tests cover shape, label uniqueness, group whitelist. - wrap-commands: 2 tests cover shape and label-references-tag. Test count moves 571 → 584 (13 new tests, 40 new assertions). Gates green. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
generate-views was 161 lines mixing data derivation (sub-groups, read fields, payload fields, four kinds of aliases, function signature, ns-clause requires) with output formatting (the file string). The audit's recipe — the same one already applied to generate-core — was to split data assembly from orchestration. view-context (private, ~140 lines) does the assembly and returns a known-shape map: :fn-name :ns-path :fn-sig :require-entries :hiccup-ctx :node :root-slot :let-fields :field->owner :has-let? generate-views shrinks to ~45 lines: destructures the bundle, builds the ns-clause string, threads has-let?/let-fields/ hiccup-ctx into the body string, returns the file content. The data assembly is still big — every derived datum is needed exactly once and they cross-reference enough that further splitting would multiply argument lists. The split's value is that the orchestrator is now a readable sequence of steps without 25 derived locals in scope. cljs_project_test.cljs's parity tests are the safety net; all 584 tests still pass (0 failures), 0 release-build warnings, 0 lint warnings. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
node->hiccup-with-events was 123 lines doing four jobs at once: build the props map, resolve text from text-field or :text, walk the children across slots with sub-group / template dispatch, and assemble the final hiccup string. The children walk was the gnarliest part — 50 lines of nested cond + let inside a reduce. emit-sub-group-child (~40 lines) renders one sub-group child: either a singleton view call or a template iteration. Returns [rendered-or-nil rendered-tpls'] so the caller can dedupe templates within a parent slot — the first encounter renders, later ones return nil so a parent with N seed-backed clones still emits one iteration. walk-slotted-children (~29 lines) is the reduce-over-slots loop; sub-group children dispatch through emit-sub-group-child, non-group children recurse via node->hiccup-with-events. node->hiccup-with-events shrinks to ~77 lines and reads as props → text → children → output assembly, four single-purpose steps. The recursive cycle (node->hiccup-with-events ↔ walk-slotted-children) is bridged by a forward `declare`. cljs_project parity tests are the safety net; 584 tests still pass, 0 release-build warnings, 0 lint warnings, formatting clean. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Three commits picking up the open items from the 2026-04-23 audit
that weren't closed by the time of the v0.1.0 cleanup arc, plus
unit coverage for the v0.2.0 modules that landed without test
files. No behaviour change, no document-model change, no plugin
contract change.
Commits
Tests for cheat-sheet/group-rows + command-palette pure
helpers — promotes group-rows / curated-commands /
wrap-commands / ->item from defn- to defn so unit tests can
pin the shape (label / group / run! present, no duplicate
labels, ->item synthetic id format) without going through the
modal lifecycle. 13 new tests, 40 new assertions; test count
571 → 584.
Decompose generate-views: extract view-context data bundle
— generate-views was 161 lines mixing data derivation (sub-
groups, read fields, payload fields, four kinds of aliases,
fn signature, ns-clause requires) with output formatting.
view-context (private, ~140 lines) does the assembly and
returns a known-shape map; generate-views shrinks to ~45 lines
reading as a sequence of formatting steps. Same recipe as the
already-landed generate-core split.
Decompose node->hiccup-with-events into walk + emit
helpers — node->hiccup-with-events was 123 lines doing four
jobs at once. emit-sub-group-child (~40 lines) renders one
sub-group child; walk-slotted-children (~29 lines) is the
reduce-over-slots loop; node->hiccup-with-events shrinks to
~77 lines and reads as props → text → children → output
assembly.
Test plan
The cljs-project parity tests in test/bareforge/export/cljs_project_test.cljs
are the safety net for both refactors. Any behavioural drift in
the emitted CLJS project would have failed one of those.
🤖 Generated with Claude Code