The UI Said 'Saved.' Did the Audit Log Agree?
Description and use
A Cypress recipe that verifies UI feedback, API persistence, and audit events for a role change, using bounded polling and correlation IDs to avoid race conditions.
Problem
A UI success toast does not guarantee that the backend persisted data, emitted audit events, or queued notifications.
Outcome
The recipe demonstrates how to assert UI feedback, API persistence, and audit events, avoiding race conditions with bounded polling and correlation IDs.
Workflow
- Create a test user via HTTP POST
- Visit the admin user page
- Select a new role and click "Save changes"
- Assert the UI toast contains "Saved"
- Request the user API and assert the role is "editor"
- Poll the audit‑events endpoint for a "role.changed" event using bounded retries
- Assert the event contains the correct from/to values
Evidence
The green <strong>Saved</strong> toast answers one narrow question: did the React application render a success message?
For consequential workflows, test three postconditions: Browser – The user saw the expected state; API – The durable record contains the change; Side‑effect sink – The expected asynchronous event appeared
Use bounded polling: function waitForEvent(subjectId, action, attemptsLeft = 8, ... )
- Record date: 2026-10-10T16:40:58.429Z