Companion: add a functional test for the Mermaid render DOM mutations

Open
#18 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
Half a day
Newbie friendliness
42/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Domain
testing-qa

Research direction

Start with the render functions in apps/api/src/companion/v1.js (lines 137-200), then the mirror tests in apps/api/src/companion/mermaidScanner.test.ts to see how existing tests mirror the browser code. Add a jsdom-based test that stubs mermaid.render and asserts the primer-mermaid wrapper, data-mermaid-source attribute, and primer-mermaid-error note. Done when the test passes and covers the theme re-render round-trip.

Written by the indexing model from the issue text.

Description

triage

Surfaced by: code review on #15 (Mermaid auto-rendering).

The Task 3 wiring added renderAllMermaidBlocks, renderOneMermaidBlock, loadMermaidOnce, and reRenderMermaidForTheme to apps/api/src/companion/v1.js. Coverage today:

  • apps/api/src/companion/mermaidScanner.test.ts — mirror tests for findMermaidBlocks + documentHasMermaidBootstrap. Strong.
  • apps/api/src/routes/companion.test.ts — smoke assertion that the new function names appear in the served body. Catches the "new code shipped" case but not behavior.

Missing: a jsdom-driven mirror that exercises the render-DOM-mutation logic — wrapper shape (<div class=\"primer-mermaid\" data-mermaid-source>), error-path inline note (<div class=\"primer-mermaid-error\">), data-mermaid-source round-trip on theme re-render. We can stub out mermaid.render to return a known string and assert the resulting DOM shape.

Worth doing the next time anyone touches the render pipeline.

apps/api/src/companion/v1.js:137-200

Dominant language
TypeScript
Stars
2
Forks
1
Avg merge
13h 38m
Merged PRs (30d)
24

Getting set up

  • Ships a Dockerfile or Docker Compose file
  • No pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from 0xPolygon/primer

All issues in 0xPolygon/primer

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.