test: conformance tests for JSON Canvas spec + Canvas Candy baseline#29
Open
LeslieOA wants to merge 1 commit into
Open
test: conformance tests for JSON Canvas spec + Canvas Candy baseline#29LeslieOA wants to merge 1 commit into
LeslieOA wants to merge 1 commit into
Conversation
…loses #16) Test count goes from 38/3 suites to 168/5 suites. Two new files: 1. src/core/__tests__/spec-conformance.test.ts - Edge side × end matrix round-trip: 4 (fromSide) × 4 (toSide) × 2 (fromEnd) × 2 (toEnd) = 64 combinations, each round-tripped through parseCanvas / serializeCanvas with deep equality on the result - Edge with all-optional fields omitted — verifies we don't fabricate default values - All six JSON Canvas preset colour codes ('1' through '6') preserved verbatim through round-trip on both nodes and edges - Hex colour preserved verbatim through round-trip - Full structural deep-equal on a representative mixed-type document - FileNode subpath round-trip - GroupNode background / backgroundStyle round-trip 2. src/renderer/extensions/__tests__/cssclasses.test.ts - hasCssClasses detection: text node, plain text, `cssclass` alias, non-text-node ignore - Frontmatter parsing: array form, comma-separated string, single string, `cssclass` (singular) alias, whitespace trimming, empty handling, displayText extraction - Class → RenderProps mapping for every baseline class: shapes (cc-shape-circle, parallelogram-left/right, cc-border-squared) fills (cc-card-fill / -transparent / -opaque / -nocolor) borders (cc-border-none / -dashed / -dotted / -double / -rounded / -dropshadow, single-side, additive multi-side) text alignment (cc-card-center, cc-callout-center) parametric: gradient {N}deg, rotate-card {N}, rotate-text {N} and trailing-l variant, non-matching pattern silently ignored - enrichNodes batch behaviour: non-text passthrough, plain-text reference-equality, frontmatter-but-no-cssclasses passthrough Verified - npm test: 168/168 across 5 suites - npm run typecheck: clean - npm run lint: exit 0 Notes - Tests live under src/core/__tests__/ and src/renderer/extensions/__tests__/ per jest.config.js's testMatch pattern. Co-locating Candy tests with the extension keeps the test surface organised by module. - Did not test the new updateXxx operation variants from #5 (PR #27) — those land separately and will get their own round of tests post-merge. Refs: #16 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This was referenced May 23, 2026
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
Test count: 38 → 168 across 5 suites. Two new files, both pure additions — no source changes.
src/core/__tests__/spec-conformance.test.tssrc/renderer/extensions/__tests__/cssclasses.test.tshasCssClassesdetection, frontmatter parsing variants, full Candy class → RenderProps mapping (shapes, fills, borders, text alignment, parametric), enrichNodes batch behaviourWhy this matters
serialization.test.ts. Any regression that silently mutates an edge field or fabricates a default will fail loudly.cssclasses.tsis the spec for the entire community-convention feature; pinning every class → RenderProps mapping means a future refactor (or eventual Rust port) can't drift silently.canvas-uinext adds a Candy class, the same test should appear here. Easy to spot in PR review.What's deliberately NOT in this PR
updateXxxoperation variants from refactor(core): replace Partial<CanvasNode> in updateNodeContent with explicit operation variants #5 — that's PR refactor(core): explicit per-field operation variants + deprecate renderMarkdown #27's scope and they'll get their own test pass post-merge.updateNodeContentremoval tests — same reason.__tests__/spec-fixtures/as the issue proposed — opted for inline JSON construction instead. Easier to read, no fixture-loader plumbing, every test self-contained. Real.canvasfixtures still live atsample.canvasand are exercised byserialization.test.ts+canvas-state.test.ts. Can revisit if a future addition needs bigger / shareable fixtures.Verification
npm test: 168/168, 5 suitesnpm run typecheck: cleannpm run lint: exit 0Independent of #27 and #28 — no overlapping files, can merge in any order.
Refs: #16