Skip to content

Conversation

osterman
Copy link
Member

what

  • Added comprehensive test coverage for the pkg/ui/markdown package
  • Increased test coverage from 43.3% to 89.3%
  • Created new test files for parser and styles modules
  • Extended renderer tests with additional test cases

why

  • The pkg/ui/markdown package had low test coverage (43.3%)
  • Many critical functions were untested, including parsing, styling, and rendering functions
  • Improving test coverage helps ensure code reliability and prevents regressions
  • Meeting the project's goal of 80-100% test coverage for packages

Test Coverage Details

New Test Files Created

  • pkg/ui/markdown/parser_test.go - Tests for SplitMarkdownContent function
  • pkg/ui/markdown/styles_test.go - Tests for styling functions and configurations

Functions Now Tested

  • SplitMarkdownContent - Markdown content parsing
  • RenderAsciiWithoutWordWrap - ASCII rendering without word wrapping
  • RenderAscii - ASCII rendering with word wrapping
  • RenderWorkflow - Workflow documentation rendering
  • RenderError - Error message rendering with styling
  • RenderSuccess - Success message rendering
  • WithWidth - Renderer width configuration option
  • NewTerminalMarkdownRenderer - Terminal-aware renderer creation
  • applyStyleSafely - Safe style application with nil checks
  • GetDefaultStyle - Style configuration with customizations
  • Helper functions (stringPtr, boolPtr, uintPtr)

Coverage Metrics

  • Before: 43.3% coverage
  • After: 89.3% coverage
  • All new tests pass: ✅

🤖 Generated with Claude Code

- Add comprehensive tests for SplitMarkdownContent parser function
- Add tests for all renderer functions including ASCII variants
- Add tests for RenderWorkflow, RenderError, and RenderSuccess
- Add tests for WithWidth option and NewTerminalMarkdownRenderer
- Add complete test coverage for styles including applyStyleSafely
- Add tests for GetDefaultStyle with various markdown configurations
- Test pointer helper functions (stringPtr, boolPtr, uintPtr)
- Test non-TTY fallback scenarios for rendering functions
- Improve overall package coverage from 43.3% to 89.3%

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@osterman osterman requested a review from a team as a code owner August 27, 2025 20:31
@github-actions github-actions bot added the size/l Large size PR label Aug 27, 2025
@osterman osterman added the patch A minor, backward compatible change label Aug 27, 2025
@osterman osterman added no-release Do not create a new release (wait for additional code changes) and removed patch A minor, backward compatible change labels Aug 27, 2025
osterman and others added 3 commits August 27, 2025 15:39
… QF1008

- Access embedded StylePrimitive fields directly on StyleBlock
- Fix style.Heading.StylePrimitive.Color to style.Heading.Color
- Fix style.Document, H1, H2, H3 StylePrimitive references
- Simplify CodeBlock.StyleBlock.Color access

This addresses golangci-lint QF1008: could remove embedded field StylePrimitive from selector

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
…i-lint warning

- Extract style verification logic into verifyStyleCustomizations helper function
- Use early return to avoid nested if-else blocks
- Reduces cyclomatic complexity from 5 to acceptable level
- Maintains same test coverage and functionality

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
osterman and others added 2 commits August 27, 2025 15:46
- Add periods to all comment lines (godot)
- Pass AtmosConfiguration by pointer to avoid hugeParam warnings (gocritic)
- Remove unnecessary embedded field selectors for StyleBlock (QF1008)
- Remove unnecessary fmt.Sprintf for string concatenation (S1025)
- Update all tests to use pointer references for AtmosConfiguration

This reduces the number of linting issues and improves code quality

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Pass ansi.StyleConfig by pointer to avoid hugeParam warning
- Use Terminal.MaxWidth instead of deprecated Docs.MaxWidth field
- Add backward compatibility fallback for deprecated field

Reduces linting issues from 24 to 10

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@github-actions github-actions bot added size/xl Extra large size PR and removed size/l Large size PR labels Aug 27, 2025
Copy link

mergify bot commented Aug 27, 2025

Warning

This PR exceeds the recommended limit of 1,000 lines.

Large PRs are difficult to review and may be rejected due to their size.

Please verify that this PR does not address multiple issues.
Consider refactoring it into smaller, more focused PRs to facilitate a smoother review process.

- Replace repetitive conditional color assignment with applyColorSafely helper
- Rename applyStyleSafely to applyColorSafely for clarity
- Simplifies code and reduces duplication
- Maintains testability with proper unit tests
- Addresses concern about non-DRY code pattern

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@osterman osterman added the patch A minor, backward compatible change label Aug 27, 2025
- Fixed compilation errors in all files calling NewTerminalMarkdownRenderer and NewRenderer
- Updated errors/error_funcs.go to pass atmosConfig as pointer
- Updated internal/tui/templates files to pass pointer
- Updated pkg/utils/markdown_utils.go to pass pointer
- Updated test files to use pointer references
- Removed deprecated Docs.MaxWidth fallback
@osterman osterman removed the no-release Do not create a new release (wait for additional code changes) label Aug 27, 2025
osterman and others added 6 commits August 27, 2025 16:19
- Revert NewRenderer and NewTerminalMarkdownRenderer to accept AtmosConfiguration by value
- Update all call sites to pass by value instead of pointer
- Maintains test coverage improvements (89.7% for pkg/ui/markdown)
- Preserves applyColorSafely helper function and other test enhancements

The pointer optimization will be handled in a separate PR to avoid mixing
test improvements with API changes.
})
}

// TestNewRendererErrorCases tests error handling in NewRenderer

Check failure

Code scanning / golangci-lint

Comment should end in a period Error test

Comment should end in a period
})
}

// TestRenderErrorCases tests error handling in rendering methods

Check failure

Code scanning / golangci-lint

Comment should end in a period Error test

Comment should end in a period
})
}

// TestNewTerminalMarkdownRendererEdgeCases tests edge cases for NewTerminalMarkdownRenderer

Check failure

Code scanning / golangci-lint

Comment should end in a period Error test

Comment should end in a period
}

// verifyStyleCustomizations checks if style customizations were applied correctly.
func verifyStyleCustomizations(t *testing.T, atmosConfig schema.AtmosConfiguration, style *ansi.StyleConfig) {

Check failure

Code scanning / golangci-lint

hugeParam: atmosConfig is heavy (6160 bytes); consider passing it by pointer Error test

hugeParam: atmosConfig is heavy (6160 bytes); consider passing it by pointer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
patch A minor, backward compatible change size/xl Extra large size PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant