Files
Numman AliandHanzo Dev 0a9834c6fc docs: Enforce GPT 5.1 full-opencode.json as only supported configuration
This PR standardizes all documentation and configuration on GPT 5.1 model identifiers, removes deprecated GPT 5.0 models, and enforces full-opencode.json as the only officially supported configuration. The changes address GPT 5 model temperamental behavior and ensure users have the proper setup for reliable operation with OpenCode.

Co-authored-by: Hanzo Dev <[email protected]>
2025-11-16 21:52:44 +00:00
..
2025-11-11 20:49:43 +00:00

Test Suite

This directory contains the comprehensive test suite for the OpenAI Codex OAuth plugin.

Test Structure

test/
├── README.md                      # This file
├── auth.test.ts                   # OAuth authentication tests
├── config.test.ts                 # Configuration parsing tests
├── logger.test.ts                 # Logging functionality tests
├── request-transformer.test.ts    # Request transformation tests
└── response-handler.test.ts       # Response handling tests

Running Tests

# Run all tests once
npm test

# Watch mode (re-run on file changes)
npm run test:watch

# Visual test UI
npm run test:ui

# Generate coverage report
npm run test:coverage

Test Coverage

auth.test.ts (16 tests)

Tests OAuth authentication functionality:

  • State generation and uniqueness
  • Authorization input parsing (URL, code#state, query string formats)
  • JWT decoding and payload extraction
  • Authorization flow creation with PKCE
  • URL parameter validation

config.test.ts (13 tests)

Tests configuration parsing and merging:

  • Global configuration application
  • Per-model configuration overrides
  • Mixed configuration (global + per-model)
  • Default values and fallbacks
  • Reasoning effort normalization (minimal → low for codex)
  • Lightweight model detection (nano, mini)

request-transformer.test.ts (30 tests)

Tests request body transformations:

  • Model name normalization (all variants → gpt-5 or gpt-5-codex)
  • Input filtering (removing stored conversation history)
  • Tool remap message injection
  • Reasoning configuration application
  • Text verbosity settings
  • Encrypted reasoning content inclusion
  • Unsupported parameter removal

response-handler.test.ts (10 tests)

Tests SSE to JSON conversion:

  • Content-type header management
  • SSE stream parsing (response.done, response.completed)
  • Malformed JSON handling
  • Empty stream handling
  • Status preservation

logger.test.ts (5 tests)

Tests logging functionality:

  • LOGGING_ENABLED constant
  • logRequest function parameter handling
  • Complex data structure support

Test Philosophy

  1. Comprehensive Coverage: Each module has extensive tests covering normal cases, edge cases, and error conditions
  2. Fast Execution: All tests run in < 250ms
  3. No External Dependencies: Tests use mocked data and don't make real API calls
  4. Type Safety: All tests are written in TypeScript with full type checking

CI/CD Integration

Tests automatically run in GitHub Actions on:

  • Every push to main
  • Every pull request

The CI workflow tests against multiple Node.js versions (18.x, 20.x, 22.x) to ensure compatibility.

Adding New Tests

When adding new functionality:

  1. Create or update the relevant test file
  2. Follow the existing pattern using vitest's describe and it blocks
  3. Ensure tests are isolated and don't depend on external state
  4. Run npm test to verify all tests pass
  5. Run npm run typecheck to ensure TypeScript types are correct

Example Configurations

See the config/ directory for working configuration examples:

  • minimal-opencode.json: Simplest setup with defaults
  • full-opencode.json: Complete example with all model variants