Skip to content

test(copilot): add dedicated test suite for Glossary OS Copilot#42

Open
paollacq wants to merge 4 commits intosolanabr:mainfrom
paollacq:feat/glossary-copilot-tests
Open

test(copilot): add dedicated test suite for Glossary OS Copilot#42
paollacq wants to merge 4 commits intosolanabr:mainfrom
paollacq:feat/glossary-copilot-tests

Conversation

@paollacq
Copy link
Copy Markdown

@paollacq paollacq commented Apr 7, 2026

Summary

This PR adds a dedicated Vitest suite for Glossary Copilot inside apps/glossary-os, turning Copilot quality into something visible and verifiable instead of implicit. The suite covers the Copilot core from multiple angles: concept detection, domain classification, error pattern matching, context building, prompt construction, structured response parsing, API input validation, and end-to-end Copilot action flows with mocked Gemini responses. In total, the PR adds 67 passing tests across 13 test files, plus a few runtime fixes discovered while building the suite. The goal is straightforward: make the Copilot behavior defensible for reviewers and judges.

What This PR Adds

  • a dedicated test suite under apps/glossary-os/src/__tests__
  • fixtures for realistic Solana / Anchor code and common Solana errors
  • unit coverage for Copilot helper modules
  • integration coverage for generateCopilotAnswer(...) in all action modes:
    • explain
    • debug
    • generate
    • plan
  • contract tests for /api/copilot
  • runtime hardening based on failures surfaced by the tests

Test Coverage

Current suite size:

  • 13 test files
  • 67 passing tests

Covered modules:

  • src/lib/copilot/concept-detector.ts
  • src/lib/copilot/domain-classifier.ts
  • src/lib/copilot/error-patterns.ts
  • src/lib/copilot/prompt-builder.ts
  • src/lib/copilot/response-parser.ts
  • src/lib/copilot.ts
  • src/lib/glossary.ts
  • src/app/api/copilot/route.ts

Test layers:

  • Unit
    • concept detection
    • domain classification
    • error pattern matching
    • response parsing
    • prompt building
    • context building
    • glossary shared utilities
  • Integration
    • explain flow
    • debug flow
    • generate flow
    • plan flow
  • Contract
    • API input validation
    • Copilot structured output shape

Why This Matters

This PR does not add another Copilot surface area. It makes the existing Copilot reliable.

That matters because Glossary Copilot is not a static page feature. It includes:

  • dynamic glossary context assembly
  • prompt construction
  • structured JSON parsing
  • mode-specific behavior
  • API validation
  • Gemini integration boundaries

Without a dedicated suite, regressions in any of those layers would be easy to miss. With this PR, the Copilot behavior becomes much easier to review, maintain, and trust.

Validation

Commands run:

npm run test --workspace @stbr/glossary-os
npm run typecheck:web

Result:

Test Files  13 passed (13)
Tests       67 passed (67)

Screenshots

Local Tests

Copilot Workspace

Local Run

From the repository root:

npm install
npm run test --workspace @stbr/glossary-os
npm run typecheck:web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant