Skip to content

test(replay): session-replay-vars.test.ts (2,299 lines) tests everything except its namesake — split by actual subject #1460

Description

@thymikee

Context

src/daemon/handlers/__tests__/session-replay-vars.test.ts (2,299 lines, 65 tests, 0 describe blocks) contains zero references to buildReplayBuiltinVars — the only export of the module it is named after (src/daemon/handlers/session-replay-vars.ts, whose real test lives next door in the correctly-named session-replay-builtin-vars.test.ts). What it actually contains (verified 2026-07-28):

  1. ~450 lines testing src/replay/vars.ts (buildReplayVarScope, resolveReplayString, collectReplayShellEnv, parseReplayCliEnvEntries, resolveReplayAction) — a module with real precedence/escaping logic and no test file of its own name anywhere.
  2. ~15 tests of parseReplayScriptDetailed/readReplayScriptMetadata that are pure duplication — src/replay/__tests__/script.test.ts (589 lines, property-based) already covers both thoroughly.
  3. ~1,820 lines re-testing runReplayScriptFile from session-replay-runtime.ts, which already has its own 540-line session-replay-runtime.test.ts (18 direct calls vs this file's 4).

Anyone auditing coverage for these modules lands in the wrong file or concludes coverage is missing. Note: PR #1451 (daemon modularity proposal) will eventually relocate replay tests wholesale — keep this move minimal and mechanical so it doesn't fight that migration.

Task

Redistribute the file's contents to where each test's subject lives; delete true duplicates.

Acceptance criteria

  • The src/replay/vars.ts tests move to src/replay/__tests__/vars.test.ts (new file, co-located with its subject).
  • The duplicated script.ts tests are deleted after a per-test check that an equivalent assertion exists in src/replay/__tests__/script.test.ts; any test asserting something script.test.ts does not cover moves there instead. List the disposition of each in the PR description (moved/deleted-as-duplicate-of-X).
  • The runReplayScriptFile tests merge into session-replay-runtime.test.ts (or a clearly named sibling like session-replay-runtime-maestro.test.ts if size demands), deduplicating against its existing 18 call sites the same way — one obvious home for that function's coverage afterward.
  • session-replay-vars.test.ts is deleted.
  • No production changes; no net loss of distinct assertions (dedup of genuinely identical coverage is the only permitted reduction, and it must be itemized).
  • pnpm test:unit green; changed-line coverage gate (check:coverage-changed) unaffected since no prod lines change.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions