Repository navigation
[backport cloud/1.57] FE-3441 test(billing): pin cross-user capability guards after dropping the user-id check - #21059
Conversation
…g the user-id check (#21006) ## Summary Stacked on #21004 (base `fix/billing-capability-read-unified-off`). #21004 drops the `resolved_for.user_id` check from the capabilities reader, which was the safety net that stopped one member's rights (an owner's `can_manage_members` / `can_cancel`) being published as another's. These tests pin the guards that remain, for the case the user-id check covered: two accounts in the same team workspace. Test-only, no production change. No AS IS/TO BE screenshots (no UI change). Each remaining guard is pinned by a test that fails when **only that guard** is removed (owner A, member B, team workspace W; A's answer carries `can_manage_members` / `can_cancel: true`): | Guard | Pinned by | | --- | --- | | core `sameBillingScope` uid comparison | uid-only switch at the same role (owner → second owner): A's answer is `SUPERSEDED`, cached snapshot dropped | | core scope `generation` | A → B → A before A's first answer lands: still `SUPERSEDED` | | composable `authUid` key on read state | A resolved, B signs in: rights hidden synchronously, before the switch watcher runs | | composable stale-result fence (try path) | B answers first, A's late answer must not clobber B; A's refresh `SUPERSEDED` on the SDK rail after the switch must not restore A's snapshot | | composable catch path (fence + abort check) | A's refresh fails with an outage after the switch: B stays ready on its own answer | The composable cases run on both the legacy client and the SDK rail, through a typed `BillingReadRail`. ## Verification - `useBillingCapabilities.crossUser.test.ts` 17 passed; `capabilitiesCrossUser.test.ts` 8 passed; full `useBillingCapabilities*` (241) and `account-core/src/core/billing` (755) pass. - Mutation check, run locally one guard at a time (not committed): - uid compare off → 2 core failures; generation check off → 1 core failure. - `authUid` key off → 2 composable failures; try-path fence off → 3 composable failures. - catch-path fence alone off → 0 failures: on an account switch the watcher aborts the request, so the `controller.signal.aborted` check covers the same case. Removing the fence and the abort check together → 2 failures. - The earlier version of this PR passed with each composable guard removed on its own and with the core uid compare removed; this revision closes those gaps (independent review finding).
📦 Bundle Size
🎨 Storybook: ✅ Built — View Storybook🧩 Custom Nodes Ecosystem Matrix: 🟡 Withheld — could not measureExecutes the frontend JS of every registry pack that ships any, against this change, in both renderers. The eight This candidate changes nothing the matrix measures, so every expensive stage was skipped. Reproduce locally# build one shard's fixture, then run it
python3 scripts/registry-census/build_matrix.py --shard 1/4
MATRIX_RENDERER=vue MATRIX_VUE=1 \
npx vitest run --config vitest.matrix.config.mts
Full docs: scripts/registry-census/README.md 🌾 Fallow: ✅ PassedFallow audits the diff for duplication, complexity and dead code. It gates on new findings only, so when the audit completes, a red is something this PR introduced or moved — never inherited backlog. A red can also mean the audit itself did not finish; the details below say which happened. No new findings in the changed files. Reproduce locally# the base the gate compared against
npx fallow audit --root . --quiet --format json \
--changed-since e1eda8f23790d817579ac2e242deab28d3dba015
Full docs: ADR-DEVEX-LINT-0015 🌐 Website E2ETip All tests passed.
|
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## cloud/1.57 #21059 +/- ##
=============================================
Coverage ? 86.35%
=============================================
Files ? 3665
Lines ? 175103
Branches ? 46226
=============================================
Hits ? 151207
Misses ? 21880
Partials ? 2016
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
Backport of #21006 to
cloud/1.57Automatically created by backport workflow.