@@ -62,6 +62,52 @@ describe('OrganizationSwitcher', () => {
6262 } ) ;
6363
6464 describe ( 'OrganizationSwitcherTrigger' , ( ) => {
65+ it ( 'shows OrganizationPreview when user has an active organization' , async ( ) => {
66+ const { wrapper, fixtures } = await createFixtures ( f => {
67+ f . withOrganizations ( ) ;
68+ f . withUser ( {
69+ email_addresses :
[ '[email protected] ' ] , 70+ organization_memberships : [ { name : 'Test Organization' , id : '1' , role : 'admin' } ] ,
71+ } ) ;
72+ } ) ;
73+
74+ // Set the active organization in the context
75+ fixtures . clerk . organization = {
76+ id : '1' ,
77+ name : 'Test Organization' ,
78+ slug : 'test-organization' ,
79+ membersCount : 1 ,
80+ pendingInvitationsCount : 0 ,
81+ adminDeleteEnabled : true ,
82+ maxAllowedMemberships : 100 ,
83+ } as any ;
84+
85+ const { getByText } = render ( < OrganizationSwitcher /> , { wrapper } ) ;
86+ expect ( getByText ( 'Test Organization' ) ) . toBeInTheDocument ( ) ;
87+ } ) ;
88+
89+ it ( 'shows PersonalWorkspacePreview when user has no active organization and hidePersonal is false' , async ( ) => {
90+ const { wrapper, props } = await createFixtures ( f => {
91+ f . withOrganizations ( ) ;
92+ f . withUser ( { email_addresses :
[ '[email protected] ' ] } ) ; 93+ } ) ;
94+
95+ props . setProps ( { hidePersonal : false } ) ;
96+ const { getByText } = render ( < OrganizationSwitcher /> , { wrapper } ) ;
97+ expect ( getByText ( 'Personal account' ) ) . toBeInTheDocument ( ) ;
98+ } ) ;
99+
100+ it ( 'shows "No organization selected" when user has no active organization and hidePersonal is true' , async ( ) => {
101+ const { wrapper, props } = await createFixtures ( f => {
102+ f . withOrganizations ( ) ;
103+ f . withUser ( { email_addresses :
[ '[email protected] ' ] } ) ; 104+ } ) ;
105+
106+ props . setProps ( { hidePersonal : true } ) ;
107+ const { getByText } = render ( < OrganizationSwitcher /> , { wrapper } ) ;
108+ expect ( getByText ( 'No organization selected' ) ) . toBeInTheDocument ( ) ;
109+ } ) ;
110+
65111 it ( 'shows the counter for pending suggestions and invitations' , async ( ) => {
66112 const { wrapper, fixtures } = await createFixtures ( f => {
67113 f . withOrganizations ( ) ;
0 commit comments