Skip to content

InfoTab: Extract useInfoTab hook and add tests#339

Open
skoeva wants to merge 1 commit intoAzure:mainfrom
skoeva:infotab
Open

InfoTab: Extract useInfoTab hook and add tests#339
skoeva wants to merge 1 commit intoAzure:mainfrom
skoeva:infotab

Conversation

@skoeva
Copy link
Collaborator

@skoeva skoeva commented Feb 27, 2026

This PR extracts data fetching, form state, validation, and save logic from InfoTab into a dedicated useInfoTab hook, adds 18 unit tests, and skips the getManagedNamespaceDetails call when the managed namespace list is empty.

Summary

  • Extracts data fetching, form state, validation, and save logic from InfoTab into a dedicated useInfoTab hook
  • Fetches getManagedNamespaceDetails only after confirming the namespace list is non-empty, avoiding a redundant az-cli call
  • Adds 18 unit tests covering loading state, guard conditions, form population, validation, hasChanges tracking, and save behavior

Fixes: #119

Testing

  • Run cd plugins/aks-desktop && npm test and ensure the tests pass

Screenshot

image

@skoeva skoeva self-assigned this Feb 27, 2026
Copilot AI review requested due to automatic review settings February 27, 2026 12:02
@skoeva skoeva added the p1 priority label Feb 27, 2026
@skoeva skoeva added the quality label Feb 27, 2026
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 useInfoTab hook that encapsulates managed-namespace fetch, form population, validation, change tracking, and save/update logic.
  • Updates InfoTab to become a thin UI wrapper that consumes the hook’s state and handlers.
  • Adds a comprehensive useInfoTab unit 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.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

This comment was marked as outdated.

Signed-off-by: Evangelos Skopelitis <eskopelitis@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

plugins/aks-desktop: Separate presentation from logic plugins/aks-desktop/src/components/InfoTab/index.tsx InfoTab

2 participants