Render the Brex setup page through ProviderItem::AccountSetupComponent

Merged
JA
1d ago
+747-120

Updated 2026-11-18: the account type and subtype dropdowns now render through DS::Select under the same field names (0391b4366), with the subtype switch wired to its dropdown:select event; the setup snapshot is re-recorded and a system test covers the switch.

Summary

Provider kit Track B, B5b: Brex's account setup page (brex_items/setup_accounts, with _subtype_select inlined) renders through a shared ProviderItem::AccountSetupComponent. The move itself leaves the HTML unchanged, checked against snapshots taken before the change. A separate commit then switches the page's hand-built alerts and empty state to DS primitives (see Screenshots). This completes moving Brex's views onto the provider kit.

Part of #5003 (Track B, item 5, second of two slices: B5a selection pages, B5b setup page).

Stacked on #5234. Fork pre-flight: jaysbeekay/sure#724 (same branch, same commit; its CI, Gatekeeper review and screenshot history live there).

What changed

  • ProviderItem::AccountSetupComponent: the setup dialog moved from the Brex view, including the per-account subtype selects from _subtype_select (its only caller, so the partial goes). Messages come from the provider's existing setup_accounts.* and subtype_select.* keys; the form posts to complete_account_setup_<key>_item_path.
  • The provider's account-specific defaults are data: defaults: maps each provider account to its default account type and depository subtype. Brex computes it in a new brex_account_setup_defaults helper, from its existing card? check and default_brex_depository_subtype.
  • brex_items/setup_accounts keeps its title and ivars and renders the component.

Screenshots

The move (first commit) changes nothing visible. The DS commit (16badcc9e) renders the account-type hint as an info DS::Alert, the fetch error as an error DS::Alert and the all-linked state as DS::EmptyState. Before is this branch without that commit; after is with it. 1400px and 390px wide.

BeforeAfter
Setup page, desktop
Setup page, phone
API error, desktop
API error, phone
All linked, desktop
All linked, phone

The dropdowns commit (0391b4366) renders both dropdowns through DS::Select. Before is this branch without that commit; after is with it, closed and with the account type open. 1400px wide.

BeforeAfterAfter, open

Demo data

No demo data needed: no new records.

Migration notes

No migration.

Verification

  • Snapshots: three renders of the original view, recorded before the change, with the same normalisation as B4:

    • a cash and a card account, exercising both default types and both name-based subtypes;
    • an API error;
    • every account linked.

    ProviderItem::AccountSetupComponentTest asserts the view still renders each one, and that it renders through the component; the latter fails without the change (uninitialized constant ProviderItem::AccountSetupComponent).

  • Snapshot provenance (re-checked 2026-11-17): the three snapshot tests were run against the old Brex setup view on up/provider-kit-select, before this slice: 3 runs, 0 failures.

  • DS commit (2026-11-17): the three setup snapshots were re-recorded on purpose; each diff is the replaced block only. Lunch Flow's and Mercury's setup snapshots were re-recorded the same way when this merged up (jaysbeekay/sure#752, jaysbeekay/sure#753).

  • Existing tests unchanged: BrexItemsControllerTest, BrexItemsProviderKitTest and the helper tests pass unedited.

  • Mutations, each caught: every account defaulting to Depository; no default subtype; the submit enabled after an API error or with nothing to set up; the API error hidden; Brex's card default lost; another provider's messages.

  • bin/rails test (full, at the B5b commit): 16,304 runs, 0 failures; the same 8 ReleaseNotesWorkflowTest errors (no node in the test image).

  • bin/rubocop, erb_lint on the changed templates and bin/brakeman: no offenses or warnings.

  • Diff with copy detection (git diff -C against B5a): non-test +171 / -120.

  • Checked against upstream AGENTS.md (blob 1a5dbebd, 2026-11-17): no deviations.

Blast radius

  • ProviderItemsController#setup_accounts renders brex_items/setup_accounts with the same ivars; unchanged.
  • Siblings: the other providers' setup pages keep their own templates for now.

Summary by cubic

Moves Brex's account setup page onto a shared ProviderItem::AccountSetupComponent, completing the move of Brex's views onto the provider kit (part of #5003).

  • The setup dialog, including the _subtype_select partial, moves into the component; the partial is removed.
  • Brex's per-account defaults are passed in as data via a new brex_account_setup_defaults helper.
  • Messages and the form path use the provider's keyed translations, so other providers can reuse the component.
  • The account type and subtype dropdowns now render through DS::Select under the same field names (account_types[<id>], account_subtypes[<id>]), keeping the subtype's blank placeholder; the type selection still drives the subtype switch, covered by a new system test.
  • The fetch error, account-type hint, and all-linked state become DS::Alert and DS::EmptyState — a deliberate visual change.
  • Other providers' setup pages keep their own templates for now.