Skip to content

test(ui): add AccountButton connected integration test#9191

Open
alexcarpenter wants to merge 2 commits into
carp/account-button-controllerfrom
carp/account-button-integration
Open

test(ui): add AccountButton connected integration test#9191
alexcarpenter wants to merge 2 commits into
carp/account-button-controllerfrom
carp/account-button-integration

Conversation

@alexcarpenter

@alexcarpenter alexcarpenter commented Jul 17, 2026

Copy link
Copy Markdown
Member

What

Adds an end-to-end integration test for the connected AccountButton — the container from #9185 that wires AccountButtonView to useAccountButtonController. Stacked on top of #9185.

Where the existing tests cover each layer in isolation:

  • account-button.controller.test.tsx — controller → Clerk
  • (view is presentational, driven by fake props)

…this test proves the three layers compose: it renders the real view through the real controller against a mocked @clerk/shared/react, opens the real headless popover, and clicks the real rows/actions — then asserts both the resulting Clerk calls and the container's close-on-success behavior.

Coverage (14 tests)

  • Renders nothing while loading / when there is no active user
  • Renders the trigger and keeps the popover closed until clicked; opens on click
  • Select organizationsetActive({ organization, redirectUrl }) + popover closes
  • Select personalsetActive({ organization: null }) + closes
  • Switch accountsetActive({ session }) + closes
  • Sign out a sessionsignOut({ sessionId }) + closes
  • Sign out allsignOut() + closes
  • Accept invitationaccept() + revalidate() + closes
  • Accept suggestionaccept() + revalidate() + closes
  • Manage organizationnavigate('/org-profile') and the popover stays open
  • Manage account (personal mode) → navigate('/user-profile') and stays open
  • Create organizationnavigate('/create-org') and stays open

Together these exercise every callback in the container's closeOnSuccess set plus every navigation, through the real DOM.

Parity with the legacy suites

The legacy OrganizationSwitcher (30 tests) and UserButton (20 tests) suites are monolithic — all layers in one file. Under the Mosaic split those behaviors route to layers that are already tested, so only the composed-interaction subset belongs here:

  • A11y (dialog semantics, focus trap, focus-on-open, escape-restores-focus, axe) → covered by the headless popover primitive's own suite; not re-tested here.
  • Data derivation / gating (name priority, counters, permission gating, no-user) → owned by account-button.controller.test.tsx.
  • PortalProvider getContainer → N/A; AccountButton navigates via router.navigate, not openX modals.

Feature-parity gaps (not test gaps, tracked separately): AccountButton doesn't yet implement hidePersonal, force-organization-selection, or the trigger pending-counter badge.

Notes

  • The per-row "Sign out" is hover-revealed (pointer-events: none until row hover), a state jsdom can't apply, so that one interaction uses fireEvent.click instead of userEvent. Noted inline.
  • turbo/vitest (14/14), type-check, and --quiet lint all pass locally.

Changeset

Empty — test-only PR, no user-facing change (the feature ships under #9184 / #9185).

@vercel

vercel Bot commented Jul 17, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
clerk-js-sandbox Ready Ready Preview, Comment Jul 17, 2026 4:08pm
swingset Ready Ready Preview, Comment Jul 17, 2026 4:08pm

Request Review

@changeset-bot

changeset-bot Bot commented Jul 17, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 088fc5a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 0 packages

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository YAML (base), Repository UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 2a7f3fe3-0f9b-4531-87b3-6dfbb33b079e

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Comment @coderabbitai help to get the list of available commands.

macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Jul 17, 2026
@macroscopeapp

macroscopeapp Bot commented Jul 17, 2026

Copy link
Copy Markdown

Approvability

Verdict: Approved

This PR adds integration tests for the AccountButton component with no production code changes. The empty changeset confirms no packages are affected, making this a low-risk test-only addition.

You can customize Macroscope's approvability policy. Learn more.

@macroscopeapp
macroscopeapp Bot dismissed their stale review July 17, 2026 16:06

Dismissing prior approval to re-evaluate 088fc5a

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant