Link the parent breadcrumb on account and SSO provider pages

Merged
JA
1mo ago
+72-0

Closes #504

Update, 30 Oct. main now has upstream #3981 ("Fold the bill's page into its drawer"). BillsController#show always renders the drawer without the layout, so there is no bill page left to carry a trail. The merge of main at a94a7d3a takes main's side in bills_controller.rb and bills_controller_test.rb. It also removes bills_return_path and the breadcrumbs.bills key, because nothing else read them; the Bills index's default trail still reads "Bills" through controller_name.titleize. The ported CI image change and the bills test pin are already on main. This PR's diff is now only the account and SSO provider trails, four files, which match #522 / we-promise/sure#4373. The bills rows below describe the earlier head and no longer apply.

Fork/upstream pair. The account and SSO provider half of this change is ported to upstream main as fork pre-flight #522, which carries upstream PR we-promise/sure#4373 (on upstream issue we-promise/sure#4365). #522 is a port onto mirror/upstream-main, not the same branch or commit as this PR. The bills half stays fork-only: upstream renders bills#show as the index plus a drawer (we-promise/sure#3981), so it has no full bill page to put a trail on.

Before: a bill's page showed Home > Bills, and "Bills" was plain text, so there was no way back to the Bills list from the trail. An account's page (Home > Accounts) and the SSO provider admin forms (Home > SSO providers) had the same problem.

After: the trails read Home > Bills > <bill name>, Home > Accounts > <account name> and Home > SSO providers > Add SSO Provider / Edit SSO Provider, and the middle crumb is a link. The Bills crumb goes back to the tab and filters the bill was opened from (All, Calendar or Paycheck), or to the plain index when the bill wasn't opened from Bills.

How: these actions never set @breadcrumbs, so they took the default trail, whose last crumb is the section and is never a link. Each one now sets its own three-level trail.

Summary

Completes #504, including the owner's request to apply the fix to every breadcrumb with the same defect.

Scope and dependencies

  • Issue: #504
  • Parent PR/branch, if stacked: none
  • Ported CI fixes, so this PR's CI can go green. Each becomes a no-op once main carries it:
    • 89cd90cd ports upstream c1405be40 (we-promise/sure#4108), which pins a date-dependent bills test that fails on main from about the 19th of each month.
    • a531b3ae ports #516's ci.yml change (Refs #511), which moves the service images off ECR Public, whose anonymous limit kept failing test_system before any test ran.
  • Intentionally out of scope:
    • Breadcrumbable defaults and the shared partial. A generic "link the section to its index" default would link /holdings, which 404s without an account.
    • Drawer and dialog pages (transactions, holdings, rules, categories and others), which render over a page that keeps its own trail.
    • Other locales. They fall back to en through config.i18n.fallbacks.

Which pages. A throwaway test sweep, not committed, requested every directly reachable GET page as a family admin and as a super admin, and printed each trail. Only these full pages had an unlinked parent: bills#show, accounts#show, and admin/sso_providers#new and #edit. Goals, events, account statements and API keys already had the full trail.

Changes

  • BillsController#show sets the trail after the drawer early-return. The new private method bills_return_path reuses RecurringFeatureGuardable#safe_return_path(fallback: bills_path), keeps the result only when its path is bills_path, and returns only that path and its query, never a host.
  • AccountsController#show sets Home > [Accounts](/accounts) > name.
  • Admin::SsoProvidersController#set_form_breadcrumbs is called from new, edit and both failure re-renders.
  • config/locales/breadcrumbs/en.yml gains bills: Bills.

Blast radius. @breadcrumbs is per action. The drawer render and the account frame partials render without the layout. safe_return_path is read, not changed. Siblings: Bills::SmartConfigurationsController#show and RecurringOccurrencesController#show are dialogs. AccountableResource#show has no route.

Evidence checklist

  • Each issue in this PR has its own acceptance criteria and no unrelated issue work is included. (The two ported CI fixes above only unblock CI.)
  • Contract rows touched by this change name existing tests.
  • Any gate test has an observed failing mutation transcript attached.
  • Fixtures used as evidence assert internal consistency.
  • Financial calculations use BigDecimal and documented rounding points. (No financial calculations.)
  • De-identification uses token-shape allowlists; no personal data is included.
  • Files changed, decisions, tests/runtime, risks, and next unblocked issue are documented below.

Validation

At a94a7d3a: accounts_controller_test.rb, admin/sso_providers_controller_test.rb and bills_controller_test.rb give 276 runs, 0 failures, 0 errors. RuboCop reports no offences on the four changed files.

Tests. Each positive test failed before its fix. Each last-crumb assertion targets [data-breadcrumbs] > span:last-child, so an unlinked middle crumb can't satisfy it.

TestBefore the fix
bills: the Bills crumb links back to /bills, with the bill name last0 links
bills: an absolute or relative referrer of /bills?view=all&q[bill_type]=subscription keeps that query0 links; the relative case still failed on the first, host-only version (Gatekeeper G1)
bills: no referrer gives a 200 and /bills (G2)0 links
bills: off-host, scheme-relative, javascript:, transactions-page and unparseable referrers give plain /bills0 links
accounts: the Accounts crumb links /accounts, with the account name last0 links
accounts: the accounts list has no self-link, and "Accounts" is its last crumbpassed (a guard)
SSO providers: new and edit link the list, with the form title last0 links
SSO providers: a rejected create keeps the link and the "Add" title, and creates no provider0 links
SSO providers: a rejected update keeps the link and the "Edit" title0 links
SSO providers: the list has no self-linkpassed (a guard)

Mutations, each reverted after its run:

MutantCaught by
drop the referrer host checkthe off-host referrer case
return plain bills_paththe tab case
compare hosts only (the first implementation)the relative-referrer case
drop the trail from the failed update paththe rejected-update case
drop the trail from the failed create paththe rejected-create case (before this test, every test passed)
give the failed update the :new titlethe rejected-update case

Commands and results:

  • bin/rails test, full suite on the controller changes (then e58bf208, re-authored since with the same tree): 12452 runs, 1 failure, 0 errors, 35 skips. The failure is Provider::OpenaiTest#test_extra_headers_stringifies_nested_values_Ruby-style, which only fails in this sandbox: it runs Ruby 3.3, and the test expects Ruby 3.4's Hash#inspect.
  • bills_controller_test.rb at 89cd90cd: 107 runs, 0 failures. The skipped-occurrence test fails without the ported pin and passes with it.
  • CI on a531b3ae: every job green, including test_unit, test_system and Analyze (swift).
  • RuboCop: no offences on the changed files.
  • Brakeman: 0 warnings.
  • Upstream AGENTS.md (read from mirror/upstream-main): the commit subjects are at most 72 characters and give their reasons; the tests are Minitest with fixtures; no ERB, components, styles or API endpoints change; the branch is current with main.

Risks, blockers, and follow-up

  • Only the trail contents change; no component or style changes.
  • Upstream has the same defect for accounts and SSO providers; #522 / we-promise/sure#4373 carries that fix.

Screenshots

Same change as we-promise/sure#4373; these are that PR's before and after screenshots.

Captured by a system test against the test fixtures: before on main at 7917bc1e4, after on we-promise/sure#4373's branch.

PageBeforeAfter
AccountBefore: Home  class= Accounts, as the unlinked current page">After: Home  class= Accounts > Checking Account">
New SSO providerBefore: Home  class= SSO providers">After: Home  class= SSO providers > Add SSO Provider">
Edit SSO providerBefore: Home  class= SSO providers">After: Home  class= SSO providers > Edit SSO Provider">

Summary by CodeRabbit

  • New Features
    • Added breadcrumb navigation to account details and SSO provider forms, with links back to their respective lists.
    • Added a Bills breadcrumb to bill pages. It returns to the Bills list and preserves the selected view when reached from that list.
    • Breadcrumbs now distinguish the current page from linked navigation items.