InfoTab: Extract useInfoTab hook and add tests#339
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors InfoTab in the AKS Desktop plugin by extracting its data-fetching, form state/validation, and save behavior into a dedicated useInfoTab hook, and adds unit tests around the new hook and its guard conditions (including skipping the details call when there are no managed namespaces).
Changes:
- Introduces a new
useInfoTabhook that encapsulates managed-namespace fetch, form population, validation, change tracking, and save/update logic. - Updates
InfoTabto become a thin UI wrapper that consumes the hook’s state and handlers. - Adds a comprehensive
useInfoTabunit test suite covering fetch guards, loading/error states, validation,hasChanges, and save behavior.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| plugins/aks-desktop/src/components/InfoTab/hooks/useInfoTab.ts | New hook containing InfoTab’s fetch/state/validation/save logic and the “skip details call if list is empty” optimization. |
| plugins/aks-desktop/src/components/InfoTab/hooks/useInfoTab.test.ts | New unit tests for the hook’s loading/guards/form population/validation/hasChanges/save behavior. |
| plugins/aks-desktop/src/components/InfoTab/InfoTab.tsx | Simplifies InfoTab by delegating logic to useInfoTab and rendering from hook state. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 22 out of 22 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Evangelos Skopelitis <eskopelitis@microsoft.com>
This PR extracts data fetching, form state, validation, and save logic from
InfoTabinto a dedicateduseInfoTabhook, adds 18 unit tests, and skips thegetManagedNamespaceDetailscall when the managed namespace list is empty.Summary
InfoTabinto a dedicateduseInfoTabhookgetManagedNamespaceDetailsonly after confirming the namespace list is non-empty, avoiding a redundant az-cli callhasChangestracking, and save behaviorFixes: #119
Testing
cd plugins/aks-desktop && npm testand ensure the tests passScreenshot