Architecture decision record · ADR-0013

Test harnesses in @meridian-ts/test-support

A new package @meridian-ts/test-support has one harness for each HTML part.

Status
Accepted
Deciders
Joe Gaudet
Created
Updated
PRD
PRD
Related
None

Context

The tests of the guide, the test app and the stories found elements with CSS selectors and MapLibre class names. A change of markup then breaks many tests, and an application that uses Meridian has no tested way to drive its maps. The sibling library Lattice ships harnesses on harnessed (@harnessed-ts/core).

A map has two kinds of parts:

  • HTML parts: markers, popups, controls, the place search and the route steps. A harness finds them by their role and accessible name, and acts on them as a person does.
  • Canvas parts: sources, layers, clusters, the route line, the draw shapes and the deck.gl layers. They are pixels in a WebGL canvas. No DOM query can read them.

Decision drivers

Not recorded in the original ADR.

Options considered

Not recorded in the original ADR.

Decision

  • A new package @meridian-ts/test-support has one harness for each HTML part. It is plain TypeScript, built with tsup, so the standard decorators are compiled in the package. An application needs no Babel plugin, and the harnesses run with each harnessed driver.

  • Each harness finds its host by role and accessible name only:

    Harness Host
    MapHarness the map canvas, region "Map"
    MarkerHarness button "Map marker"
    PopupHarness dialog "Map popup"
    NavigationControlHarness button "Zoom in"
    GeolocateControlHarness button "Find my location" or "Location not available"
    FullscreenControlHarness button "Enter fullscreen" or "Exit fullscreen"
    GlobeControlHarness button "Enable globe" or "Disable globe"
    TerrainControlHarness button "Enable terrain" or "Disable terrain"
    PlaceAutocompleteHarness combobox (any name, or the name that the test gives)
    GeocoderControlHarness combobox "Search places"
    DirectionsStepsHarness list "Route steps"
  • Two components get the ARIA that the table needs. <map.Popup> gives the popup element role="dialog" and the name "Map popup" (@label changes it). <DirectionsSteps> gives its list the name "Route steps" (aria-label changes it). This also helps screen reader users.

  • The labels are the English defaults of MapLibre. A test of a map with another locale gives the names to the harness.

  • Canvas parts have no harness. Their tests read the map instance (getLayer, getSource, getPaintProperty, queryRenderedFeatures) next to the harness calls.

  • Amended (2026-12-03): the guide samples assert only through harness methods and @harnessed-ts/should. So MapHarness has layerType(map, id) and zoom(map), which read the map instance that the test gives. They work only when the test and the map are in the same process (QUnit, a Jig story), not in Playwright. Other canvas reads stay on the map instance. ScaleControl and AttributionControl show text with no role, so they have no harness either; their tests use assert.dom.

  • The test app, the guide tests and the Jig story play functions use the harnesses (@harnessed-ts/ember in QUnit, @jig-ts/harnessed in stories).

Consequences

  • A markup change inside a component changes its harness only, not each test.
  • An application can drive a Meridian map in its own tests with the same harnesses.
  • Canvas assertions stay tied to the MapLibre API. This is a limit of a WebGL map, not of the harnesses.

Findings while the harnesses were built

  • MapLibre changes the title of a toggle button (globe, terrain, fullscreen) and keeps the first aria-label. A screen reader then reads the old name, for example "Enable globe" while the globe shows. The harnesses read the state from title. Report this to MapLibre.
  • The harnessed Ember driver runs on Ember 5.12, so the harness tests are in the plain suite that CI runs on 7.3, 6.12 and 5.12.
  • The guide app keeps its own harness (docs-app/tests/harnesses/guide.harness.ts) for the guide header, navigation and content. Its harness files are a TypeScript project of their own (tsconfig.harness.json), and @harnessed-ts/core/babel compiles them, because the app compiles its own decorators in the legacy form.

Confirmation

Not recorded in the original ADR.

Interview record

Each question of the interview with its answer and its source. A fact from the code or a document, a question that the author did not ask, and an assumption are rows too.

QuestionAnswerSource
Where does the text of this page come from?From the Markdown file docs/adr/0013-harnesses.md at commit ece53da. The text of each section is the text of the Markdown file. A section that the Markdown file does not have says so.Document: docs/adr/0013-harnesses.md

Changelog

DateAuthorChange
2026-12-02Joe GaudetStatus in the Markdown file: Accepted (2026-12-02).
2026-12-02Joe GaudetCommit fa9b0fd: Test harnesses for Meridian (#3)
2026-12-03Joe GaudetCommit 665a4fc: docs: assert with should matchers in the testing guide (#5)
2026-12-04Joe Gaudet (agent)Converted from docs/adr/0013-harnesses.md to this page. The text is the text of the Markdown file.

The adr skill of skillsaw wrote this page. The HTML in this file is the source of truth. The diagrams are the Mermaid sources in it.