Skip to content

EDM-3687: Allow user to go back to step to fix problems#625

Open
celdrake wants to merge 1 commit intoflightctl:mainfrom
celdrake:EDM-3687-enable-create-fleet-wizard-step
Open

EDM-3687: Allow user to go back to step to fix problems#625
celdrake wants to merge 1 commit intoflightctl:mainfrom
celdrake:EDM-3687-enable-create-fleet-wizard-step

Conversation

@celdrake
Copy link
Copy Markdown
Collaborator

@celdrake celdrake commented Apr 20, 2026

Fixes the issue in the CreateFleetWizard whereby when a validation error was present in step N, and user moved to N-1, then they couldn't move back to step N.

Summary by CodeRabbit

  • Tests

    • Added test coverage for Create Fleet wizard validation scenarios, including step navigation with validation errors and button state management.
  • Bug Fixes

    • Improved Create Fleet wizard step validation logic to correctly determine which steps remain enabled or disabled based on prior step validation status.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 20, 2026

Walkthrough

A new Cypress test validates the Create fleet wizard's back navigation and validation error handling. Supporting changes include a page object accessor for the Back button and updated wizard step-disable logic to allow the current step to remain enabled despite validation errors.

Changes

Cohort / File(s) Summary
Cypress Test Addition
libs/cypress/e2e/fleets/createFleet.cy.ts
New test case validating wizard back navigation, field retention after navigation, and that the Next button disables on validation errors.
Page Object Enhancement
libs/cypress/pages/CreateFleetWizardPage.ts
Added backFleetWizardButton getter to access the wizard's Back button via cy.contains('button', 'Back').
Wizard Step Logic Update
libs/ui-components/src/components/Fleet/CreateFleet/CreateFleetWizard.tsx
Modified isDisabledStep() to disable a step only when a prior ordered step is invalid, allowing the current step to remain enabled despite its own validation errors.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change—enabling users to return to earlier steps in the wizard to fix validation problems—which aligns with the PR objective of fixing the bug where users couldn't go back to correct errors.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
libs/cypress/e2e/fleets/createFleet.cy.ts (1)

71-73: Assert the validation state is still active after returning.

The test confirms the invalid value is preserved, but it should also confirm the invalid step still disables Next after re-entry.

Suggested test assertion
     createFleetWizardPage.backFleetWizardButton.click();
     createFleetWizardPage.nextFleetWizardButton.should('be.enabled').click();
 
     createFleetWizardPage.newFleetSystemImageField.should('be.visible').should('have.value', 'invalid!oci');
+    createFleetWizardPage.nextFleetWizardButton.should('be.disabled');
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@libs/cypress/e2e/fleets/createFleet.cy.ts` around lines 71 - 73, The test
currently checks that createFleetWizardPage.newFleetSystemImageField retains the
invalid value but doesn't assert the wizard step remains invalid; after
navigating back (where
createFleetWizardPage.nextFleetWizardButton.should('be.enabled').click() is used
to advance), add an assertion that createFleetWizardPage.nextFleetWizardButton
is disabled when re-entering the step with the invalid value (e.g., assert
.should('be.disabled') before attempting to proceed) so the invalid validation
state is enforced; reference createFleetWizardPage.nextFleetWizardButton and
createFleetWizardPage.newFleetSystemImageField to locate where to add the check.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@libs/cypress/e2e/fleets/createFleet.cy.ts`:
- Around line 71-73: The test currently checks that
createFleetWizardPage.newFleetSystemImageField retains the invalid value but
doesn't assert the wizard step remains invalid; after navigating back (where
createFleetWizardPage.nextFleetWizardButton.should('be.enabled').click() is used
to advance), add an assertion that createFleetWizardPage.nextFleetWizardButton
is disabled when re-entering the step with the invalid value (e.g., assert
.should('be.disabled') before attempting to proceed) so the invalid validation
state is enforced; reference createFleetWizardPage.nextFleetWizardButton and
createFleetWizardPage.newFleetSystemImageField to locate where to add the check.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2baa480f-44ef-41a2-9275-cf855b783eb0

📥 Commits

Reviewing files that changed from the base of the PR and between fc240a7 and 9f2b94a.

📒 Files selected for processing (3)
  • libs/cypress/e2e/fleets/createFleet.cy.ts
  • libs/cypress/pages/CreateFleetWizardPage.ts
  • libs/ui-components/src/components/Fleet/CreateFleet/CreateFleetWizard.tsx

Comment on lines +62 to +65
const stepIdx = orderedIds.findIndex((orderedStepId) => orderedStepId === stepId);
return orderedIds.some((orderedId, orderedStepIdx) => {
return orderedStepIdx < stepIdx && !validStepIds.includes(orderedId);
});
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

the condition is quite confusing TBH.
Can't we just pass a current step ID to this function and return early ?

Suggested change
const stepIdx = orderedIds.findIndex((orderedStepId) => orderedStepId === stepId);
return orderedIds.some((orderedId, orderedStepIdx) => {
return orderedStepIdx < stepIdx && !validStepIds.includes(orderedId);
});
const isDisabledStep = (currentStepId: string, stepId: string, validStepIds: string[]) => {
if (currentStepId === stepId) {
return false; //current step is never disabled
}
const validIndex = validStepIds.indexOf(stepId);
return validIndex === -1 || validIndex !== orderedIds.indexOf(stepId);
}

also we use this condition in multiple wizards - maybe its worth making it a common func.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

With this change, the initial bug would not be fixed: When on step 2 with some invalid input, users can go back to step 1. And now clicking on "Next" does nothing since the step with the error is a "future step" from the POV of the new current step.

I agree that it would be better to unify the check for the disabled steps in the different Wizards.
I can see two options:

  • Use in the CreateFleetWizard the pattern we have in the other wizards, that for step N+2, they check the steps N, N+1.
  • Make this function reusable and use it in all the wizards.

Personally I find the second one better in the long run, even though it's harder to understand. We could properly document it and it would not require new custom logic for any new Wizards.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants