Skip to content

test(examples): add end-to-end test for the passkeys example - #1623

Merged
spydon merged 1 commit into
mainfrom
examples/passkeys-e2e-test
Jul 20, 2026
Merged

spydon merged 1 commit into
mainfrom
examples/passkeys-e2e-test

Conversation

@spydon

@spydon spydon commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

What

Adds an end-to-end integration test for the passkeys example, matching the ones added for realtime_room and database_crud. It drives the actual app widgets against the local Supabase stack.

The test

integration_test/passkeys_test.dart uses testWidgets to:

  1. Pump PasskeyExampleApp, create an account and land on the passkey management screen (a fresh account shows "No passkeys yet." and the "Register a passkey" button).
  2. Sign out and assert the sign-in screen returns.
  3. Attempt a wrong password and assert an error surfaces instead of signing in.
  4. Sign in with the correct password and assert the signed-in screen returns.

Scope

The WebAuthn ceremony itself (registerPasskey / signInWithPasskey) drives a platform authenticator prompt (Face ID, Windows Hello, a security key, ...) that cannot be automated headlessly, so it is exercised manually per the README rather than in this test. The test covers everything around the ceremony: account creation, the passkey-list screen, session management and password sign-in error handling.

A small _pumpUntil helper polls the widget tree (auth calls are async over the network, so the UI can't be pumpAndSettled). Each run uses a unique email so sign up never collides with an existing user.

Also adds the integration_test dev dependency and an "Integration test" section to the example README.

Testing

  • flutter analyze: no issues; dart format: clean.
  • Ran end to end against a local stack, twice, both green. Integration tests need a device, so run it with -d macos, an emulator or a real device.

@spydon
spydon requested a review from a team as a code owner July 20, 2026 11:33
@coderabbitai

coderabbitai Bot commented Jul 20, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f9c35537-db7d-4288-82b2-9420711b02b0

📥 Commits

Reviewing files that changed from the base of the PR and between 7b7953e and 2abe100.

⛔ Files ignored due to path filters (1)
  • pubspec.lock is excluded by !**/*.lock
📒 Files selected for processing (3)
  • examples/passkeys/README.md
  • examples/passkeys/integration_test/passkeys_test.dart
  • examples/passkeys/pubspec.yaml

📝 Walkthrough

Summary by CodeRabbit

  • Documentation

    • Added instructions for running the passkeys integration test against a local Supabase stack.
    • Clarified which WebAuthn steps require manual interaction with a platform authenticator.
  • Tests

    • Added end-to-end coverage for account creation, passkey management navigation, sign-out, failed authentication, and successful sign-in.
    • Added support for running the integration test on a device or emulator.

Walkthrough

Adds a Flutter integration test for the passkeys example. The test initializes Supabase from Dart environment variables, creates a unique account, verifies the passkey management screen, signs out, checks incorrect-password handling, and signs back in successfully. A polling helper waits for network-driven UI states. The README documents manual WebAuthn prompt handling and provides a local-stack test command. The integration_test Flutter dependency is also added.

Sequence Diagram(s)

sequenceDiagram
  participant IntegrationTest
  participant PasskeysExampleApp
  participant LocalSupabase
  IntegrationTest->>PasskeysExampleApp: Create account
  PasskeysExampleApp->>LocalSupabase: Authenticate account
  LocalSupabase-->>PasskeysExampleApp: Return authentication result
  IntegrationTest->>PasskeysExampleApp: Verify passkey screen
  IntegrationTest->>PasskeysExampleApp: Sign out
  PasskeysExampleApp->>LocalSupabase: End session
  IntegrationTest->>PasskeysExampleApp: Try incorrect password
  PasskeysExampleApp->>LocalSupabase: Attempt authentication
  LocalSupabase-->>PasskeysExampleApp: Return authentication error
  IntegrationTest->>PasskeysExampleApp: Sign in with correct password
  PasskeysExampleApp->>LocalSupabase: Authenticate account
  LocalSupabase-->>PasskeysExampleApp: Return authentication result
Loading

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@spydon
spydon merged commit 5db6922 into main Jul 20, 2026
38 checks passed
@spydon
spydon deleted the examples/passkeys-e2e-test branch July 20, 2026 12:10
Vinzent03 pushed a commit that referenced this pull request Jul 28, 2026
## What

Adds an end-to-end integration test for the `passkeys` example, matching
the ones added for `realtime_room` and `database_crud`. It drives the
actual app widgets against the local Supabase stack.

## The test

`integration_test/passkeys_test.dart` uses `testWidgets` to:

1. Pump `PasskeyExampleApp`, create an account and land on the passkey
management screen (a fresh account shows "No passkeys yet." and the
"Register a passkey" button).
2. Sign out and assert the sign-in screen returns.
3. Attempt a wrong password and assert an error surfaces instead of
signing in.
4. Sign in with the correct password and assert the signed-in screen
returns.

### Scope

The WebAuthn ceremony itself (`registerPasskey` / `signInWithPasskey`)
drives a platform authenticator prompt (Face ID, Windows Hello, a
security key, ...) that cannot be automated headlessly, so it is
exercised manually per the README rather than in this test. The test
covers everything around the ceremony: account creation, the
passkey-list screen, session management and password sign-in error
handling.

A small `_pumpUntil` helper polls the widget tree (auth calls are async
over the network, so the UI can't be `pumpAndSettle`d). Each run uses a
unique email so sign up never collides with an existing user.

Also adds the `integration_test` dev dependency and an "Integration
test" section to the example README.

## Testing

- `flutter analyze`: no issues; `dart format`: clean.
- Ran end to end against a local stack, twice, both green. Integration
tests need a device, so run it with `-d macos`, an emulator or a real
device.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants