Skip to content

Template heuristics tests - Cover getSampleData and profile generation #3

@ewilderj

Description

@ewilderj

Description

Add comprehensive unit tests for the TemplateHeuristics class to ensure proper sample data generation and profile creation for the capture system.

Work Required

  1. Create Test File: Add test/capture.template-heuristics.test.js
  2. Test getSampleData(): Verify sample data for all known templates
  3. Test generateProfile(): Test profile generation for different template patterns
  4. Test Fallbacks: Verify fallback behavior for unknown templates
  5. Mock Dependencies: Mock page objects where needed

Implementation Details

Based on capture/template-heuristics.js, test coverage for:

Sample Data Templates

  • animated-text: text, velocity parameters
  • carousel: items array, duration, zoom parameters
  • message-banner: title, subtitle
  • webp-loop: url, fit parameters
  • timeleft: minutes, label
  • snake: cellSize, tickMs
  • simple-clock: empty object

Profile Generation Patterns

  • Clock/time templates: wait for text with digits, timed screenshots
  • Text/animation templates: wait for animation, longer video duration
  • Carousel templates: wait for media and stability, extended recording
  • Media templates: wait for media loading
  • Game templates: wait for coverage and initialization
  • Banner templates: wait for text, shorter videos
  • Default templates: wait for visual stability

Test Cases

  • getSampleData() returns correct structure for known templates
  • getSampleData() returns empty object {} for unknown templates
  • generateProfile() creates appropriate detection strategies
  • generateProfile() sets reasonable timeouts and durations
  • Pattern matching works for template ID variations
  • Mock page analysis returns expected content structure

Files to Create

  • test/capture.template-heuristics.test.js - New test file

Acceptance Criteria

  • template-heuristics.js statements coverage reaches ≥50%
  • All template patterns are tested with expected sample data
  • Profile generation logic is validated for each template type
  • Edge cases and fallbacks are covered
  • Tests use proper mocking for page objects

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions