fix(app): a re-read of the same account keeps its workspace on screen

USER_UPDATED (or a retry) set the workspace back to loading, which unmounted
the client routes and lost an open form's typed values. A ready workspace now
stays until the answer; found by the V1-1.5 security audit.
This commit is contained in:
bchanot committed 2026-10-26 02:08:25 +01:00
1 parent ae0bd3f8d8
commit e1c1980949
2 files changed
+22 -3

No files matched your search

@@ -298,6 +298,22 @@ describe('authStore', () => {
})
})
it('keeps a ready workspace on screen while the same account is read again', async () => {
fake.tables.workspaces = [{ id: 'ws-1', personal_user_id: 'user-1' }]
stop = useAuthStore.getState().start()
fake.emit('SIGNED_IN', fakeSession())
await flush()
await flush()
const seen: string[] = []
const unsubscribe = useAuthStore.subscribe((s) => seen.push(s.workspace.status))
fake.emit('USER_UPDATED', fakeSession())
await flush()
await flush()
unsubscribe()
expect(seen).not.toContain('loading')
expect(useAuthStore.getState().workspace).toEqual({ status: 'ready', id: 'ws-1' })
})
it('forgets the workspace on sign-out', async () => {
fake.tables.workspaces = [{ id: 'ws-1', personal_user_id: 'user-1' }]
stop = useAuthStore.getState().start()