Skip to content

refactor(SDK-1127): extract CreatePaymentFlow and ViewPaymentFlow#2463

Merged
mariechatfield merged 11 commits into
mainfrom
refactor/marie/SDK-1127-test-driven
Jul 24, 2026
Merged

refactor(SDK-1127): extract CreatePaymentFlow and ViewPaymentFlow#2463
mariechatfield merged 11 commits into
mainfrom
refactor/marie/SDK-1127-test-driven

Conversation

@mariechatfield

@mariechatfield mariechatfield commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Summary

ContractorManagement.PaymentFlow remains exactly the same; ContractorManagement.CreatePaymentFlow and ContractorManagement.ViewPaymentFlow are new @alpha flows that represent the spokes / internal flows.

post-refactor.mov

Changes

  • Test-first redo of the SDK-1127 hub+spoke split. Phase 1 (fb9173d6, 2f3a2910) adds a flow-integration test layer against the current flat PaymentFlow — the only layer that renders the real component tree and can catch a wiring bug between hub and spoke — plus fixes two weak/no-op spots in the e2e harness that a prior attempt at this refactor needed but never landed.
  • Phase 2 (66f953ea) re-extracts CreatePaymentFlow/ViewPaymentFlow as spokes, mirroring the PayrollFlow/PayrollExecutionFlow pattern. Fixes two real regressions a previous attempt at this same split introduced: each spoke now builds its machine via a lazy useState initializer (not useMemo, which doesn't guarantee identity survives a re-render triggered by a bubbled onEvent call) and passes prefixBreadcrumbs straight through without stripping onNavigate (which had broken "click breadcrumb to return to the hub").
  • CreatePaymentFlow/ViewPaymentFlow are marked @alpha, not @public — they exist to prep a 4th spoke slot for the upcoming HistoricalPaymentFlow, not because a partner asked for standalone entry points. PaymentFlow's public docs still describe the underlying blocks (CreatePayment, PaymentSummary, PaymentHistory, PaymentStatement) as before.
  • Renamed the view spoke from ViewHistoryFlow to ViewPaymentFlow (9cee5ead) so it follows the same <Verb>Payment pattern as its sibling CreatePaymentFlow.
  • Derived files (.reports/, docs/reference/**, docs/guides/endpoint-*, sdk-app/generated-registry-data.ts) intentionally excluded — CI regenerates and commits those separately.

Test plan

  • npm run test -- --run — 3559 passed, 1 expected fail
  • npx tsc --noEmit clean
  • npx eslint clean (only pre-existing unrelated warnings)
  • npm run build clean
  • npx knip clean on new files
  • Phase 1's PaymentFlow.test.tsx, written against the old flat implementation, passes unmodified against the new hub+spoke code

🤖 Generated with Claude Code

mariechatfield and others added 3 commits July 23, 2026 09:58
…ing match

`assertPaymentSummary` and the duplicate check in 93-payment-submit.spec.ts
asserted on "Payment summary," which also appears on the review page's own
totals grid, so the assertion could pass before submission actually
completed. Assert the review heading disappears instead. Also give
FlowRenderer's onEvent handler a real state update so e2e exercises the same
re-render churn a partner app produces, instead of masking bugs behind a
no-op handler.
…refactor (SDK-1127)

Renders the full PaymentFlow tree — the only test layer that can catch a
wiring-level bug between the hub and a future spoke, unlike the machine unit
tests or e2e's happy-path-only coverage. Covers the history -> statement ->
breadcrumb-back -> cancel path, breadcrumb navigation back to the list from
both history and createPayment, and a forced parent re-render mid-flow, so
the upcoming CreatePaymentFlow/ViewHistoryFlow split has a regression net
before any code moves.
…spokes (SDK-1127)

Carves the create-payment and view-history steps out of PaymentFlow into
their own hub+spoke flows, mirroring the PayrollFlow/PayrollExecutionFlow
pattern: each spoke owns its own robot3 machine and breadcrumb trail,
prefixed with the hub's landing breadcrumb, and bubbles terminal events
(exit, cancel, landing navigation) back up to the hub. Prepares the fourth
spoke slot for the upcoming HistoricalPaymentFlow. Pure structural refactor —
no behavior change, all events unchanged; the flow-integration and machine
tests added alongside this confirm the split preserves the flat machine's
exact transitions.

Each spoke builds its machine via a lazy useState initializer rather than
useMemo, and passes prefixBreadcrumbs straight into its trail without
stripping onNavigate — both fix real regressions found in an earlier attempt
at this same split (a useMemo keyed on an unmemoized breadcrumbs array
silently reset in-flight flow state on re-render; stripped onNavigate broke
"click breadcrumb to return to the hub").

CreatePaymentFlow and ViewHistoryFlow are marked @Alpha rather than
promoted to public: PaymentFlow keeps composing them internally, but
partners on the public surface still see the underlying blocks (CreatePayment,
PaymentSummary, PaymentHistory, PaymentStatement) documented as before.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@mariechatfield mariechatfield changed the title refactor(PaymentFlow): extract CreatePaymentFlow and ViewHistoryFlow spokes (SDK-1127) refactor(SDK-1127): extract CreatePaymentFlow and ViewHistoryFlow Jul 23, 2026

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 is the important new test. My first attempt at refactoring accidentally broke some navigation. The state machine unit tests passed because the logic for navigating on events remained; what was missing was firing the expects we expected and when.

These tests let us walk through more of the variations of navigation in a way that's cheaper/faster than a full e2e test but more thorough than purely a state machine test.

Comment thread src/components/Contractor/Payments/PaymentFlow/PaymentFlow.test.tsx
Comment thread src/components/Contractor/Payments/ViewHistoryFlow/GUIDE.md Outdated
mariechatfield and others added 3 commits July 23, 2026 12:31
…spokes (SDK-1127)

Adds hub-level integration coverage for the two remaining untested paths
through PaymentFlow: submitting a new payment through CreatePaymentFlow to
PaymentSummary, and entering/exiting the information-requests spoke via
both cancel and done.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…ntextual wrapper

InformationRequestFormContextual never got the Footer static-property
assignment that every other Flow-composed form uses, and the barrel export
was missing Footer entirely. The response modal rendered with no Cancel or
Submit button whenever InformationRequestsFlow drove it, and closing via the
modal's X never notified a parent hub (e.g. PaymentFlow) either.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
The flow has one spoke and a real exit, not a fan-out of spokes off a
resting screen -- shape-wise it reads as a guided drill-in-and-back, not a
hub. Also names the return edge explicitly (breadcrumb/navigate) instead of
collapsing both directions under one label.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@mariechatfield
mariechatfield force-pushed the refactor/marie/SDK-1127-test-driven branch from 2f0c29c to c7082e0 Compare July 23, 2026 19:39
/>
)
}
InformationRequestFormContextual.Footer = Footer

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.

Latent bug that we found while adding information requests to the flow test 🙃

github-actions Bot and others added 2 commits July 23, 2026 19:44
Aligns the view spoke's name with its sibling CreatePaymentFlow -- both are
Payment-flow spokes of ContractorManagement.PaymentFlow, and the old
ViewHistoryFlow name was the only one that didn't follow that pattern. Pure
rename: no behavior change.
@mariechatfield mariechatfield changed the title refactor(SDK-1127): extract CreatePaymentFlow and ViewHistoryFlow refactor(SDK-1127): extract CreatePaymentFlow and ViewPaymentFlow Jul 23, 2026
@mariechatfield
mariechatfield marked this pull request as ready for review July 23, 2026 20:33
@mariechatfield
mariechatfield requested a review from a team as a code owner July 23, 2026 20:33
@mariechatfield
mariechatfield enabled auto-merge July 24, 2026 21:29
@mariechatfield
mariechatfield added this pull request to the merge queue Jul 24, 2026
Merged via the queue into main with commit 68544e1 Jul 24, 2026
38 checks passed
@mariechatfield
mariechatfield deleted the refactor/marie/SDK-1127-test-driven branch July 24, 2026 21:47
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