Skip to content

D-28: Dialogue — snapshot + unit tests (parser, reducer, views) #278

@kirich1409

Description

@kirich1409

Description

Bring the Dialogue feature to adequate test coverage — parser fixtures, reducer TestStore cases, view snapshots across appearances.

Spec: Epic #250 §9 acceptance criteria.

Scope

Parser tests (AgentChatTests/Parser/)

Extend fixtures from D-8:

  • 20+ real JSONL snippets covering every event type from spec §2.
  • Dedup test with reconnect-like duplicate streams.
  • Overflow (10+ MiB single line) drop + continue test.
  • Tolerant decode (unknown fields in known type).
  • Partial-line (byte-by-byte feeding).
  • Unknown event type → .unknownEvent(raw:).

Reducer tests (AgentChatTests/Reducer/)

TestStore flows:

  • Happy path: init → text response → tool_use → tool_result → completed → result.
  • Tool failure path.
  • API retry → recovered.
  • Rate limit rejected → status .error.
  • Compact boundary divider.
  • Interrupt mid-stream.
  • Unknown event logging.
  • Cost threshold crossed → costAlertShown = true.

View snapshot tests (AgentChatUISnapshotTests/)

Using pointfreeco/swift-snapshot-testing:

  • All 12 tool widgets × 4 appearances (light/dark/HCR/reduceTransparency) — populated / collapsed / expanded states.
  • Message views — short / long / multi-segment × 4 appearances.
  • ThinkingIndicator — collapsed / expanded / streaming / completed.
  • DialogueView composite — empty / streaming / tool running / error / rate-limited.
  • PreflightErrorView — each reason variant.
  • StreamInspectorView — filtered / unfiltered.

Coverage target

Not aiming for % metric — aim for flow coverage. Every user-visible state of every view should have at least one snapshot; every reducer transition should have at least one TestStore case.

Acceptance Criteria

  • Parser test suite passes with 20+ fixtures covering spec.
  • Reducer TestStore suite passes with 8+ flows.
  • Snapshot tests cover all widgets + views × 4 appearances.
  • swift test in each new package passes.
  • CI Swift step extended to run both packages' tests.
  • Snapshot reference images committed.

Relationships

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions