Skip to content

docs: Test suite development summary (346→350 tests, 5-tier coverage) #3

@ranxianglei

Description

@ranxianglei

Summary

This issue documents the comprehensive test suite development for opencode-acp, covering the period from the initial ACP rebrand through the msgid expansion PR (#1).

Test Suite Growth

Phase Tests Files Commit
Baseline (existing from DCP fork) 95 10 d5f1540
Tier 1: Pure function unit tests +83 +6 04105e2
Tier 2: Mock-data unit tests +68 +4 7471a1b
Functional: Compress pipeline tests +77 +3 90b8c00
E2E: Full pipeline tests +21 +2 7268202
Review fixes + backward compat +4 0 17aa4c1, f0cf9d1
Total 350 22

New Test Files (12)

Tier 1 — Pure Function Tests (no dependencies, no mocks)

File Tests Source Module
config-validation.test.ts ~18 lib/config-validation.ts — extracted pure validation
priority-classify.test.ts ~15 lib/priority.ts — message classification
shape.test.ts ~12 lib/shape.ts — token estimation
query-pure.test.ts ~14 lib/query.ts — context query logic
gc-truncate-pure.test.ts ~12 lib/gc/truncate.ts — GC truncation params
state-utils-pure.test.ts ~12 lib/state/utils.ts — state utilities

Tier 2 — Mock-Data Tests

File Tests Source Module
query-mock.test.ts 33 lib/query.ts — with mock messages
gc-truncate-mock.test.ts 11 lib/gc/truncate.ts — with mock state
strategies-dedup.test.ts 12 lib/strategies/dedup.ts — dedup strategy
strategies-purge-errors.test.ts 12 lib/strategies/purge-errors.ts — error purging

Functional — Compress Pipeline

File Tests Source Module
compress-search.test.ts 22 lib/compress/search.ts — boundary resolution
compress-state.test.ts 21 lib/compress/state.ts — block allocation
message-ids.test.ts 34 lib/message-ids.ts — ID formatting/parsing/assignment

E2E — Full Pipeline

File Tests Coverage
e2e-message-transform.test.ts 11 Full hooks pipeline: filtering, hallucination stripping, compression blocks, pruning, manual trigger, persistence
e2e-blocks-nudges.test.ts 10 Nudge injection, block aging, session switch, tool part IDs, block consumption

Key Quality Improvements

Bug Fixes Found Through Testing

  1. resetOnCompaction didn't clear messageIds (lib/state/utils.ts) — production bug caught by test review
  2. purgeErrors.turns < 1 validation was lost during extraction — restored

Review-Driven Fixes

Backward Compatibility Tests

  • parseBoundaryId normalizes 4-digit refs to 5-digit
  • Old persisted state with m0001 keys migrates to m00001 on load
  • Roundtrip stability: old format → parse → format → new format

Test Architecture

  • Runner: node --import tsx --test tests/*.test.ts (Node built-in test runner)
  • Pattern: node:test + node:assert/strict (no vitest/jest)
  • Mocks: Manual factories (buildConfig(), buildMessages(), textPart(), toolPart())
  • CI: GitHub Actions — typecheck + test + build (Node 22/24 matrix)

Documentation

  • TESTING.md — 566 lines: running tests, framework, categories, coverage tables, writing guide
  • AGENTS.md — Updated with mandatory dual-agent review for code + tests

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions