-
Notifications
You must be signed in to change notification settings - Fork 1
Description
Summary
The Markdown formatter supports multiple output variants (line numbers, only-tree, git status) but lacks regression tests using golden files to verify stable output across changes.
Problem Statement
The src/services/formatters/MarkdownFormatter.js implements various output modes and flags, but without golden file tests we cannot:
- Verify that output format remains consistent after code changes
- Catch unintended formatting regressions
- Validate that fence language detection works correctly
- Ensure begin/end markers are properly placed
- Test interaction between multiple flags
This affects users who rely on consistent Markdown output for documentation generation, AI tool integration, and automated workflows.
Current State
Formatter Capabilities (Implemented but Untested):
- Base Markdown formatting with code fences
--with-line-numbers- Line-numbered content--only-tree- Tree structure without file contents--with-git-status- Git status annotations- Language detection for syntax highlighting
- Begin/end markers for file boundaries
Existing Test Coverage:
- Unit tests may exist for individual methods
- No golden file tests for integrated output
- No tests for flag combinations
Affected Components
src/services/formatters/MarkdownFormatter.js- Formatter implementationsrc/ui/components/CopyView.js- Format mapping and optionstests/fixtures/goldens/- Will store expected outputstests/helpers/determinism.js- Normalization utilitiestests/helpers/fixtures.js- Golden file matcher
Implementation Approach
-
Create golden files in
tests/fixtures/goldens/markdown/:base.md- Default markdown outputwith-line-numbers.md- With line numbersonly-tree.md- Tree structure onlywith-git-status.md- With git annotationscombined-flags.md- Multiple flags together
-
Create test file
tests/e2e/markdown-formatter.test.js:- Test each variant against golden files
- Use
normalizeForGolden()for deterministic comparison - Test flag combinations
- Verify fence language detection
-
Follow existing golden file workflow:
- Initial generation with
UPDATE_GOLDEN=true - Subsequent runs compare against baselines
- Git tracks changes to golden files
- Initial generation with
Tasks
- Create
tests/fixtures/goldens/markdown/directory - Create
tests/e2e/markdown-formatter.test.jswith variant tests - Add test for base Markdown output (no flags)
- Add test for
--with-line-numbersoutput - Add test for
--only-treeoutput - Add test for
--with-git-statusoutput - Add test for combined flags (e.g., line numbers + git status)
- Generate initial golden files with
UPDATE_GOLDEN=true npm run test:e2e - Verify fence language detection for various file types (
.js,.py,.md, etc.) - Verify begin/end markers are correctly placed
- Ensure tests pass on CI across different platforms
Acceptance Criteria
- At least 6 golden file tests for Markdown formatter variants
- Tests pass consistently without
UPDATE_GOLDENflag - Golden files are committed and tracked in git
- Tests fail when formatter output changes
- Language detection verified for common file extensions
- All flag combinations produce deterministic output
- README examples match actual output from golden files
- No test flakiness or platform-specific failures
Additional Context
This issue is a subset of #19 (E2E golden tests) but focuses specifically on the Markdown formatter, which is commonly used for AI tool integration and documentation generation.
README Examples to Verify:
- Common Recipes - Line 98-99 shows markdown streaming
- Quick Start - Shows basic markdown usage
Related Testing Infrastructure: