Files
buzz/mobile/test/features/profile
Logan Johnson 2cca0ec157 test(mobile): cover presence ordering against delayed live events (#7526)
🤖
## Summary

This PR adds tests only. It locks in how the mobile app shows a member
as Online or Offline when a live presence update arrives late.

The app learns presence two ways: a periodic snapshot from the relay
(the server), and live updates sent by each member's device. These use
different clocks. A live update can reach the phone after a newer
snapshot already counted it. Without a guard, that late update could
flip a member to the wrong state until the next 60-second refresh.

The guard itself already shipped in #7382 (see
`presence_cache_provider.dart` on `main`). This PR adds the tests that
prove it keeps working:

- A late `offline` update, signed before the snapshot, does not show the
member as Offline. The app asks the relay for one fresh snapshot
instead.
- A real change from a device whose clock runs behind the relay is not
dropped. The fresh snapshot confirms it, and the member shows as
Offline.
- An update signed in the same second as the snapshot is not trusted
directly in either direction (Online→Offline or Offline→Online). The app
confirms it with a fresh snapshot.
- If the same late update is delivered twice, the app asks for only one
confirmation.

No production code changes. No UI changes.

### Related issue

Follow-up to #7382 (snapshot/live ordering, review item 2). It is the
last PR in the #7382 → #7383 → #7526 stack; both parents have merged.
None found beyond this stack.

### Testing

The new file `mobile/test/features/profile/presence_ordering_test.dart`
drives the real presence cache through a fake relay session and fake
time. On this head, rebased on current `main`: `dart format` clean,
`flutter analyze` clean, and the profile test suite passes (139 tests).

Signed-off-by: Logan Johnson <loganj@squareup.com>
2026-10-01 13:48:23 -04:00
..