Closed fnimick closed 2 years ago
@benjie the cy.wait
commands are actually necessary in this case - the websocket connection is explicitly reset after a session change in login and register, and without the wait commands, the database change potentially happens before the websocket reconnects and therefore the test fails as the UI never updates. It's a race condition which is extremely unlikely to happen in the real world since it involves a session being created and the user record being modified within a few milliseconds of each other.
I initially tried to increase the timeout on the cypress assertions, before I realized what was happening here - the issue is a race condition on the UI side which basically can only occur in a test scenario. The key here is to wait before making the database change after session creation, to allow the websocket to reconnect - otherwise, the database change may or may not be propagated to the UI since there is a race condition between the database change and the socket reconnection.
Okay that makes sense; it's suboptimal but I doubt it's worth the effort to fix (which could involve having the client write something to window on reconnect and having cypress poll for it or similar strategy) :+1:
Description
Adds a test to confirm that the current user subscription used for displaying validation status correctly updates the UI when database modifications are made.
Performance impact
None.
Security impact
None.
Checklist
N/A - this is a test-only change.
yarn lint:fix
passes.yarn test
passes.RELEASE_NOTES.md
file (if one exists).