BasicsStep: Extract hooks, add docs, tests, stories#601
Conversation
There was a problem hiding this comment.
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
useBasicsStepto encapsulate focus, auto-selection, option mapping, cluster readiness/missing checks, and helper text derivation (with exported pure helpers for isolated testing). - Introduces
useRegisterClusterto 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.
There was a problem hiding this comment.
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.
illume
left a comment
There was a problem hiding this comment.
Thanks for this.
Can you please address the open review comments when you have time?
There was a problem hiding this comment.
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.
illume
left a comment
There was a problem hiding this comment.
Nice improvements.
There's some open review comments to take a look at.
There was a problem hiding this comment.
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.
Signed-off-by: Evangelos Skopelitis <eskopelitis@microsoft.com>
Signed-off-by: Evangelos Skopelitis <eskopelitis@microsoft.com>
There was a problem hiding this comment.
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.
Signed-off-by: Evangelos Skopelitis <eskopelitis@microsoft.com>
There was a problem hiding this comment.
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.
These changes extract all logic from
BasicsStepinto dedicateduseBasicsStepanduseRegisterClusterhooks, add comprehensive TSDocs, unit tests, and Storybook stories.Fixes: #95
Summary
FormField.onChangetype fromstring | numbertostring, removing unsafe casts across all callersSearchableSelectemittingundefinedon clear;handleClusterChangenow properly resets cluster and resourceGroupuseBasicsStepwith a narrowUseBasicsStepInputinterfaceRegisterClusterasync flow intouseRegisterCluster, making the component purely presentationalgetClusterHelperText,isClusterNonReady,getClusterStateMessage) for isolated testingTesting
cd plugins/aks-desktop && npm testand ensure the tests pass