test(examples): add full e2e suite for Edge Functions#1633
Merged
Conversation
Contributor
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughAdds a local ChangesEdge Functions invocation coverage
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant TestSuite
participant FunctionsClient
participant LocalSupabase
participant EchoFunction
TestSuite->>FunctionsClient: invoke echo with request options
FunctionsClient->>LocalSupabase: send encoded request
LocalSupabase->>EchoFunction: forward method, headers, query, and body
EchoFunction-->>LocalSupabase: return encoded response or error
LocalSupabase-->>FunctionsClient: return decoded response or exception
FunctionsClient-->>TestSuite: expose result, status, stream, or abort error
Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
spydon
force-pushed
the
examples/edge-functions-e2e
branch
3 times, most recently
from
July 22, 2026 09:36
b3d9dfe to
aecde9a
Compare
spydon
added a commit
that referenced
this pull request
Jul 22, 2026
## What
Adds an `edge_functions` example under `examples/`, following the same
structure as `database_crud` and `storage_transforms`. It demonstrates
invoking Supabase Edge Functions with `supabase.functions.invoke(...)`:
- **JSON body over POST**, reading the JSON response back
(`invoke('greet', body: {...})`).
- **GET with query parameters** instead of a body (`method:
HttpMethod.get, queryParameters: {...}`).
- **Custom headers** sent to the function and echoed back (`headers:
{...}`).
- **Plain text in and out**: a `String` body is sent as `text/plain` and
the `text/plain` response arrives as a `String` (`invoke('shout', body:
text)`).
- **Error handling**: a non-2xx response throws a `FunctionException`
whose `details` carry the response body (`invoke('word-count', ...)`).
## How it's structured
- All Edge Function access lives in `lib/functions_repository.dart`
(`FunctionsRepository`), kept separate from the UI so the calls are easy
to read and to drive from tests. Models with `factory fromJson` live in
`lib/models.dart`. The Material 3 UI in `lib/main.dart` stays thin.
- Three demo functions ship under `examples/supabase/functions/`:
`greet`, `shout` and `word-count`.
- The Edge Runtime is enabled in `examples/supabase/config.toml`;
`supabase start` serves the functions automatically. The demo functions
set `verify_jwt = false` so the example can call them with just the
publishable key, matching the other examples which run unauthenticated.
- The new package is registered in the workspace `pubspec.yaml` and
listed in `examples/README.md`.
## Testing
- `dart format .` and `flutter analyze` are clean.
- `integration_test/functions_test.dart` was run against the local stack
(`supabase start`) on web (Chrome 150) via `flutter drive`: **all tests
passed**. It covers the repository flow (JSON greeting over POST and
GET, plain-text transform, and a 400 validation error surfacing as a
`FunctionException`) plus a UI smoke test.
A stacked PR (#1633) adds a full end-to-end suite covering the entire
`functions.invoke` surface.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
- **New Features**
- Added a Flutter example demonstrating Supabase Edge Functions.
- Added greeting, plain-text transformation, and word-count function
examples.
- Added support for POST requests, query parameters, custom headers, and
error handling.
- Enabled the example to run in the browser and against the local stack.
- **Documentation**
- Added setup, usage, project structure, and integration testing
instructions.
- **Tests**
- Added end-to-end coverage for function responses, validation errors,
and UI interactions.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Add integration_test/invoke_test.dart covering the whole surface of functions.invoke: every HTTP method, query parameters, custom headers, JSON/text/binary/multipart request bodies and a region; every response type (JSON, text, binary and an SSE ByteStream); custom status codes; the three FunctionException variants; and request aborting. The suite drives a new echo test-support function that reflects the request back in whatever shape a query parameter asks for. It is not used by the example UI and has verify_jwt disabled like the other demo functions.
spydon
force-pushed
the
examples/edge-functions-e2e
branch
from
July 22, 2026 11:11
aecde9a to
3d9c10a
Compare
spydon
enabled auto-merge (squash)
July 22, 2026 11:12
mandarini
approved these changes
Jul 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a full end-to-end integration test suite for the
edge_functionsexample, covering the entire surface offunctions.invoke.integration_test/invoke_test.dartexercises:Request
HttpMethod(GET, POST, PUT, DELETE, PATCH)Stringbody sent astext/plainUint8Listbody sent as binaryMultipartFileuploads (files:) with form fieldsregion(adds theforceFunctionRegionquery andx-regionheader)Response
Maptext/plainas aStringapplication/octet-streamas aUint8Listtext/event-streamas a readableByteStream(SSE)FunctionResponse.statusErrors
FunctionsHttpExceptionon a non-2xx JSON response (Map indetails)FunctionsHttpExceptionon a non-2xx text response (String indetails)FunctionsFetchExceptionwhen the function is unreachableAbort
abortSignalcancels the request (RequestAbortedException)abortSignalused as a request timeoutHow
The suite drives a new
echotest-support function (examples/supabase/functions/echo) that reflects the request back in whatever shape a query parameter asks for (JSON reflection, text, binary, SSE, or a chosen status code). It is not used by the example UI and hasverify_jwt = falselike the other demo functions.Testing
dart format .andflutter analyzeare clean.supabase start) on web (Chrome 150) viaflutter drive: all tests passed, including the binary, multipart, SSEByteStreamand abort cases.Summary by CodeRabbit
Tests
New Features