Skip to content

test(examples): add end-to-end test for the realtime room example#1621

Merged
spydon merged 4 commits into
mainfrom
examples/realtime-room-e2e-test
Jul 22, 2026
Merged

test(examples): add end-to-end test for the realtime room example#1621
spydon merged 4 commits into
mainfrom
examples/realtime-room-e2e-test

Conversation

@spydon

@spydon spydon commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

What

Stacked on top of #1619 (the realtime_room example itself). Adds a full end-to-end integration test that drives the actual app widgets against the local Supabase stack, covering all three realtime features through the UI.

Base this on #1619 (examples/realtime-room), not main. Merge #1619 first, or rebase this once it lands.

The test

integration_test/room_test.dart uses testWidgets to:

  1. Pump RealtimeRoomApp, enter a name on the join screen and open the room.
  2. Presence — assert the user's own name appears in the roster chip.
  3. Postgres Changes — type a message in the composer, send it, and assert it appears in the list (it round-trips through the database and comes back on the realtime stream).
  4. Spin up a second SupabaseClient as another user ("bob") and:
    • Presence — assert bob appears in the roster.
    • Broadcast — bob sends a typing ping; assert the "bob is typing" indicator shows.
    • Postgres Changes — bob posts a message; assert it appears in the first client's list.
  5. Postgres Changes (delete) — delete the user's own message through the UI and assert it leaves the list.

Because realtime updates arrive asynchronously over the network, the UI can't be settled with pumpAndSettle; a small _pumpUntil helper polls the widget tree with a timeout instead. tearDown removes the posted rows so the test can run repeatedly.

Also re-adds the integration_test dev dependency and the "Integration test" section to the example README (both were intentionally left out of #1619 so that PR is example-only).

Testing

  • flutter analyze: no issues; dart format: clean.
  • Ran the test end to end against a local stack (all five assertions above pass, repeatably). Integration tests need a device, so run it with -d macos, an emulator or a real device.

Summary by CodeRabbit

  • Tests

    • Added an end-to-end integration test for the realtime room example.
    • The test verifies messaging, presence updates, typing indicators, and message deletion through the user interface.
  • Documentation

    • Added instructions for running the integration test against a local stack.

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

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a Flutter integration test for the realtime room example, covering Presence, Postgres Changes, Broadcast, message deletion, and asynchronous UI updates. It also adds the testing dependency and documents local-stack execution.

Changes

Realtime room integration testing

Layer / File(s) Summary
Integration test foundation
examples/realtime_room/pubspec.yaml, examples/realtime_room/integration_test/room_test.dart
Adds the Flutter integration-test dependency, Supabase environment configuration, suite initialization and disposal, and cleanup of existing test messages.
Realtime flow validation
examples/realtime_room/integration_test/room_test.dart, examples/realtime_room/README.md
Tests joining, Presence roster updates, Postgres Changes message delivery and deletion, Broadcast typing indicators, asynchronous polling, and documents the local-stack test command.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: adding an end-to-end test for the realtime_room example.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch examples/realtime-room-e2e-test

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Checkov (3.3.8)
examples/realtime_room/pubspec.yaml

Traceback (most recent call last):
File "/usr/local/bin/checkov", line 2, in
from checkov.main import Checkov
ModuleNotFoundError: No module named 'checkov'


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 force-pushed the examples/realtime-room-e2e-test branch from 964d20b to 563f672 Compare July 20, 2026 09:22
@spydon
spydon force-pushed the examples/realtime-room branch from a4cb13f to 922a8bc Compare July 22, 2026 12:12
Base automatically changed from examples/realtime-room to main July 22, 2026 14:09
…m-e2e-test

# Conflicts:
#	examples/README.md
#	examples/realtime_room/README.md
#	examples/realtime_room/pubspec.yaml
#	pubspec.yaml
@spydon
spydon enabled auto-merge (squash) July 22, 2026 15:21
@spydon
spydon merged commit f65c7ae into main Jul 22, 2026
23 of 24 checks passed
@spydon
spydon deleted the examples/realtime-room-e2e-test branch July 22, 2026 15:22

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
examples/realtime_room/integration_test/room_test.dart (1)

1-132: 📐 Maintainability & Code Quality | 🔵 Trivial

Run melos analyze and melos format
Repo guidance for Dart changes requires the Melos wrappers, not just flutter analyze / dart format.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@examples/realtime_room/integration_test/room_test.dart` around lines 1 - 132,
Run the repository-standard `melos analyze` and `melos format` commands for the
Dart changes, and resolve any reported analysis or formatting issues in the
integration test before finalizing.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@examples/realtime_room/integration_test/room_test.dart`:
- Around line 31-39: Update the realtime room test setup and teardown to
generate per-run unique usernames and message content, then reuse those values
in the posted messages, find.text assertions, and cleanup query. Ensure tearDown
only deletes rows belonging to the current test run rather than all messages
authored by shared usernames.

In `@examples/realtime_room/README.md`:
- Around line 60-66: Update the integration-test instructions around the Flutter
command to clarify that localhost:54321 is only valid for macOS/desktop targets.
Document the appropriate host address or platform alias for Android emulators
and physical devices, and ensure each target uses a reachable SUPABASE_URL.

---

Nitpick comments:
In `@examples/realtime_room/integration_test/room_test.dart`:
- Around line 1-132: Run the repository-standard `melos analyze` and `melos
format` commands for the Dart changes, and resolve any reported analysis or
formatting issues in the integration test before finalizing.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: c3c10e8b-95a3-439b-aeb6-13d51ecb7e10

📥 Commits

Reviewing files that changed from the base of the PR and between 47ceaaf and cfb0cbc.

📒 Files selected for processing (3)
  • examples/realtime_room/README.md
  • examples/realtime_room/integration_test/room_test.dart
  • examples/realtime_room/pubspec.yaml

Comment on lines +31 to +39
tearDown(() async {
// Remove whatever the test posted so it can run repeatedly.
await Supabase.instance.client.from('messages').delete().inFilter(
'username',
[
'alice',
'bob',
],
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Isolate test rows from shared-stack data.

This deletes every message authored by alice or bob, including pre-existing data or another concurrent run’s rows. Use per-run unique usernames/message content and clean up only those generated values; this also prevents stale rows from making the find.text assertions ambiguous.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@examples/realtime_room/integration_test/room_test.dart` around lines 31 - 39,
Update the realtime room test setup and teardown to generate per-run unique
usernames and message content, then reuse those values in the posted messages,
find.text assertions, and cleanup query. Ensure tearDown only deletes rows
belonging to the current test run rather than all messages authored by shared
usernames.

Comment thread examples/realtime_room/README.md
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