Repository navigation
refactor(supabase_test)!: take HttpMethod for method matching and align names with supabase_flutter's testing helpers - #2025
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
…gn names with supabase_flutter's testing helpers
…ocument the migration
e48fcbc to
b9791d1
Compare
…#2045) #2025 changed the `method:` parameter of `MockSupabaseHttpClient.requestsTo` and the stub helpers to take an `HttpMethod`. #2018 and #2019 were tested against main without that change and pass `HttpMethod.x.value`, so after all three merged, main no longer analyzes in `supabase_storage` and `supabase_flutter_web_auth`. This passes the enum value at those five call sites. Related: https://linear.app/supabase/issue/SDK-2358 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit - **Tests** - Updated request-method checks in authentication and storage test coverage to use consistent method representations. These changes affect test validation only; application behavior, supported operations, and expected request outcomes remain unchanged. The existing scenarios continue to verify the same requests and outcomes. No end-user-facing functionality or interface changes are included in this update. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
…anges met (#2046) Three combinations of PRs that were each green on their own broke main. - `supabase_auth`: #2027 added `pkce_failed_request_test.dart` passing `HttpMethod.x.value`, but #2025 changed `requestsTo` and the stub helpers to take an `HttpMethod`, so the package no longer analyzes. - `supabase_test`: since #2027, a local `signOut()` revokes the session in the background. The `stubSignOut` test looked for the `/logout` request right after `signOut()` returned, so it now waits for the event queue first. - `supabase_typegen`: #2020 added a `badge` table to the hostile fixture, and #2044 suffixes generated names that clash with Flutter types, so the class is now `BadgeTable`. The hostile golden is regenerated, and the tests that reference the class use the new name.
Linear: https://linear.app/supabase/issue/SDK-2358/refactorsupabase-test-take-httpmethod-for-method-matching-and-align
Changes
method:takesHttpMethod.stub,stubText,stubError,stubStall,stubStatuses,stubHandler,stubTableandrequestsTonow takeHttpMethod?instead of a rawString, so a typo no longer compiles. Every call site in the workspace, the README, the example, the skill andAGENTS.mdmoved fromHttpMethod.post.value(or'POST') toHttpMethod.post.RecordedRequest.methodstays aString, since it is what went over the wire.package:supabase_testre-exportsHttpMethod, so a test that imports onlysupabase_testand, for example,supabase_storagecan still call these methods.testSupabaseClientandinitializeTestSupabasetake the same parameter names.apiKeybecamepublishableKey, andrealtime: MockRealtimeTransportbecamerealtimeTransport: WebSocketTransport, matchinginitializeTestSupabase. A mock transport is passed asrealtimeTransport: realtime.callin both places.sb_publishable_key in both helpers (testPublishableKeyinsupabase_flutter/testing.dartis now aconst). Signed-out requests now carry the headers a production publishable key produces.publishableKeystays nullable in both, andnullfalls back to the default.MIGRATION.mdgets a short "Testing" section covering the renames and the new default key.Notes for review
realtimeTransportis typedWebSocketTransportin both helpers.supabase_fluttercannot depend onsupabase_test, and the coreimplicit_call_tearoffslint flags passing the mock object directly. KeepingMockRealtimeTransportintestSupabaseClientwould leave the two signatures different, so both now takeWebSocketTransportand callers writerealtime.callin both places. The trade-off is that.callis now also needed withtestSupabaseClient.Authorizationheader is only partly right.SupabaseClientsetsomitNewApiKeyAsBeareronly on the functions HTTP client (packages/supabase/lib/src/supabase_client.dart:129-134). PostgREST, storage and auth requests still sendAuthorization: Bearer <publishable key>when signed out. The new default still makes header assertions match production, and the regression tests pin both behaviors: REST sends the bearer, functions leave it out.supabase_testandsupabase_flutter/testing.dartare excluded from the compliance scan, sosdk-compliance.yamlis unchanged.supabase_testkeeps its default key private, because a publictestPublishableKeywould clash with the onesupabase_flutter/testing.dartexports when a test imports both.Tests
HttpMethodis usable with onlypackage:supabase_testimported.testSupabaseClientdefaults to ansb_publishable_key: REST sends it as the bearer token, a function invocation does not. A custompublishableKeyand arealtimeTransportare passed through.initializeTestSupabasesends a signed-out function call with the key only asapikey.Summary by CodeRabbit
HttpMethodthrough the testing package.Authorizationheader.