Skip to content

IS-11570 Fix "triggered by" in stepper history when handling redirect steps - #284

Open
luisgoncalves wants to merge 2 commits into
feature/dev/IS-11570-haapi-stepper-history-navigation-refactorfrom
fix/dev/IS-11570-haapi-stepper-history-redirect-steps
Open

IS-11570 Fix "triggered by" in stepper history when handling redirect steps#284
luisgoncalves wants to merge 2 commits into
feature/dev/IS-11570-haapi-stepper-history-navigation-refactorfrom
fix/dev/IS-11570-haapi-stepper-history-redirect-steps

Conversation

@luisgoncalves

@luisgoncalves luisgoncalves commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

In a redirect scenario we have:

  • Action A
  • Server returns redirect step RS with action R
  • Stepper follows R
  • Server returns some other step X

Previously, the history entry would have A as "triggered by", and X as the result step, which is not correct. In this PR, the "triggered by" action becomes R.

This helps back/forward navigation in POST-redirect-GET cases, since the GET action is a safe/reproducible one.

Also adds a isLink type predicate.

Also renames formatNextStepData to formatStepData to avoid confusion with newly added types (separate commit).

@luisgoncalves luisgoncalves changed the title IS-11570 Fix "triggered by" in stepper history when handling redirect… IS-11570 Fix "triggered by" in stepper history when handling redirect steps Aug 6, 2026
@luisgoncalves
luisgoncalves requested a lite review from Copilot August 6, 2026 15:19
// Triggered by the action in the redirection step
assert(history[1].triggeredByAction.type === HAAPI_STEPPER_ELEMENT_TYPES.ACTION);
assert(history[1].triggeredByAction.subtype === HAAPI_ACTION_TYPES.FORM);
expect(history[1].triggeredByAction.model.href).toBe('/auth/redirected');

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This used to fail.

};
}

function nextStepError(step: HaapiStepperError): { nextStepError: HaapiStepperError } {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Only used once for now, but added for symmetry.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Updates the HAAPI stepper to record history entries with the actual action that triggered the resulting step when redirects are involved (e.g., POST-redirect-GET), improving back/forward navigation by making the reproducible “triggered by” action the redirect-follow action rather than the original pre-redirect action.

Changes:

  • Adjust step processing to recurse through redirection-step using the redirect action as the effective triggering action for subsequent history entries.
  • Introduce an isLink type predicate and use it to simplify link-vs-form branching in step processing and reproducible-action logic.
  • Refactor several step handlers to return HaapiStepperStep directly (instead of wrapper objects), and update tests accordingly.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/haapi-react-sdk/haapi-stepper/util/link-predicates.ts Adds isLink type predicate for next-step actions.
src/haapi-react-sdk/haapi-stepper/util/link-predicates.spec.ts Adds unit tests for the new isLink predicate.
src/haapi-react-sdk/haapi-stepper/feature/stepper/step-handlers/polling-step.ts Refactors handler to return step data directly.
src/haapi-react-sdk/haapi-stepper/feature/stepper/step-handlers/completed-step.ts Refactors handler to return step data (or undefined) directly.
src/haapi-react-sdk/haapi-stepper/feature/stepper/step-handlers/authentication-or-registration-step.ts Refactors handler to return step data directly.
src/haapi-react-sdk/haapi-stepper/feature/stepper/HaapiStepper.tsx Updates redirect handling and history recording to use the redirect-follow action as the “triggered by” source.
src/haapi-react-sdk/haapi-stepper/feature/stepper/HaapiStepper.spec.tsx Extends redirect history tests to validate “triggered by” action correctness.
src/haapi-react-sdk/haapi-stepper/feature/stepper/haapi-stepper.types.ts Introduces HaapiStepperNextStepData and reshapes history typings around it.
src/haapi-react-sdk/haapi-stepper/feature/stepper/data-formatters/format-next-step-data.ts Adds an overload to support HaapiFormActionHaapiStepperFormAction conversion.
src/haapi-react-app/src/shared/feature/history/reproducible-action.ts Uses isLink predicate to determine reproducibility for link actions.

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

Comment thread src/haapi-react-sdk/haapi-stepper/feature/stepper/HaapiStepper.tsx Outdated
@luisgoncalves
luisgoncalves force-pushed the fix/dev/IS-11570-haapi-stepper-history-redirect-steps branch from 9074bd0 to d89d601 Compare August 6, 2026 15:32
@luisgoncalves
luisgoncalves marked this pull request as ready for review August 6, 2026 15:38
@luisgoncalves
luisgoncalves requested a review from aleixsuau August 6, 2026 17:09
...params,
currentStep: nextStepResponse,
action: nextStepResponse.actions[0],
action: getElementWithDataHelpers(nextStepResponse.actions[0]),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

"Element" seems unclear in this context. I wonder if we should renameto "entity" or similar.

case HAAPI_STEPS.POLLING:
return handlePollingStep(nextStepResponse, pendingOperation, nextStep, config, history);
return nextStepSuccess(
handlePollingStep(nextStepResponse, pendingOperation, nextStep, config, history),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It seems it would be a clearer that each handle* returns nextStepSuccess internally.

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.

3 participants