Skip to content

test(gateway): port-agnostic e2e, opt-in ocr - #3514

Merged
steebchen merged 1 commit into
mainfrom
fix/e2e-harness-port-and-ocr-optin
Aug 9, 2026
Merged

steebchen merged 1 commit into
mainfrom
fix/e2e-harness-port-and-ocr-optin

Conversation

@steebchen

@steebchen steebchen commented Aug 9, 2026 •

Copy link
Copy Markdown
Member

Problem

Two unrelated ways a scoped test run reports failures that have nothing to do with the change under test. Both showed up while verifying #3492.

1. Video log-content assertions hardcode http://localhost:4001.

gateway-api-test-harness.ts and two videos.spec.ts assertions compare against a literal http://localhost:4001, but the gateway builds that URL from getGatewayPublicBaseUrl() (i.e. GATEWAY_URL). Any worktree following AGENTS.md's "isolated stack per worktree" guidance runs on an offset GATEWAY_PORT, so three video tests fail:

AssertionError: expected 'http://localhost:4801' to be 'http://localhost:4001'
 ❯ gateway-api-test-harness.ts:278

The tests were asserting the port, not the behaviour.

2. ocr.e2e.ts runs unconditionally and hardcodes mistral-ocr-latest.

It only skipped when LLM_MISTRAL_API_KEY was entirely absent, so a Mistral key without the separate OCR entitlement fails with an upstream {"detail":"Invalid API Key"} → 401 on every e2e run, including ones scoped to an unrelated model:

$ TEST_MODELS="together-ai/gpt-oss-20b" FULL_MODE=true pnpm test:e2e
 FAIL  apps/gateway/src/ocr.e2e.ts > /v1/ocr extracts a document via mistral-ocr-latest
 Tests  1 failed | 102 passed

OCR is also billed per page, so it should not run on every unrelated scoped run in the first place.

Approach

Port: assert against the same helpers the gateway itself uses — getGatewayPublicBaseUrl() in the harness, buildGatewayVideoLogContentUrl() in videos.spec.ts. The tests now verify the URL matches what the app produces, on any port, and keep working on the http://localhost:4001 default.

OCR: OCR models already live in the catalogue (output: ["ocr"], ocr: true), so drive the suite from it like the rerank/speech/transcription suites do. Adds an ocrModels list to chat-helpers.e2e.ts mirroring rerankModels (same TEST_MODELS/TEST_PROVIDERS, deactivation, env-var and stability filters), and ocr.e2e.ts becomes test.each(ocrModels).

The mapping is marked test: "skip", which makes the suite opt-in — TEST_MODELS overrides test: "skip", so it runs exactly when you ask for it:

TEST_MODELS="mistral/mistral-ocr-latest" pnpm test:e2e

The "rejects an unknown model with 400" case is pure request validation, rejected before any provider is contacted, so it no longer needs a key gate and runs always.

Verification

videos.spec.ts — 50/50 pass on all three configurations (previously 3 failures on the first):

GATEWAY_URL before after
http://localhost:4801 (offset stack) 3 failed 50 passed
http://localhost:4001 (explicit) 50 passed 50 passed
unset (falls back to :4001) 50 passed 50 passed

ocr.e2e.ts:

$ pnpm test:e2e                                          # default
Testing 0 ocr model configurations
 ✓ /v1/ocr rejects an unknown model with 400
 Tests  3 passed

$ TEST_MODELS="mistral/mistral-ocr-latest" pnpm test:e2e # opt-in
Testing 1 ocr model configurations
 × /v1/ocr extracts a document via 'mistral/mistral-ocr-latest'   # this machine's key lacks the OCR entitlement

The scoped run that previously failed is now clean:

$ TEST_MODELS="together-ai/gpt-oss-20b" FULL_MODE=true pnpm test:e2e
 Test Files  29 passed | 2 skipped (31)
      Tests  102 passed | 88 skipped (190)

Gates: pnpm build 17/17 · pnpm lint 17/17 · packages/models 131/131 · full apps/gateway unit suite 2171 passed. One failure there — openai-content-filter.spec.ts > logs missing moderation credentials — reproduces identically on unmodified main with these changes stashed; it is the known local .env leakage (the spec assumes no OpenAI key is configured) and is untouched by this PR.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests

    • Expanded OCR extraction coverage across configured providers and models, including region-specific and selectively enabled test scenarios.
    • Added consistent validation for unknown OCR models, regardless of provider credentials.
    • Updated video log URL checks to work with configured gateway environments instead of relying on local addresses.
  • Chores

    • Mistral OCR tests are now opt-in because they require separate OCR access.

The video log-content assertions hardcoded http://localhost:4001, so
videos.spec.ts failed for any worktree running an isolated stack on an
offset GATEWAY_PORT. Assert against the same helpers the gateway uses to
build the URL instead.

ocr.e2e.ts hardcoded mistral-ocr-latest and only skipped when
LLM_MISTRAL_API_KEY was absent, so a key without the OCR entitlement
failed every scoped e2e run with an upstream 401 unrelated to the change
under test. Drive it from the catalogue like the rerank/speech suites via
a new ocrModels list, and mark the mapping test: "skip" so it runs only
under TEST_MODELS="mistral/mistral-ocr-latest".

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings August 9, 2026 18:09
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Aug 9, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 1b7cfdad-ab82-479d-8d7e-d682a555be0b

📥 Commits

Reviewing files that changed from the base of the PR and between fb28632 and 4f528a8.

📒 Files selected for processing (5)
  • apps/gateway/src/chat-helpers.e2e.ts
  • apps/gateway/src/ocr.e2e.ts
  • apps/gateway/src/test-utils/gateway-api-test-harness.ts
  • apps/gateway/src/videos/videos.spec.ts
  • packages/models/src/models/mistral.ts

Walkthrough

The PR adds filtered OCR model configurations for parameterized gateway E2E tests, disables Mistral OCR tests by default, and updates video log URL assertions to use shared gateway URL helpers.

Changes

OCR and gateway E2E updates

Layer / File(s) Summary
OCR model selection
apps/gateway/src/chat-helpers.e2e.ts
Builds OCR test cases with provider, model, region, environment, stability, deprecation, and test-selection filters. Logs the generated configuration count.
Parameterized OCR execution
apps/gateway/src/ocr.e2e.ts, packages/models/src/models/mistral.ts
Runs extraction tests for each configured OCR model. Unknown-model validation always runs. Mistral OCR tests are skipped by default.
Dynamic video log URL assertions
apps/gateway/src/test-utils/gateway-api-test-harness.ts, apps/gateway/src/videos/videos.spec.ts
Uses shared gateway URL helpers instead of hard-coded localhost URLs.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant OCRTestSuite
  participant GatewayAPI
  participant OCRProvider
  OCRTestSuite->>GatewayAPI: Send extraction request with configured OCR model
  GatewayAPI->>OCRProvider: Execute OCR extraction
  OCRProvider-->>GatewayAPI: Return extraction result
  GatewayAPI-->>OCRTestSuite: Return test response
Loading

Possibly related PRs

Suggested reviewers: smakosh

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the two main changes: port-agnostic gateway E2E tests and opt-in OCR testing.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/e2e-harness-port-and-ocr-optin

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@steebchen
steebchen merged commit 94f23d9 into main Aug 9, 2026
12 checks passed
@steebchen
steebchen deleted the fix/e2e-harness-port-and-ocr-optin branch August 9, 2026 18:53
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.

2 participants