Skip to content

fix(typescript): make auth mocks reusable and fix offset pagination wire tests#16047

Open
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1779394976-fix-ts-wire-test-pagination-oauth
Open

fix(typescript): make auth mocks reusable and fix offset pagination wire tests#16047
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1779394976-fix-ts-wire-test-pagination-oauth

Conversation

@devin-ai-integration
Copy link
Copy Markdown
Contributor

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.ts previously used .mockEndpoint() (single-use). When a paginated endpoint calls getNextPage(), it triggers a second HTTP request which needs re-authentication. The single-use mock was already consumed, causing ECONNREFUSED on 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 hasNextPage response property but WITH a step (limit) property, the SDK's hasNextPage() check uses items.length >= step. Mock data may not satisfy this condition (e.g., 2 items with limit=10), causing hasNextPage() to return false when the test asserts true.

When step is defined but hasNextPage is not, isPaginationCursorMissingInExample now returns true, correctly skipping the getNextPage() assertions. When neither step nor hasNextPage is defined, the SDK uses items.length > 0 which works with any non-empty mock data, so assertions are still generated.

  • Updated seed test snapshots for all affected fixtures (pagination, oauth, inferred-auth, any-auth, etc.)

Testing

  • pnpm seed test --generator ts-sdk --fixture pagination — 2/2 passed
  • pnpm seed test --generator ts-sdk --fixture oauth-client-credentials — 2/2 passed
  • pnpm seed test --generator ts-sdk --fixture oauth-client-credentials-default — 1/1 passed
  • pnpm seed test --generator ts-sdk --fixture inferred-auth-explicit — 1/1 passed
  • pnpm seed test --generator ts-sdk --fixture inferred-auth-implicit — 1/1 passed
  • pnpm seed test --generator ts-sdk --fixture any-auth — 3/3 passed
  • All other affected fixtures verified (endpoint-security-auth, websocket-inferred-auth, etc.)
  • Pre-existing expected failures remain expected (oauth-client-credentials-custom, inferred-auth-implicit-reference)

Link to Devin session: https://app.devin.ai/sessions/c5391382257a4f8fa34651269a60ab5d

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-integration
Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Copy link
Copy Markdown

@claude claude Bot left a comment

Choose a reason for hiding this comment

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

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.

@devin-ai-integration devin-ai-integration Bot changed the title fix: make auth mocks reusable and fix offset pagination wire tests fix(typescript): make auth mocks reusable and fix offset pagination wire tests May 21, 2026
@github-actions
Copy link
Copy Markdown
Contributor

SDK Generation Benchmark Results

Comparing PR branch against median of 5 nightly run(s) on main (latest: 2026-05-21T05:23:53Z).

Full benchmark table (click to expand)
Generator Spec main (generator) main (E2E) PR (generator) Delta
ts-sdk square 231s (n=5) 240s (n=5) 221s -10s (-4.3%)

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 fern generate). main (E2E): full customer-observable time including build/test scripts (nightly baseline, informational). Delta is computed against generator-only baseline.
⚠️ = generation exited with a non-zero exit code (timing may not reflect a successful run).
Baseline from nightly runs on main (latest: 2026-05-21T05:23:53Z). Trigger benchmark-baseline to refresh.
Last updated: 2026-05-21 21:12 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

0 participants