Skip to content

test(generator): add missing test coverage for generateVersusSVG and generateAutoThemeVersusSVG #4822

@taniy8

Description

@taniy8

Is your feature request related to a problem? Please describe.

generateVersusSVG (and its internal generateAutoThemeVersusSVG branch) in lib/svg/generator.ts currently have no dedicated test coverage in lib/svg/generator.test.ts.

Every other SVG generator has direct tests:

  • generateSVG
  • generateMonthlySVG
  • generateHeatmapSVG
  • generatePulseSVG
  • generateNotFoundSVG
  • generateRateLimitSVG
  • generateVersusSVG

This is particularly important because generateAutoThemeVersusSVG was recently refactored to replace hand-rolled tower rendering loops with renderTowers(), and there are no regression tests covering that code path.

A search of the test suite shows only a single "versus" reference, related to contrast logic rather than validating SVG output from generateVersusSVG.

Describe the solution you'd like

Add a describe('generateVersusSVG') block and a describe('generateVersusSVG auto-theme') block to lib/svg/generator.test.ts covering:

  • Renders valid SVG (<svg ... </svg>)
  • viewBox width equals double the single-panel width
  • Contains VS divider circle and text
  • Both usernames rendered in output
  • role="img", aria-labelledby, aria-describedby present
  • <title> includes both usernames
  • <desc> includes contribution counts for both users
  • Winner gets crown emoji 👑; tied match produces no crown
  • Dashed divider line between panels
  • XML-reserved characters in usernames are escaped
  • hideBackground: true renders transparent background

Auto-theme:

  • Injects --cp-bg, --cp-accent, --cp-text CSS vars
  • Includes prefers-color-scheme: dark media query
  • Uses cp-accent-fill / cp-bg-fill classes instead of hardcoded hex values

Describe alternatives you've considered

No response

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions