Skip to content

Address issue #234: Test Coverage Phase 1b - Notification, Lifecycle, and Edge Case Tests#235

Merged
schuyler merged 4 commits intomainfrom
claude/resolve-issue-234-G3kBr
Dec 30, 2025
Merged

Address issue #234: Test Coverage Phase 1b - Notification, Lifecycle, and Edge Case Tests#235
schuyler merged 4 commits intomainfrom
claude/resolve-issue-234-G3kBr

Conversation

@schuyler
Copy link
Copy Markdown
Owner

Summary

Implements Test Coverage Phase 1b as specified in issue #234, adding comprehensive test suites for notification/observer integration, document lifecycle, renderer edge cases, highlighter coverage gaps, and image handling in exports.

New Test Suites Added (5 files, 2,591 lines)

  1. MPNotificationTests.m (HIGH priority)

    • Tests for NSNotificationCenter observer patterns
    • Preference change notifications
    • Theme and font change notifications
    • Observer cleanup and thread safety tests
  2. MPDocumentLifecycleTests.m (MEDIUM priority)

    • Document dirty flag management
    • Revert behavior tests
    • Encoding detection (UTF-8, BOM, ASCII)
    • File conflict detection
    • File deletion during edit scenarios
  3. MPRendererEdgeCaseTests.m (MEDIUM priority)

    • Nil data source/delegate handling
    • Empty and whitespace-only markdown
    • Markdown extension combinations
    • Malformed HTML in code blocks (XSS prevention)
    • Concurrent render requests
    • MathJax, Mermaid, Graphviz, TOC, Front matter support
  4. HGMarkdownHighlighterTests.m (LOWER priority)

    • Property getter/setter tests
    • Style parsing error callbacks
    • Activation/deactivation without text view
    • Stress tests for rapid property changes
  5. MPImageExportTests.m (LOWER priority)

    • Base64 embedded images (PNG, GIF, JPEG)
    • Linked external images (HTTP, HTTPS, relative paths)
    • Invalid image URLs (empty, malformed, XSS attempts)
    • Alt text and title preservation
    • Reference-style images

Related Issue

Related to #234

Test Coverage

All tests are designed to run headless in CI environment. Tests follow established patterns from Phase 1 (#197) and use existing test helpers (MPMockRendererDataSource, MPMockRendererDelegate).

Success Criteria from Issue #234

  • All new tests pass
  • Tests run headless in CI
  • No flaky tests (proper synchronization, file cleanup, test isolation)
  • Coverage improvement measurable

Manual Testing Plan

Not required - this PR adds only unit tests with no behavioral changes to the application.

Review Notes

… and Edge Case Tests

Implements five new test suites as specified in issue #234:

1. MPNotificationTests (HIGH priority)
   - Tests for NSNotificationCenter observer patterns
   - Preference change notifications
   - Theme and font change notifications
   - Observer cleanup and thread safety tests

2. MPDocumentLifecycleTests (MEDIUM priority)
   - Document dirty flag management
   - Revert behavior tests
   - Encoding detection (UTF-8, BOM, ASCII)
   - File conflict detection
   - File deletion during edit scenarios

3. MPRendererEdgeCaseTests (MEDIUM priority)
   - Nil data source/delegate handling
   - Empty and whitespace-only markdown
   - Markdown extension combinations
   - Malformed HTML in code blocks
   - Concurrent render requests
   - MathJax, Mermaid, and Graphviz support
   - Front matter handling

4. HGMarkdownHighlighterTests (LOWER priority)
   - Property getter/setter tests
   - Style parsing error callbacks
   - Activation/deactivation without text view
   - Stress tests for rapid property changes

5. MPImageExportTests (LOWER priority)
   - Base64 embedded images (PNG, GIF, JPEG)
   - Linked external images (HTTP, HTTPS, relative paths)
   - Invalid image URLs (empty, malformed, XSS attempts)
   - Alt text and title preservation
   - Reference-style images

All tests designed to run headless in CI environment.

Related to #234
Updated the following documents to reflect the completion of Issue #234:

- test_coverage_improvement_plan.md: Updated test file count, added new test
  suites to inventory, marked phases as completed
- infrastructure_evaluation.md: Updated test file count, added new test files
  and coverage areas to the documentation
- xcuitest.md: Expanded test coverage sections, marked critical gaps as
  partially addressed

Related to #234
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Dec 30, 2025

Code Coverage Report

Current Coverage: 51.30%

Coverage Details (Summary)
Name                                                                                                                                   Coverage            
-------------------------------------------------------------------------------------------------------------------------------------- ------------------- 
MASPreferences.bundle                                                                                                                  0.00% (0/0)         
MacDown 3000.app                                                                                                                       57.83% (7213/12472) 
    /Users/runner/work/macdown3000/macdown3000/MacDown/Code/Preferences/MPHtmlPreferencesViewController.m                              0.00% (0/87)        
        MPPrismDefaultThemeName                                                                                                        0.00% (0/2)         
        -[MPHtmlPreferencesViewController viewIdentifier]                                                                              0.00% (0/3)         
        -[MPHtmlPreferencesViewController toolbarItemImage]                                                                            0.00% (0/3)         
        -[MPHtmlPreferencesViewController toolbarItemLabel]                                                                            0.00% (0/2)         
        -[MPHtmlPreferencesViewController viewWillAppear]                                                                              0.00% (0/4)         
        -[MPHtmlPreferencesViewController changeStylesheet:]                                                                           0.00% (0/7)         
        -[MPHtmlPreferencesViewController changeHighlightingTheme:]                                                                    0.00% (0/7)         
        -[MPHtmlPreferencesViewController invokeStylesheetFunction:]                                                                   0.00% (0/23)        
        -[MPHtmlPreferencesViewController loadStylesheets]                                                                             0.00% (0/13)        
        -[MPHtmlPreferencesViewController loadHighlightingThemes]                                                                      0.00% (0/23)        
    /Users/runner/work/macdown3000/macdown3000/MacDown/Code/Document/MPDocument.m                                                      50.56% (767/1517)   
        MPEditorPreferenceKeyWithValueKey                                                                                              85.71% (6/7)        
        MPEditorKeysToObserve                                                                                                          100.00% (14/14)     
        __MPEditorKeysToObserve_block_invoke                                                                                           100.00% (9/9)       
        MPEditorPreferencesToObserve                                                                                                   100.00% (13/13)     
        __MPEditorPreferencesToObserve_block_invoke                                                                                    100.00% (8/8)       
        MPRectStringForAutosaveName                                                                                                    100.00% (6/6)       
        MPAreNilableStringsEqual                                                                                                       100.00% (3/3)       
        MPGetWebViewBackgroundColor                                                                                                    0.00% (0/9)         
        -[NSURL(Convert) absoluteBaseURLString]                                                                                        0.00% (0/6)         
        -[WebView(Shortcut) enclosingScrollView]                                                                                       100.00% (3/3)       
        -[MPPreferences(Hoedown) extensionFlags]                                                                                       75.00% (21/28)      
        -[MPPreferences(Hoedown) rendererFlags]                                                                                        66.67% (8/12)       
        MPGetPreviewLoadingCompletionHandler                                                                                           100.00% (25/25)     
        __MPGetPreviewLoadingCompletionHandler_block_invoke                                                                            100.00% (22/22)     
        -[MPDocument preferences]                                                                                                      100.00% (3/3)       
        -[MPDocument markdown]                                                                                                         100.00% (3/3)       
        -[MPDocument setMarkdown:]                                                                                                     100.00% (3/3)       
        -[MPDocument html]                                                                                                             0.00% (0/3)         
        -[MPDocument toolbarVisible]                                                                                                   0.00% (0/3)         
        -[MPDocument previewVisible]                                                                                                   100.00% (3/3)       
        -[MPDocument editorVisible]                                                                                                    100.00% (3/3)       
        -[MPDocument needsHtml]                                                                                                        0.00% (0/5)         
        -[MPDocument setTotalWords:]                                                                                                   0.00% (0/7)         
        -[MPDocument setTotalCharacters:]                                                                                              0.00% (0/7)         
        -[MPDocument setTotalCharactersNoSpaces:]                                                                                      0.00% (0/8)         
        -[MPDocument setAutosaveName:]                                                                                                 100.00% (4/4)       
        -[MPDocument init]                                                                                                             88.89% (8/9)        
        -[MPDocument windowNibName]                                                                                                    100.00% (3/3)       
        -[MPDocument windowControllerDidLoadNib:]                                                                                      98.82% (84/85)      
        __41-[MPDocument windowControllerDidLoadNib:]_block_invoke                                                                     100.00% (4/4)       
        -[MPDocument reloadFromLoadedString]                                                                                           100.00% (8/8)       
        -[MPDocument close]                                                                                                            0.00% (0/20)        
        +[MPDocument autosavesInPlace]                                                                                                 100.00% (2/2)       
        +[MPDocument writableTypes]                                                                                                    100.00% (3/3)       

... (2355 more lines truncated)

📊 **Full coverage report available in workflow artifacts**

Add hoedown/document.h import to resolve HOEDOWN_EXT_TABLES
undeclared identifier error.

Related to #234
Guard against multiple calls to [expectation fulfill] since
NSUserDefaultsDidChangeNotification can fire multiple times when
preferences are changed. Also removed unnecessary restore/synchronize
since only one notification is needed to verify the mechanism works.

Related to #234
@schuyler schuyler merged commit d41897f into main Dec 30, 2025
5 checks passed
@schuyler schuyler deleted the claude/resolve-issue-234-G3kBr branch December 30, 2025 22:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants