Wait for the sync to register before leaving

Merged
YO
12d ago
+12-2

Summary

TestSessionRehearsesEveryWrite failed now and then on ubuntu-latest with /sync is reported; got [...].

The cause is in the test, not the write gate:

  • The ledger's Sync later button registers a background sync asynchronously: serviceWorker.register, then ready, then sync.register.
  • That finishes after the click command reports back.
  • The test then navigated straight to the page again. On a slow host the page was gone before sync.register ran, so the sync event never fired and the page never sent /sync.

The fixture now marks body[data-sync=registered] once the sync is registered. The test waits for that selector before leaving the page, and keeps any writes reported during the wait.

Test plan

  • Reproduced: with a 3s delay injected before sync.register, the original test fails with the CI error (/sync is reported; got [...]), and the fixed test passes. The delay is not committed.
  • DAGU_BIN=<built> go test -count=2 -run 'TestSessionRehearsesEveryWrite$' ./conformance/spec079_browser_session/ passes.
  • gofmt and golangci-lint pass for linux, windows and darwin.

Summary by cubic

Fixes a flaky TestSessionRehearsesEveryWrite failure on slow CI hosts where the test navigated away before the background sync was registered, so /sync was never sent. The page now sets body[data-sync=registered] once its background sync is fully registered, and the test waits for that marker before leaving the page. Because the worker sends /sync some time after registration completes, the test also keeps writes reported during the wait and by the reload and typing commands that follow, so no reported write is missed.

Summary by CodeRabbit

  • Tests
    • Browser session conformance checks now wait until background synchronization is registered before verifying reported writes. This makes the check more reliable when confirming that browser sessions rehearse all writes.