Skip to content

[AAASM-5211] 🐛 (iam): Key RoleCapabilityCards ROLE_BADGE_TONE by Map - #1771

Merged
Chisanan232 merged 2 commits into
mainfrom
v0.0.1/AAASM-5211/fix/role_capability_badge_tone
Jul 28, 2026
Merged

[AAASM-5211] 🐛 (iam): Key RoleCapabilityCards ROLE_BADGE_TONE by Map#1771
Chisanan232 merged 2 commits into
mainfrom
v0.0.1/AAASM-5211/fix/role_capability_badge_tone

Conversation

@Chisanan232

Copy link
Copy Markdown
Contributor

Description

While verifying AAASM-5211's acceptance criteria (subtask AAASM-5231), found that one of the Story's four target sites was never actually fixed despite the Story/Epic being tracked as complete: dashboard/src/features/iam/RoleCapabilityCards.tsx's ROLE_BADGE_TONE was still a plain Record<string, string> object literal, indexed with bracket notation (ROLE_BADGE_TONE[role] ?? 'iam-role-badge--viewer').

This is the same wire-data-keyed object-literal lookup pattern the rest of Epic AAASM-5208 eradicated — a role id equal to an inherited Object.prototype member name (constructor, toString, __proto__, hasOwnProperty, valueOf) would resolve to that inherited value instead of falling through to the default tone class, defeating the ?? 'iam-role-badge--viewer' fallback.

Note: this file/variable is distinct from the byte-identical-looking ROLE_BADGE_TONE in features/iam/MemberList.tsx, which AAASM-5229's PR #1744 already converted to a Map — that PR's own description explicitly noted RoleCapabilityCards.tsx was left untouched, out of scope for that ticket. This PR closes that gap for RoleCapabilityCards.tsx's own ROLE_BADGE_TONE, following the identical Map pattern already established in MemberList.tsx.

Type of Change

  • 🐛 Bug fix

Breaking Changes

  • No

Related Issues

  • Related Jira ticket: AAASM-5211

Testing

  • Unit tests added / updated — new RoleCapabilityCard — badge tone describe block in RoleCapabilityCards.test.tsx asserting inherited-prototype-key role ids (constructor, toString, __proto__, hasOwnProperty, valueOf) and unknown roles fall back to the default tone class. These assertions fail against the pre-fix object-literal lookup.
  • No integration tests required — component-level unit coverage is sufficient for this lookup-safety fix.

Locally verified in dashboard/:

  • pnpm exec tsc --noEmit — clean
  • pnpm exec eslint . — clean
  • pnpm exec vitest run — 272 files / 3022 tests passed (full suite)

Checklist

  • Code follows project style guidelines
  • Self-review of the diff completed
  • Documentation updated if behaviour changed (n/a — internal lookup only)
  • All CI checks passing (pending CI run)
  • Commits are small and follow the Gitmoji convention
  • Commits are signed off (git commit -s) — advisory only per CONTRIBUTING.md

RoleCapabilityCards still indexed ROLE_BADGE_TONE as a plain object literal
with `?? 'iam-role-badge--viewer'` fallback, so a role id matching an
inherited Object.prototype member (constructor, toString, __proto__, …)
would resolve to that inherited value instead of the fallback tone. This is
the same class of gap AAASM-5229/#1744 fixed in the neighboring but distinct
MemberList.tsx ROLE_BADGE_TONE — this one was left untouched by that ticket's
scope and remained live.
Regression test asserting that inherited Object.prototype member names
(constructor, toString, __proto__, hasOwnProperty, valueOf) and unknown role
ids fall back to the default badge tone rather than resolving to a stray
prototype value. Fails against the pre-fix object-literal lookup.
@codecov

codecov Bot commented Jul 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@sonarqubecloud

Copy link
Copy Markdown

@Chisanan232 Chisanan232 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ LGTM — reviewed and approved by Claude Code

(Recorded as a review comment because GitHub blocks self-approval on an own-authored PR; this is the sign-off of record.)

Requirement correctness

This closes a genuine gap left by the AAASM-5208 sweep, found by independently re-verifying every Story in the Epic against live origin/main rather than trusting Jira's "Done" status: RoleCapabilityCards.tsx's own ROLE_BADGE_TONE was never converted, even though the byte-identical table in the sibling MemberList.tsx was fixed under AAASM-5229 (PR #1744) — confirmed via git log and get_pull_request_files on #1744 that it only ever touched MemberList.tsx. ROLE_BADGE_TONEMap, read site → .get() ?? 'iam-role-badge--viewer'. Regression test covers constructor/toString/__proto__/hasOwnProperty/valueOf plus an ordinary unknown-role case, all asserting the default tone renders rather than an inherited-prototype value leaking into the badge class.

CI — fully green

17/17 checks pass, including Dashboard (type-check + lint), Dashboard tests + coverage, Dashboard e2e (Playwright), aa-cli build compat, SonarCloud ×2, CodeQL, and CI Success.

Security

Closes the last remaining Epic-5208 site of this shape — no new risk introduced.

Note for the record: a second, independently-dispatched PR (#1775, AAASM-5245) found and fixed this exact same site while adding a regression lint rule, before this PR merged. Will rebase/adjust #1775 to drop its now-duplicate RoleCapabilityCards.tsx hunk once this merges, to avoid a conflict.

Merging with a merge commit as org admin.

🤖 Reviewed with Claude Code

@Chisanan232
Chisanan232 merged commit 36df767 into main Jul 28, 2026
40 checks passed
@Chisanan232
Chisanan232 deleted the v0.0.1/AAASM-5211/fix/role_capability_badge_tone branch July 28, 2026 04:16
Chisanan232 added a commit that referenced this pull request Jul 28, 2026
… rule)

Closes AAASM-5245 (and its parent AAASM-5216). Adds the no-restricted-syntax rule banning Record<> object-literal lookup tables, with its three documented gaps, closing the prevention half of Epic AAASM-5208. Found and fixed one genuine missed site (RoleCapabilityCards.tsx's ROLE_BADGE_TONE) independently of PR #1771, which landed first — rebased to drop the now-duplicate hunk. Reviewed and approved by Claude Code (CI green 17/17, requirement-correct, all 45 suppressions individually justified, no security concerns). Merged as org admin.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant