Skip to content

BasicsStep: Extract hooks, add docs, tests, stories#601

Open
skoeva wants to merge 3 commits into
Azure:mainfrom
skoeva:basicsstep
Open

BasicsStep: Extract hooks, add docs, tests, stories#601
skoeva wants to merge 3 commits into
Azure:mainfrom
skoeva:basicsstep

Conversation

@skoeva
Copy link
Copy Markdown
Collaborator

@skoeva skoeva commented Apr 16, 2026

These changes extract all logic from BasicsStep into dedicated useBasicsStep and useRegisterCluster hooks, add comprehensive TSDocs, unit tests, and Storybook stories.

Fixes: #95

Summary

  • Narrows FormField.onChange type from string | number to string, removing unsafe casts across all callers
  • Fixes SearchableSelect emitting undefined on clear; handleClusterChange now properly resets cluster and resourceGroup
  • Extracts subscription/cluster mapping, auto-selection, focus management, cluster readiness checks, and helper-text derivation into useBasicsStep with a narrow UseBasicsStepInput interface
  • Extracts RegisterCluster async flow into useRegisterCluster, making the component purely presentational
  • Exports pure helpers (getClusterHelperText, isClusterNonReady, getClusterStateMessage) for isolated testing
  • Adds TSDocs to all public interfaces and hooks
  • Adds 37 unit tests across both hooks and 17 Storybook stories covering all visual states

Testing

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

@skoeva skoeva self-assigned this Apr 16, 2026
@skoeva skoeva added the quality label Apr 16, 2026
@skoeva skoeva marked this pull request as ready for review April 16, 2026 18:00
Copilot AI review requested due to automatic review settings April 16, 2026 18:00
@skoeva skoeva changed the title BasicsStep: WIP BasicsStep: Extract hooks, add docs, tests, stories Apr 16, 2026
Copy link
Copy Markdown
Contributor

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

Note

Copilot was unable to run its full agentic suite in this review.

This PR refactors the BasicsStep wizard step by extracting its stateful logic into dedicated hooks (useBasicsStep, useRegisterCluster), and adds unit tests plus Storybook coverage for the resulting behavior.

Changes:

  • Introduces useBasicsStep to encapsulate focus, auto-selection, option mapping, cluster readiness/missing checks, and helper text derivation (with exported pure helpers for isolated testing).
  • Introduces useRegisterCluster to encapsulate the async “register AKS cluster” flow and related loading/error/success state.
  • Adds Vitest unit tests for both hooks and Storybook stories for BasicsStep.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
plugins/aks-desktop/src/components/CreateAKSProject/hooks/useRegisterCluster.ts New hook encapsulating async AKS cluster registration flow and status state.
plugins/aks-desktop/src/components/CreateAKSProject/hooks/useRegisterCluster.test.ts Unit tests validating register flow behavior and messaging.
plugins/aks-desktop/src/components/CreateAKSProject/hooks/useBasicsStep.ts New hook + pure helpers for Basics-step derived state and callbacks.
plugins/aks-desktop/src/components/CreateAKSProject/hooks/useBasicsStep.test.ts Unit tests for pure helpers and hook-derived behaviors.
plugins/aks-desktop/src/components/CreateAKSProject/components/BasicsStep.tsx Converts BasicsStep and RegisterCluster to presentational components using new hooks.
plugins/aks-desktop/src/components/CreateAKSProject/components/BasicsStep.stories.tsx Adds Storybook stories covering key visual states.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread plugins/aks-desktop/src/components/CreateAKSProject/hooks/useBasicsStep.ts Outdated
Copy link
Copy Markdown
Contributor

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 6 out of 6 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread plugins/aks-desktop/src/components/CreateAKSProject/hooks/useBasicsStep.ts Outdated
Copy link
Copy Markdown
Collaborator

@illume illume left a comment

Choose a reason for hiding this comment

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

Thanks for this.

Can you please address the open review comments when you have time?

Copy link
Copy Markdown
Contributor

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 6 out of 6 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread plugins/aks-desktop/src/components/CreateAKSProject/hooks/useRegisterCluster.ts Outdated
Comment thread plugins/aks-desktop/src/components/CreateAKSProject/hooks/useBasicsStep.ts Outdated
Copy link
Copy Markdown
Collaborator

@illume illume left a comment

Choose a reason for hiding this comment

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

Nice improvements.

There's some open review comments to take a look at.

Copy link
Copy Markdown
Contributor

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 25 out of 25 changed files in this pull request and generated 6 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread plugins/aks-desktop/src/components/CreateAKSProject/hooks/useBasicsStep.ts Outdated
Comment thread plugins/aks-desktop/locales/zh-Hans/translation.json
Comment thread plugins/aks-desktop/src/components/CreateAKSProject/hooks/useBasicsStep.test.ts Outdated
Signed-off-by: Evangelos Skopelitis <eskopelitis@microsoft.com>
Copilot AI review requested due to automatic review settings May 1, 2026 15:13
Signed-off-by: Evangelos Skopelitis <eskopelitis@microsoft.com>
Copy link
Copy Markdown
Contributor

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 29 out of 29 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread plugins/aks-desktop/src/components/shared/FormField.tsx
Signed-off-by: Evangelos Skopelitis <eskopelitis@microsoft.com>
Copy link
Copy Markdown
Contributor

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 30 out of 30 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@skoeva skoeva requested a review from illume May 5, 2026 02:03
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/CreateAKSProject/components/BasicsStep.tsx BasicsStep

3 participants