Skip to content

Share one token-link builder across tests #470

Closed

Description

@imnasnainaec

Six test files each build approved token links with their own helper. Replace them with one makeTokenLink in src/__tests__/test-helpers.ts, beside makePhraseLink.

Today

File Builder Default id Uses
analysis-repository-conformance.ts (#469) tokenLink(id, analysisId, tokenRef, surfaceText) none; the caller passes it 4
types/type-guards.test.ts tokenLink(analysisId, status?, tokenRef?) ref:analysis:status 10
utils/analysis-book.test.ts mkTokenLink(analysisId, tokenRef) ref:analysis 12
utils/project-analysis-summary.test.ts mkTokenLink(analysisId, tokenRef) ref:analysis 11
utils/reanchor-analysis.test.ts makeTokenLink(tokenRef, surfaceText, analysisId?) ref:analysis 76
utils/analysis-violations.test.ts linkTo(analysisId, tokenRef, id?) tl-ref 6

Watch for

  • Unique default ids. type-guards.test.ts puts the status in the id, so two links on one token and payload stay distinct. The shared default must keep that.
  • Explicit ids. analysis-violations.test.ts passes the same id twice to trigger duplicateLinkId, so callers must still be able to set the id.
  • Surface text. Some builders default it to the token ref; reanchor-analysis.test.ts needs a real one for drift detection. Default it, but allow an override.

As the data layer plan lands

Done when

The test files build token links only through makeTokenLink, and the suite passes unchanged.

Metadata

Metadata

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions