Render Mercury's views through the provider kit components

Merged
JA
1d ago
+1602-446

Summary

Provider kit Track B, B8d: Mercury's remaining views render through the provider kit's components: the Settings > Providers panel (PanelComponent), the selection dialogs (AccountSelectionComponent), the two error dialogs (ApiErrorComponent, SetupRequiredComponent) and the setup page (AccountSetupComponent). A pure move, proven against snapshots recorded from the old views. The HTML changes only where the DS commits on jaysbeekay/sure#723 and jaysbeekay/sure#724 restyled the shared components (Cancel link, alerts, empty state); eight snapshots were re-recorded in 8c8a9ea77. This completes moving Mercury's views onto the kit.

One slice rather than Lunch Flow's three (jaysbeekay/sure#750, jaysbeekay/sure#751, jaysbeekay/sure#752): Mercury reuses the hooks those slices added, so its non-test diff is +134 / -445, inside the ~300-line limit.

Part of #5003 (Track B, step 8: the Mercury conversion, views; option (c), kit variants and hooks that reproduce each provider's HTML).

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

Before / after

Before (Mercury's own views)After
Panelits own partial: a list of connections like Brex'sPanelComponent with the setup-steps slot and variant: :classic
Disconnect buttonno aria-labelthe same: :classic omits it (Brex keeps its label)
Credential fieldsinline, twicemercury_items/_credential_fields (token with value: nil; base URL; sandbox note on the add form)
Selection dialogstwo 60-line templates, as Lunch Flow'sAccountSelectionComponent with variant: :classic
Row contentnickname, name or legal business name; "Mercury • USD • status • Type"the same, from mercury_account_options
API error / setup requiredicon notice, Mercury's own keys; API error always links to provider settingsthe components' icon notice with heading:, issues:/steps: and link_text:; return_path: nil
Setup page105-line view plus _subtype_selectAccountSetupComponent with defaults: and variant: :classic; the partial goes; the hard-coded page title stays in the view
Subtype promptshard-coded English "Select subtype" / "Select type"mercury_items.subtype_select.placeholder.* in en.yml, the same words
Rendered HTMLunchanged (snapshots), except the blocks restyled with DS primitives on jaysbeekay/sure#723 and jaysbeekay/sure#724

What changed

  • ProviderItem::PanelComponent: variant: (:kit by default, :classic); disconnect_aria returns no label for :classic.
  • MercuryItemsHelper (new): mercury_account_options, mercury_account_setup_defaults and mercury_depository_subtype, the logic the views computed inline.
  • Mercury's seven views keep their names, ivars and locals and render the components; mercury_items/_subtype_select is deleted (the setup page was its only caller).
  • config/locales/views/mercury_items/en.yml: the two subtype prompts the component looks up. The app has config.i18n.fallbacks = true, so the other fifteen Mercury locales fall back to these English words, which is what every locale showed before.

Screenshots

The move changes nothing else visible. The DS commits on jaysbeekay/sure#723 (8fb320136) and jaysbeekay/sure#724 (16badcc9e) restyle these blocks: the Cancel link (secondary DS::Link), the API error and setup-required notices (DS::Alert in place of the icon notice), and the setup page's hint, fetch error and all-linked state (DS::Alert and DS::EmptyState). The Settings > Providers panel is unchanged (its snapshots match) and is not shown. Before is the base branch up/lunchflow-kit-setup-page (09b89ee5b); after is this head (5b9e1345d). Desktop 1280px; phone at Chrome's 500px minimum window width.

BeforeAfter
Select accounts, desktop
Select accounts, phone
API error, desktop
API error, phone
Setup required, desktop
Setup required, phone
Setup page (hint), desktop
Setup page (hint), phone
Setup page, fetch error, desktop
Setup page, fetch error, phone
Setup page, all linked, desktop
Setup page, all linked, phone

Demo data

No demo data needed.

Migration notes

No migration.

Verification

  • Snapshots recorded first: eleven renders of the old views were written (PROVIDER_ITEM_SNAPSHOTS=write) before anything changed, using the same cases as Brex's and Lunch Flow's:

    • panel: no connections, one connection, a syncing connection with an error;
    • select accounts (nickname, name with &, legal business name only, no name), select accounts with no nameable account, select an existing account, the API error, setup required;
    • setup page: the fixture's "Mercury Checking" plus "Mercury Savings", "Treasury MM" and "Operating" (each subtype rule and the no-match case), an API error, every account linked.

    The three "renders through" tests failed then (expected exactly once / at least once, invoked never for each component), and pass after. Brex's and Lunch Flow's snapshots still match.

  • Snapshot provenance (checked 2026-11-17): this slice's eleven snapshot tests were run against the old Mercury views on up/lunchflow-kit-setup-page (5b7bec6d7), before this slice.

    • With the snapshots as first recorded (57677753d): 11 runs, 0 failures. So the recordings are the old views' output.
    • With the current snapshots: the three panel snapshots still match. The other 8 differ only in the DS blocks: the Cancel link (3 selection snapshots), the api_error and setup_required dialogs (now DS::Alerts), and the setup page's hint, fetch error and all-linked state (3 setup snapshots). That is the deliberate DS change re-recorded in 8c8a9ea77.
  • Existing tests unedited: MercuryItemsControllerTest, Settings::ProvidersControllerTest, I18nTest and the Brex and Lunch Flow tests pass.

  • Mutations, each caught (17): the classic panel keeping the aria-label; Brex's panel losing it; Mercury's panel not classic; a setup step dropped; the edit form given the add form's token placeholder; the sandbox note on the edit form; the row name ignoring the nickname; ignoring the legal business name; the type not titleized; the selection not classic; the API error losing an issue; the API error or setup-required notice as an alert; the setup defaulting to Depository; an unmatched name defaulting to checking; the subtype prompt reworded in en.yml; the setup page not classic.

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

  • bin/rubocop, erb_lint on the changed files: no offenses. bin/brakeman: no warnings. i18n-tasks normalize leaves en.yml unchanged.

  • Size (git diff -C): non-test +134 / -445.

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

Blast radius

Who else hits these lines, and what do they pass?

  • render_provider_panel("mercury", …) and the Bank sync page render settings/providers/mercury_panel with the same locals and the same mercury-providers-panel Turbo target; ProviderItemsController renders Mercury's selection, error and setup views with the same ivars and locals.
  • PanelComponent is also rendered by Brex's panel (no variant:) and Lunch Flow's (single shape, no disconnect button); their snapshots pin their output.
  • Siblings: the other providers keep their own views. Still untranslated in Mercury's views, unchanged here: the setup page title ("Set Up Mercury Accounts") and "Mercury • USD" in the account rows.

Summary by cubic

Moves Mercury's remaining views onto the provider kit components: the Settings > Providers panel, account selection dialogs, API error and setup-required dialogs, and the setup page now render PanelComponent, AccountSelectionComponent, ApiErrorComponent, SetupRequiredComponent, and AccountSetupComponent. A pure move — the rendered HTML is unchanged, verified against snapshots recorded from the old views, except where shared components were restyled with DS primitives (the Cancel link, alerts, empty state, and the setup page's dropdowns through DS::Select).

  • PanelComponent gains a variant: :classic option so Mercury's disconnect button carries no aria-label; Brex's keeps its label.
  • View logic moves to a new MercuryItemsHelper and a mercury_items/_credential_fields partial; the _subtype_select partial is deleted.
  • The hard-coded English subtype prompts become mercury_items.subtype_select.placeholder.* in en.yml; other locales fall back to the same words.
  • Eight Mercury dialog and setup snapshots were re-recorded for the DS primitives; the selection snapshot now rejects a blank authenticity token.