Server State, Caching, and UI Tests
Separate local UI state from remote data that changes outside the current browser.
How to apply it
Include organization ID, filters, and sort in query keys. Clear sensitive cached data on logout and tenant switch. Test critical journeys and permission-denied paths, not only happy paths.
Worked example
A query key can be projects plus organization ID, status, and cursor; invalidate the relevant tenant query after a mutation.
Common mistakes to avoid
Omitting tenant context from cache keys or relying only on client-side route guards.
Practice task
Implement this concept in the capstone. Add one positive test, one negative or failure-path test, and a short note explaining the trade-off you chose.
Key Takeaways
- Separate local UI state from remote data that changes outside the current browser.
- Include organization ID, filters, and sort in query keys.
Knowledge Check
What is the strongest production practice for Server State, Caching, and UI Tests?