test(toolpath-desktop): vitest + unit tests for classify and flattenChatHead#45
Merged
Merged
Conversation
|
🔍 Preview deployed: https://5810d552.toolpath.pages.dev |
eliothedeman
commented
Apr 22, 2026
Collaborator
Author
eliothedeman
left a comment
There was a problem hiding this comment.
Summary
Covers all 10 tests named in #40 with minimal, readable fixtures. Tooling is cleanly wired, CI is green, no scope creep.
Notes
classify.test.ts:17-42— all 4classifycases (user/assistant/tool/system) present; fixtures use the correct flat wire shape ({ type, role, text }), which is exactly the shape the original bug misread.classify.test.ts:45-62— thereadStructuralmulti-artifact test genuinely constructs a 2-artifactchangemap (file:///tmp/out.txt+tool://Edit) and asserts the tool payload wins. This is the regression the issue describes.tree.test.ts:50-64— linear chain test checks both id order andkindsequence, catching either ordering or classification regressions.tree.test.ts:66-81— tool.invoke sibling attachment test verifiess2.toolInvocations[0].id === "s3"AND thats3is absent from the top-level list, which catches both prior bugs (missed splice, lost attachment).tree.test.ts:83-94— non-tool sibling filter correctly uses ausersibling and assertstoolInvocations === [].tree.test.ts:96-115— bareStepdoc fallback and detached-HEAD fallback both present; the latter uses a literal"missing"head id, exactly the detached case.vitest.config.ts:7—environment: "node"with no jsdom (jsdom is only a transitive optional peer, not an install dep). Matches the issue's "pure TS" note.package.json— addstestandtest:watchscripts; only new devDep isvitest.bun.lock— additions are vitest's own transitive deps (@vitest/*,chai,tinybench, etc.); no unrelated churn.- No Svelte component tests, no extra helpers beyond the three local fixture builders. Scope is tight.
gh pr checks 45— bothtestanddeploypass.
Verdict
Comment (would approve, but can't self-approve). Tests map 1:1 to the issue, fixtures exercise the actual regressions (not just the happy paths), and the tooling additions are minimal. Safe to merge.
…tenChatHead Regression coverage for two pure-TS modules added in #34 that hit real bugs during development — both would have been caught by a ~20-line test. Wires up Vitest as the frontend test runner (Node environment, no jsdom needed for these pure-TS tests). classify.ts: five cases covering user / assistant / tool / system branches plus readStructural's preference for conversation-type payloads over sibling file artifacts. tree.ts: five cases covering flattenChatHead's HEAD-chain lineariser, the tool.invoke sibling attachment, the non-tool-sibling filter, the bare-Step fallback, and the detached-HEAD fallback. Closes #40
0c5c5c1 to
1ad44a5
Compare
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
bun run test/bun run test:watch). No jsdom — the two modules under test are pure TS.classify.tscovering the user / assistant / tool / system cases plusreadStructural's preference for conversation-type payloads when multiple artifacts are present.flattenChatHeadintree.tscovering the linear HEAD chain, tool.invoke sibling attachment, non-tool-sibling filter, bareStepdoc fallback, and detached-HEAD fallback.Closes #40.
Test plan
bun run test— 10 / 10 passing.bun run check— svelte-check stays green (pre-existing a11y warnings only).bun run build— Vite production build succeeds.