fix(typescript): make auth mocks reusable and fix offset pagination wire tests#16047
fix(typescript): make auth mocks reusable and fix offset pagination wire tests#16047devin-ai-integration[bot] wants to merge 1 commit into
Conversation
Two fixes for wire test generation:
1. Auth mock endpoints (OAuth and inferred auth) now use { once: false }
so they can handle multiple requests during pagination (getNextPage()
triggers re-authentication).
2. Offset pagination without an explicit hasNextPage property but with a
step/limit now correctly skips getNextPage() assertions, since mock
data may not have enough items to satisfy items.length >= step.
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.
Tip: disable this comment in your organization's Code Review settings.
SDK Generation Benchmark ResultsComparing PR branch against median of 5 nightly run(s) on Full benchmark table (click to expand)
main (generator): generator-only time via --skip-scripts (includes Docker image build, container startup, IR parsing, and code generation — this is the same Docker-based flow customers use via |
Description
Fixes wire test generation for paginated endpoints with OAuth/inferred auth, and for offset pagination with step but no hasNextPage property.
Refs https://github.com/fern-demo/hiddenlayer-ts-sdk/actions/runs/26247548581/job/77249728300
Changes Made
1. Auth mock endpoints are now reusable (
{ once: false })Both OAuth client credentials and inferred auth mock generation in
TestGenerator.tspreviously used.mockEndpoint()(single-use). When a paginated endpoint callsgetNextPage(), it triggers a second HTTP request which needs re-authentication. The single-use mock was already consumed, causingECONNREFUSEDon localhost:80.Changed both mock auth generation paths (lines ~471 and ~537) to use
.mockEndpoint({ once: false }).2. Offset pagination with step skips getNextPage assertions
For offset pagination without an explicit
hasNextPageresponse property but WITH astep(limit) property, the SDK'shasNextPage()check usesitems.length >= step. Mock data may not satisfy this condition (e.g., 2 items with limit=10), causinghasNextPage()to returnfalsewhen the test assertstrue.When
stepis defined buthasNextPageis not,isPaginationCursorMissingInExamplenow returnstrue, correctly skipping thegetNextPage()assertions. When neitherstepnorhasNextPageis defined, the SDK usesitems.length > 0which works with any non-empty mock data, so assertions are still generated.Testing
pnpm seed test --generator ts-sdk --fixture pagination— 2/2 passedpnpm seed test --generator ts-sdk --fixture oauth-client-credentials— 2/2 passedpnpm seed test --generator ts-sdk --fixture oauth-client-credentials-default— 1/1 passedpnpm seed test --generator ts-sdk --fixture inferred-auth-explicit— 1/1 passedpnpm seed test --generator ts-sdk --fixture inferred-auth-implicit— 1/1 passedpnpm seed test --generator ts-sdk --fixture any-auth— 3/3 passedLink to Devin session: https://app.devin.ai/sessions/c5391382257a4f8fa34651269a60ab5d