Skip to content

test: fix Codex contract refresh fallback#55524

Closed
jalehman wants to merge 1 commit intomainfrom
forge/fix-codex-contract-mock-path
Closed

test: fix Codex contract refresh fallback#55524
jalehman wants to merge 1 commit intomainfrom
forge/fix-codex-contract-mock-path

Conversation

@jalehman
Copy link
Copy Markdown
Contributor

What

Fixes the OpenAI Codex provider runtime contract so the refresh-fallback assertion uses the current runtime mock path and avoids the bundled loader's Jiti mock bypass for that one case.

Why

This is a Forge follow-up for an unrelated test failure discovered while preparing PR #54392.

Changes

  • Update the stale Codex runtime mock path
  • Instantiate Codex provider directly for fallback contract

Testing

  • pnpm test -- src/plugins/contracts/runtime.contract.test.ts -t "owns refresh fallback for accountId extraction failures"
  • pnpm test -- src/plugins/contracts/registry.contract.test.ts

Point the stale contract-test mock at the current Codex runtime module and instantiate the provider directly for the one mock-sensitive fallback case. This keeps the fallback covered without changing production refresh behavior or the separate registry contract coverage.

Regeneration-Prompt: |
  Fix MAR-231, the unrelated prep blocker on PR #54392. The failing surface was src/plugins/contracts/runtime.contract.test.ts for the OpenAI Codex refresh fallback case. Keep production behavior unchanged. The contract loader uses Jiti for bundled providers, which bypasses the Vitest mock of the runtime wrapper and caused the test to hit the real OAuth refresh path. Update the stale runtime mock path and make only that fallback assertion use the direct provider module, while leaving registry coverage in src/plugins/contracts/registry.contract.test.ts intact. Validate with the focused Codex runtime contract test and the registry contract test.
@openclaw-barnacle openclaw-barnacle Bot added size: XS maintainer Maintainer-authored PR labels Mar 27, 2026
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Mar 27, 2026

Greptile Summary

This test-only PR fixes two issues in runtime.contract.test.ts that caused the openai-codex refresh-fallback assertion to fail:\n\n1. Stale mock path corrected: vi.mock(\"../../../extensions/openai/src/openai-codex-provider.runtime.js\", ...) referenced a non-existent src/ subdirectory; the path is updated to ../../../extensions/openai/openai-codex-provider.runtime.js, which correctly matches the actual source file at extensions/openai/openai-codex-provider.runtime.ts.\n2. Direct instantiation to avoid Jiti mock bypass: The test now calls buildOpenAICodexProviderPlugin() directly instead of going through requireProviderContractProvider(\"openai-codex\") (the bundled contract loader). This ensures Vitest's module mock for the runtime wrapper is in effect when refreshOAuth triggers the dynamic import of ./openai-codex-provider.runtime.js, rather than being bypassed by Jiti's loader.\n\nBoth changes are correct and well-scoped, with a clear comment explaining the Jiti bypass rationale.

Confidence Score: 5/5

This PR is safe to merge — it is a test-only fix with no production code changes.

The diff touches a single test file, corrects a stale mock path to match the real file location, and switches one provider instantiation to bypass a known Jiti loader limitation. Both changes are technically correct and narrowly scoped. No logic, APIs, or production behavior is affected.

No files require special attention.

Important Files Changed

Filename Overview
src/plugins/contracts/runtime.contract.test.ts Fixes stale Codex runtime mock path and switches fallback test to direct provider instantiation to avoid Jiti mock bypass.

Reviews (1): Last reviewed commit: "test: fix codex contract refresh fallbac..." | Re-trigger Greptile

@jalehman jalehman closed this Mar 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant