Remove mocks from AI test files and implement full-stack testing #214
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Remove mocks from AI test files and implement full-stack testing
Summary
This PR removes mocks from AI test files (
AI.test.tsx,ai.test.ts, andlanguage-modelstests) and implements full-stack testing using real AI gateway calls with caching. The changes enable more accurate testing of actual system behavior while maintaining test performance through AI gateway caching.Key changes:
vi.mock()calls forai-functions,ai-providers, and@ai-sdk/openaisetupAITestEnvironment()function for AI gateway configurationReview & Testing Checklist for Human
AI_GATEWAY_URLandAI_GATEWAY_TOKENare properly set for tests to workpnpm test --filter=ai-propsto verify ai-providers imports work correctlyRecommended test plan:
pnpm testto verify all packages passpnpm test --filter=ai-propsmultiple times to check for flakinessDiagram
%%{ init : { "theme" : "default" }}%% graph TB subgraph "AI Props Package" AI_test["packages/ai-props/src/<br/>AI.test.tsx"]:::major-edit test_utils["packages/ai-props/src/<br/>test-utils.ts"]:::minor-edit end subgraph "AI Database Package" ai_db_test["packages/ai-database/src/lib/<br/>__tests__/ai.test.ts"]:::major-edit end subgraph "Language Models Package" lang_test["packages/language-models/<br/>tests/index.test.ts"]:::major-edit end subgraph "AI Providers Package" provider["packages/ai-providers/src/<br/>provider.ts"]:::minor-edit build_js["packages/ai-providers/<br/>build.js"]:::minor-edit end subgraph "AI Functions Package" ai_funcs["packages/ai-functions/<br/>test/utils/setupTests.ts"]:::context end AI_test -->|"uses setupAITestEnvironment"| test_utils AI_test -->|"imports real functions"| ai_funcs ai_db_test -->|"removed @ai-sdk/openai mock"| provider lang_test -->|"removed mocks, added setup"| test_utils provider -->|"build fixes"| build_js subgraph Legend L1["Major Edit"]:::major-edit L2["Minor Edit"]:::minor-edit L3["Context/No Edit"]:::context end classDef major-edit fill:#90EE90 classDef minor-edit fill:#87CEEB classDef context fill:#FFFFFFNotes