From 546e598f6ff064b0ec331d5d35749f376ec2dd20 Mon Sep 17 00:00:00 2001 From: Alex Carpenter Date: Wed, 29 Oct 2025 13:23:12 -0400 Subject: [PATCH 1/2] chore(clerk-js): Add tests cases for org switcher preview visibility --- .../__tests__/OrganizationSwitcher.test.tsx | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/packages/clerk-js/src/ui/components/OrganizationSwitcher/__tests__/OrganizationSwitcher.test.tsx b/packages/clerk-js/src/ui/components/OrganizationSwitcher/__tests__/OrganizationSwitcher.test.tsx index c854f15f702..ed91a3ac821 100644 --- a/packages/clerk-js/src/ui/components/OrganizationSwitcher/__tests__/OrganizationSwitcher.test.tsx +++ b/packages/clerk-js/src/ui/components/OrganizationSwitcher/__tests__/OrganizationSwitcher.test.tsx @@ -62,6 +62,52 @@ describe('OrganizationSwitcher', () => { }); describe('OrganizationSwitcherTrigger', () => { + it('shows OrganizationPreview when user has an active organization', async () => { + const { wrapper, fixtures } = await createFixtures(f => { + f.withOrganizations(); + f.withUser({ + email_addresses: ['test@clerk.com'], + organization_memberships: [{ name: 'Test Organization', id: '1', role: 'admin' }], + }); + }); + + // Set the active organization in the context + fixtures.clerk.organization = { + id: '1', + name: 'Test Organization', + slug: 'test-organization', + membersCount: 1, + pendingInvitationsCount: 0, + adminDeleteEnabled: true, + maxAllowedMemberships: 100, + } as any; + + const { getByText } = render(, { wrapper }); + expect(getByText('Test Organization')).toBeInTheDocument(); + }); + + it('shows PersonalWorkspacePreview when user has no active organization and hidePersonal is false', async () => { + const { wrapper, props } = await createFixtures(f => { + f.withOrganizations(); + f.withUser({ email_addresses: ['test@clerk.com'] }); + }); + + props.setProps({ hidePersonal: false }); + const { getByText } = render(, { wrapper }); + expect(getByText('Personal account')).toBeInTheDocument(); + }); + + it('shows "No organization selected" when user has no active organization and hidePersonal is true', async () => { + const { wrapper, props } = await createFixtures(f => { + f.withOrganizations(); + f.withUser({ email_addresses: ['test@clerk.com'] }); + }); + + props.setProps({ hidePersonal: true }); + const { getByText } = render(, { wrapper }); + expect(getByText('No organization selected')).toBeInTheDocument(); + }); + it('shows the counter for pending suggestions and invitations', async () => { const { wrapper, fixtures } = await createFixtures(f => { f.withOrganizations(); From 64265d1a659426da30c6b19e2c75cb6c80e2d591 Mon Sep 17 00:00:00 2001 From: Alex Carpenter Date: Wed, 29 Oct 2025 13:25:42 -0400 Subject: [PATCH 2/2] add changeset --- .changeset/gold-planes-wear.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .changeset/gold-planes-wear.md diff --git a/.changeset/gold-planes-wear.md b/.changeset/gold-planes-wear.md new file mode 100644 index 00000000000..a845151cc84 --- /dev/null +++ b/.changeset/gold-planes-wear.md @@ -0,0 +1,2 @@ +--- +---