Repository navigation
test: mock the extensions API in integration tests - #8640
Conversation
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…ding Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Summary
Merge Risk: 🔵 Low · up to
|
commit: |
Some of the CLI's tests were quietly calling Netlify's real extensions service when they should only talk to the fake API server they run against. A recent change started sending the tests' fake login token with that call. The real service rejects that token, and the CLI then carried on without any site information, which broke a test that checks the account ID. This sends that call to the fake server during tests and turns the check back on. Nothing changes for people using the CLI.
What changed
BaseCommand.getConfignow passestestOptstoresolveConfigwhenNETLIFY_API_URLpoints at a loopback host (localhost,127.0.0.1,[::1]). This goes through a newgetLocalApiTestOptshelper insrc/utils/local-api-test-opts.ts. In@netlify/config,testOpts.hostonly decides where the extensions request goes; the API client already gets the same host.netlify build(src/lib/build.ts) already passestestOptsfor anyNETLIFY_API_URL. This path is limited to loopback hosts because@netlify/configsends the request, token included, over plainhttp://to any host that isn't a Netlify one.tests/integration/utils/mock-api.tsnow match any site or account ID; before, they matched only the literalsite_id/account_id. The same routes are added totests/integration/utils/mock-api-vitest.ts, which had none.account.idassertion intests/integration/commands/dev/v2-api.test.ts, commented out in feat: deploy server config #8639, is back.Background: netlify/build#7268 removed the
send_build_bot_token_to_jigsawflag, so@netlify/config25.3.0 always sends the token. The real team endpoint returns 403 forfake-token, andgetConfigthen quietly re-resolves offline. Real users are unaffected: real sites already returnsend_build_bot_token_to_jigsaw: trueto the CLI.How it was verified
typecheck,lint,format:checkandtest:unitall pass (756 tests).v2-api.test.tspasses, 24 of 24. With the oldbase-command.ts, "receives context" fails with the sameaccount.iderror CI showed.dev.test.ts,build-program.test.ts,build.test.tsandtelemetry.test.tspass.Closes EX-3522