IS-11570 Fix "triggered by" in stepper history when handling redirect steps - #284
Conversation
| // 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'); |
There was a problem hiding this comment.
This used to fail.
| }; | ||
| } | ||
|
|
||
| function nextStepError(step: HaapiStepperError): { nextStepError: HaapiStepperError } { |
There was a problem hiding this comment.
Only used once for now, but added for symmetry.
There was a problem hiding this comment.
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-stepusing the redirect action as the effective triggering action for subsequent history entries. - Introduce an
isLinktype predicate and use it to simplify link-vs-form branching in step processing and reproducible-action logic. - Refactor several step handlers to return
HaapiStepperStepdirectly (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 HaapiFormAction → HaapiStepperFormAction 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.
9074bd0 to
d89d601
Compare
…on with newly added types
| ...params, | ||
| currentStep: nextStepResponse, | ||
| action: nextStepResponse.actions[0], | ||
| action: getElementWithDataHelpers(nextStepResponse.actions[0]), |
There was a problem hiding this comment.
"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), |
There was a problem hiding this comment.
It seems it would be a clearer that each handle* returns nextStepSuccess internally.
In a redirect scenario we have:
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
isLinktype predicate.Also renames
formatNextStepDatatoformatStepDatato avoid confusion with newly added types (separate commit).