Render the Brex card through ProviderItem::CardComponent
Updated 2026-11-18: the setup prompt is now one DS::EmptyState instead of two hand-built copies (d365f3619), so the card changes in that block only; the three snapshots that show it are re-recorded.
Summary
Provider kit Track B, B4a: Brex's accounts-page card (brex_items/_brex_item) renders through a shared ProviderItem::CardComponent. The card's HTML is unchanged, checked against snapshots of the partial taken before the change.
Part of #5003 (Track B, item 4, first of two slices: B4a card, B4b panel).
Stacked on #5231. Fork pre-flight: jaysbeekay/sure#721 (same branch, same commit; its CI, Gatekeeper review and screenshot history live there).
What changed
ProviderItem::CardComponent(new,app/components/provider_item/): the card's template, moved from the Brex partial, with the provider named by its key:- messages from the provider's existing
<key>_items.<key>_item.*keys (no locale file changes); - the provider's logo, paths and dom id from its key and record;
- the stats and account counts the partial computed (via
brex_item_render_locals) are now methods on the component, still taking the per-connection maps the accounts page precomputes.
- messages from the provider's existing
brex_items/_brex_itemkeeps itsbrex_item:/visible_accounts:locals and renders the component with Brex's three precomputed maps.BrexItemsHelper#brex_item_render_localsis removed: the partial was its only caller, and no test referenced it.- No slots: the card has no Brex-specific parts. The sync-schedule menu item comes from the shared
sync_schedule_menu_itemhelper that 26 cards use, so the component calls it directly.
Screenshots
The setup prompt, before and after d365f3619 (light mode, 1400px).
| Before | After | |
|---|---|---|
| Accounts to set up | ![]() | ![]() |
| No accounts | ![]() | ![]() |
Demo data
No demo data needed: no new records.
Migration notes
No migration.
Verification
-
Snapshots:
test/components/provider_item/snapshots/holds seven renders of the original Brex partial, recorded before the change:- an admin;
- an admin with a linked account;
- a member with the connection's accounts;
- a member shown one of two accounts (the #3630 case);
- a member with no visible accounts;
- a connection scheduled for deletion;
- a sync error.
The renders were recorded at a frozen time, with record ids, random element ids and CSRF tokens normalised, and whitespace between tags ignored.
ProviderItem::CardComponentTestasserts that both the partial and the component render each snapshot. The seven component tests fail without the change (uninitialized constant ProviderItem::CardComponent). -
Snapshot provenance (re-checked 2026-11-17): the seven partial snapshot tests were run against the old
brex_items/_brex_itempartial onup/provider-kit-controller-setup, before this slice: 7 runs, 0 failures. So the snapshots are the old partial's output, not the component's. -
Whitespace: the normaliser ignores whitespace between and around tags, because the component's template is indented differently. A moved space between inline siblings would therefore pass; no such space differs in these renders.
-
Review fixes (2026-11-17): a test that the card reads the accounts page's precomputed counts, institutions and stats over the model's; the
visible_accountsguard now scans the card component; the snapshot normaliser no longer accepts a blank CSRF token. -
Existing tests unchanged:
ProviderItemCardsTest(every card requires and lists onlyvisible_accounts),AccountsControllerTestand the Brex tests pass unedited. -
Mutations, each caught: counting every account as visible; listing the connection's own accounts instead of the visible ones; showing the admin menu to everyone; dropping the setup prompt; reading another provider's messages; ignoring the precomputed counts.
-
bin/rails test(full, at the B4a commit): 16,290 runs, 0 failures; the same 8ReleaseNotesWorkflowTesterrors (nonodein the test image). -
bin/rubocop,erb_linton the changed templates andbin/brakeman: no offenses or warnings. -
Diff with copy detection (
git diff -Cagainst B3b): non-test +189 / -141. -
Checked against upstream AGENTS.md (blob 1a5dbebd, 2026-11-17): no deviations.
Blast radius
- The accounts page and
ProviderItemsController#complete_account_setuprenderbrex_items/brex_itemwithbrex_item:andvisible_accounts:; unchanged. ProviderItemCardsTestchecks every*_items/_*_itempartial requiresvisible_accounts; the Brex partial still declares it with no default.- Siblings: the other providers' cards keep their own partials; they move to the component in their own slices.
Summary by cubic
Renders the Brex accounts-page card through a new shared ProviderItem::CardComponent instead of the brex_items/_brex_item partial. Part of #5003 (Track B, item 4, first slice; the B4b panel slice follows).
Refactors
- The component derives the provider's messages, logo, paths, and dom id from its key and record, so other providers can adopt it in their own slices.
- The setup prompt now renders a
DS::EmptyStateinstead of hand-built markup, gaining an icon andDS::EmptyState's padding. BrexItemsHelper#brex_item_render_localsis removed; the partial was its only caller.
Tests
- Seven snapshot tests recorded from the old partial pin the card's HTML; the three showing the setup prompt were re-recorded for that change.
- The card reads the accounts page's precomputed counts and stats over the model's fallbacks.
- Snapshot normalising masks record, generated, and CSRF ids; the helper checks that every generated id an attribute references resolves, the card test verifies the delete form targets its own connection, and blank CSRF tokens fail.
- A member's card with one of two accounts hidden guards that only the visible account is listed.
Summary by CodeRabbit
- New Features
- Brex connections now display as expandable cards with connection and sync status, account groups, and institution details when all accounts are visible to you.
- When accounts need setup, the card shows a prompt and a link to complete setup.
- Admins can access sync scheduling and connection deletion actions from the card.



