Derive provider_summary from the declared family panels

Merged
JA
2d ago
+68-131

Summary

Provider kit Track A, A5: SettingsHelper#provider_summary is derived from the declared family panels instead of carrying one when branch per provider.

Part of #5003

Stacked on #5081 (A4), in Track A's native stack on #5005.

Fork pre-flight: jaysbeekay/sure#690 (same commits, against a mirror of upstream main; its CI, Gatekeeper and review history live there).

What changed

  • A provider whose adapter declares panel: (so it is in FAMILY_PANEL_KEYS) is summarised from its @<key>_items: :off without items, otherwise sync_based_summary. Only the providers whose summary really differs keep a branch: Plaid and Plaid EU (configuration form), SnapTrade (OAuth-configured items only), Enable Banking, TrueLayer and Trade Republic (custom summaries).
  • The provider:family generator no longer patches provider_summary: append_provider_summary_case and its two tests are deleted. A generated provider with panel: true gets its summary from the declaration; the generator guide says so.
  • Diff: +68 / −131 (non-test +22 / −112).

No visible change.

Demo data

No demo data needed.

Migration notes

No migration.

Verification

  • Old vs new (Rails runner, old helper loaded as a separate module): 256 cases over 32 keys (28 declared, plaid_eu, PLAID, Brex, an unknown key) × no items / own items / every provider's items / every other provider's items × Plaid configured or not: 0 differences, none raising.
  • Fail-first: "summarises a newly declared panel provider from its items" (old: :off) and "is off for a provider whose panel is not declared" (old: :ok) both failed for that reason before the change.
  • Mutations, each caught: drop the panel guard; drop the SnapTrade filter; drop each of the Enable Banking, TrueLayer and Trade Republic branches; skip the Plaid branch; drop plaid_eu; items instead of items&.any?; no downcase; ignore the configuration key (&.first).
  • eager_load! clean.
  • bin/rails test (full): 15,874 runs, 0 failures; 8 errors in ReleaseNotesWorkflowTest from node missing in the test image. After rebasing the stack onto upstream main (dbeebf14c), the full suite at the top of the stack (A9): 16,246 runs, 0 failures, the same 8 environment errors.
  • bin/rubocop on changed files: no offenses. bin/brakeman: no warnings.

Blast radius

  • Callers: Settings::ProvidersController#build_provider_entries passes every configuration key (filtered to exclude panel keys, so those stay :off apart from Plaid/Plaid EU, as before) and every FAMILY_PANELS key. The @<key>_items it reads are set by load_provider_items for all 26 panel keys, in both branches. instance_variable_get runs only after the FAMILY_PANEL_KEYS guard.
  • Siblings left for later slices: family_panel_items (A6) and load_provider_items (A7) read the same variables.

Summary by cubic

Derives SettingsHelper#provider_summary from the declared family panels instead of one when branch per provider. A provider with a declared panel: gets its summary from its @<key>_items — :off without items, otherwise sync_based_summary. Behavior is unchanged.

Refactors

  • Only providers whose summary really differs keep a branch: Plaid and Plaid EU (configuration form), SnapTrade (OAuth-configured items only), Enable Banking, TrueLayer (re-consent warning), and Trade Republic (custom summaries).
  • The provider:family generator no longer patches provider_summary; append_provider_summary_case and its tests are deleted, so a newly declared panel provider gets its summary without editing the helper.
  • A summary returns :off for a provider whose panel is not declared, even when items exist.

Summary by CodeRabbit

  • Bug Fixes
    • Provider connection summaries now reflect eligible connections, including showing an update warning when a TrueLayer connection needs re-consent.
    • Providers without a declared settings panel are shown as off, even if connection items exist.
    • SnapTrade summaries now include only connections with OAuth configured, preventing ineligible connections from appearing as active.
  • Documentation
    • Updated the provider setup guide to explain that connected providers appear in settings based on their panel declaration, without requiring a separate settings-helper update.