Skip to content

fix(client): clear stale collaborator dropdown error on retry - #91

Open
Alimedhat000 wants to merge 2 commits into
developfrom
fix/89-collaborator-error-clearing
Open

fix(client): clear stale collaborator dropdown error on retry#91
Alimedhat000 wants to merge 2 commits into
developfrom
fix/89-collaborator-error-clearing

Conversation

@Alimedhat000

Copy link
Copy Markdown
Owner

Summary

useCollaborators only reset its error inside the initial fetch effect, so once a add/remove failed, the alert ("Failed to add collaborator" / "Failed to remove collaborator") persisted indefinitely — even after a successful retry or closing/reopening the dropdown (the hook stays mounted with the document).

Fix: reset error at the start of each addCollaborator / removeCollaborator attempt, mirroring what the fetch effect already does. Failures still set a fresh message; successes now clear it.

Test plan

  • New hook-level tests in client/src/hooks/__tests__/use-collaborators.test.tsx run in a new browser-unit vitest browser project (stories can't exercise API-dependent logic). Watched the two recovery tests fail on the unfixed code (stale error asserted), pass after the fix.
  • Full client suite: 40 files / 139 tests passing
  • pnpm --filter client lint and typecheck clean

useCollaborators only reset its error inside the initial fetch effect, so
a failed add or remove left 'Failed to add/remove collaborator' showing
indefinitely — even after a successful retry or closing/reopening the
dropdown. Reset the error at the start of each action, mirroring the
fetch effect.

Adds a browser-mode vitest project for hook-level tests (stories can't
exercise API-dependent logic) with coverage for error clearing on
successful retries.
Replace bare await act(async () => {}) flushes with a polling waitFor
that waits for loading to settle. Empty act flushes can miss the
initial fetch's microtask in CI timing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Collaborator dropdown error message is never cleared after being shown

1 participant