Derive family_panel_items from the declared family panels

Merged
JA
2d ago
+41-117

Summary

Provider kit Track A, A6: Settings::ProvidersController#family_panel_items is derived from the declared family panels instead of listing each provider's @<key>_items by hand.

Part of #5003

Stacked on #5082 (A5), in Track A's native stack on #5005.

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

What changed

  • family_panel_items = FAMILY_PANEL_KEYS.index_with { |key| instance_variable_get(:"@#{key}_items") }. A provider declared with panel: true gets a sync status on its connection row without an entry of its own. The keys come from the frozen constant, never from a param.
  • The provider:family generator no longer patches family_panel_items: append_family_panel_item is deleted, with append_hash_entry, append_last_entry and add_bank_sync_entry, which had no other users, and their two tests. add_bank_sync_entries now only warns when the adapter lacks its panel: declaration.
  • Diff: +41 / −117 (non-test +10 / −88).

No visible change.

Demo data

No demo data needed.

Migration notes

No migration.

Verification

  • Old vs new (Rails runner, old method loaded on its own): 32 scenarios (no items, every provider's items, each declared provider's items alone, plus @financekit_connections and @plaid_eu_items): 0 differences, 26 keys on both sides.
  • Fail-first: "family_panel_items hands each declared panel its own loaded items" failed before the change (a declared gocardless panel was missing from the hand-kept hash).
  • Mutations, each caught: read @<key>_item; key by every connection declaration instead of the panels; return nil items; drop the generator's warning; drop its early return for an adapter that declares its panel (both covered by the new generator test, added after review).
  • 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

  • Caller: compute_provider_sync_health only, which reads items_map[key] for the PANEL_SYNCABLE_TYPES keys (the same declared panels), so hash order is not relied on.
  • Sibling left for A7: load_provider_items and prepare_show_context set these variables from their own hand-kept lists.

Summary by cubic

Derives the provider settings page's family_panel_items from the declared family panels in FAMILY_PANEL_KEYS instead of a hand-kept hash, so a provider declared with panel: true gets a sync status on its connection row without an entry of its own.

Removes the provider:family generator's regex patching of that hash: append_family_panel_item, append_hash_entry, append_last_entry, and add_bank_sync_entry are deleted along with their tests. The generator now only warns when an adapter lacks its panel: declaration, and the generator guide documents that declaration as the single source for the connection row's sync status and Sync button.

Behavior is unchanged, including the returned hash's 26 keys and their order.

Summary by CodeRabbit

  • Bug Fixes
    • Provider settings now display items for declared panels, including additional panels, and omit providers that are not declared.
    • Connection rows use the adapter’s panel declaration to show sync status and the Sync button.
  • Documentation
    • Updated the provider generator guide to describe how panel declarations affect connection rows and provider summaries.
  • Generator Feedback
    • The generator warns when a provider lacks a connection declaration with a settings panel.