test(fal): add speech/transcription usage coverage; drop e2e billing test#725
Conversation
…test Follow-up to #723 addressing CodeRabbit review feedback. - Add unit coverage for `result.usage.unitsBilled` on the fal speech and transcription adapters (billed + unbilled cases), mirroring the existing audio/image/video adapter tests. - Remove the e2e `fal-billable-units` spec, its `/api/fal-billable-units` route, and the hand-rolled `/fal-queue` aimock mount. aimock has no seam to stamp the `x-fal-billable-units` response header the feature reads, so any e2e test required manipulating `fetch` to redirect fal's hardcoded `queue.fal.run` URLs. The billed-units behavior is now covered by unit tests across all five fal adapters instead. - Drop the now-orphaned `@tanstack/ai-fal` dependency from the e2e app and regenerate the route tree. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
📝 WalkthroughWalkthroughThis PR consolidates Fal billing/usage test coverage from E2E to unit test scope. Unit tests are added to the speech and transcription adapters to validate ChangesConsolidate Fal Billing Tests to Unit Level
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning Tools execution failed with the following error: Failed to run tools: 13 INTERNAL: Received RST_STREAM with code 2 (Internal server error) 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. Comment |
🚀 Changeset Version Preview3 package(s) bumped directly, 28 bumped as dependents. 🟥 Major bumps
🟨 Minor bumps
🟩 Patch bumps
|
|
View your CI Pipeline Execution ↗ for commit 9e23e54
💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗ ☁️ Nx Cloud last updated this comment at |
@tanstack/ai
@tanstack/ai-anthropic
@tanstack/ai-client
@tanstack/ai-code-mode
@tanstack/ai-code-mode-skills
@tanstack/ai-devtools-core
@tanstack/ai-elevenlabs
@tanstack/ai-event-client
@tanstack/ai-fal
@tanstack/ai-gemini
@tanstack/ai-grok
@tanstack/ai-groq
@tanstack/ai-isolate-cloudflare
@tanstack/ai-isolate-node
@tanstack/ai-isolate-quickjs
@tanstack/ai-mcp
@tanstack/ai-ollama
@tanstack/ai-openai
@tanstack/ai-openrouter
@tanstack/ai-preact
@tanstack/ai-react
@tanstack/ai-react-ui
@tanstack/ai-solid
@tanstack/ai-solid-ui
@tanstack/ai-svelte
@tanstack/ai-utils
@tanstack/ai-vue
@tanstack/ai-vue-ui
@tanstack/openai-base
@tanstack/preact-ai-devtools
@tanstack/react-ai-devtools
@tanstack/solid-ai-devtools
commit: |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/ai-fal/tests/transcription-adapter.test.ts (1)
7-16: ⚡ Quick winExtract duplicated
seedBillableUnitshelper to shared test utility.The
seedBillableUnitshelper is identical in bothspeech-adapter.test.tsandtranscription-adapter.test.ts. Consider extracting it to a shared test utility file (e.g.,packages/ai-fal/tests/test-utils.tsorpackages/ai-fal/tests/helpers/billing.ts) to avoid duplication and ensure consistency.♻️ Suggested refactor
Create
packages/ai-fal/tests/test-utils.ts:import { recordBillableUnitsFromResponse } from '../src/utils/billing' export function seedBillableUnits(requestId: string, units: string) { recordBillableUnitsFromResponse( new Response(null, { headers: { 'x-fal-request-id': requestId, 'x-fal-billable-units': units, }, }), ) }Then import in both test files:
-import { recordBillableUnitsFromResponse } from '../src/utils/billing' - -function seedBillableUnits(requestId: string, units: string) { - recordBillableUnitsFromResponse( - new Response(null, { - headers: { - 'x-fal-request-id': requestId, - 'x-fal-billable-units': units, - }, - }), - ) -} +import { seedBillableUnits } from './test-utils'🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/ai-fal/tests/transcription-adapter.test.ts` around lines 7 - 16, The seedBillableUnits helper is duplicated; extract it into a shared test utility (e.g., test-utils or helpers file) that exports seedBillableUnits which calls recordBillableUnitsFromResponse with a Response containing the 'x-fal-request-id' and 'x-fal-billable-units' headers; then replace the local seedBillableUnits definitions in both transcription-adapter.test.ts and speech-adapter.test.ts with a single import of the shared seedBillableUnits utility.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@packages/ai-fal/tests/transcription-adapter.test.ts`:
- Around line 7-16: The seedBillableUnits helper is duplicated; extract it into
a shared test utility (e.g., test-utils or helpers file) that exports
seedBillableUnits which calls recordBillableUnitsFromResponse with a Response
containing the 'x-fal-request-id' and 'x-fal-billable-units' headers; then
replace the local seedBillableUnits definitions in both
transcription-adapter.test.ts and speech-adapter.test.ts with a single import of
the shared seedBillableUnits utility.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 3d516acd-adc2-4bc3-856a-9a6846e1d153
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (7)
packages/ai-fal/tests/speech-adapter.test.tspackages/ai-fal/tests/transcription-adapter.test.tstesting/e2e/global-setup.tstesting/e2e/package.jsontesting/e2e/src/routeTree.gen.tstesting/e2e/src/routes/api.fal-billable-units.tstesting/e2e/tests/fal-billable-units.spec.ts
💤 Files with no reviewable changes (5)
- testing/e2e/package.json
- testing/e2e/global-setup.ts
- testing/e2e/src/routes/api.fal-billable-units.ts
- testing/e2e/tests/fal-billable-units.spec.ts
- testing/e2e/src/routeTree.gen.ts
Follow-up to #723 addressing CodeRabbit review feedback.
What
result.usage.unitsBilledon the fal speech and transcription adapters (billed + unbilled cases), mirroring the existing audio/image/video adapter tests.fal-billable-unitsspec, its/api/fal-billable-unitsroute, and the hand-rolled/fal-queueaimock mount — plus the now-orphaned@tanstack/ai-fale2e dependency (route tree regenerated).Why
aimock has no seam to stamp the
x-fal-billable-unitsresponse header the feature reads, so the e2e test only worked by manipulatingfetchto redirect fal's hardcodedqueue.fal.runURLs. The billed-units behavior is now covered by unit tests across all five fal adapters instead.Testing
@tanstack/ai-falunit tests: 103 passtsc+ eslint (./src) clean;sherifclean🤖 Generated with Claude Code
Summary by CodeRabbit
Tests
Chores