Skip to content

test: property-based testing foundation (fast-check) over parsing/geometry kernels #1413

Description

@thymikee

Part of #1412 (Track A).

Context

No property-based tests exist. The highest-value targets are pure parse/print and geometry kernels that agents touch constantly and that currently rely on hand-picked examples.

Deliverables

  • Add fast-check as a dev dependency; add input generators (selectors, refs, rects, .ad lines) to src/__tests__/test-utils/ behind the existing barrel.
  • First properties, each in the owning module's test file:
    1. Selector grammar: parse→serialize→parse idempotence, including quote/apostrophe hazards (src/selectors/parse.ts).
    2. Pinned-ref grammar: @eN~sM split/join round-trip (splitRefGenerationSuffix).
    3. buildGesturePlan: for any supported gesture and any viewport, every synthesized point stays in bounds (replaces the two hand-pinned compact viewports in test/integration/smoke-ios-simulator-coverage.test.ts as the general guarantee; keep those as examples).
    4. .ad script parser: parse→serialize→parse stability for generated valid scripts (src/replay/script.ts).
    5. Snapshot diff: diff(a,a) is empty; summary counts always equal rendered line counts (src/snapshot/snapshot-diff.ts).
  • One short section in docs/agents/testing.md: "pure parser or geometry change → extend a property, not another example."

Acceptance

  • Properties run in unit-core within the slow-test budget (bound numRuns).
  • Failure output includes the shrunk counterexample.
  • pnpm check:affected --base origin/main --run green.

Out of scope

Fuzzing the CLI arg surface (separate fuzz-lane issue); exec/subprocess layer.

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