@@ -291,7 +291,7 @@ describe('OrganizationSwitcher', () => {
291291 expect ( getByText ( 'Org2' ) ) . toBeInTheDocument ( ) ;
292292 } ) ;
293293
294- it ( 'does not allow creating organization if not allowed to create additional membership ' , async ( ) => {
294+ it ( 'does not allow creating organization if max allowed memberships is reached ' , async ( ) => {
295295 const { wrapper, props } = await createFixtures ( f => {
296296 f . withOrganizations ( ) ;
297297 f . withMaxAllowedMemberships ( { max : 1 } ) ;
@@ -308,6 +308,40 @@ describe('OrganizationSwitcher', () => {
308308 expect ( queryByText ( 'Create organization' ) ) . not . toBeInTheDocument ( ) ;
309309 } ) ;
310310
311+ it ( 'does allow creating organization if max allowed memberships is not reached' , async ( ) => {
312+ const { wrapper, props } = await createFixtures ( f => {
313+ f . withOrganizations ( ) ;
314+ f . withMaxAllowedMemberships ( { max : 2 } ) ;
315+ f . withUser ( {
316+ email_addresses :
[ '[email protected] ' ] , 317+ create_organization_enabled : true ,
318+ organization_memberships : [ { name : 'Org1' , id : '1' , role : 'admin' } ] ,
319+ } ) ;
320+ } ) ;
321+
322+ props . setProps ( { hidePersonal : true } ) ;
323+ const { queryByText, getByRole, userEvent } = render ( < OrganizationSwitcher /> , { wrapper } ) ;
324+ await userEvent . click ( getByRole ( 'button' , { name : 'Open organization switcher' } ) ) ;
325+ expect ( queryByText ( 'Create organization' ) ) . toBeInTheDocument ( ) ;
326+ } ) ;
327+
328+ it ( 'does allow creating organization if max allowed memberships is unlimited' , async ( ) => {
329+ const { wrapper, props } = await createFixtures ( f => {
330+ f . withOrganizations ( ) ;
331+ f . withMaxAllowedMemberships ( { max : 0 } ) ;
332+ f . withUser ( {
333+ email_addresses :
[ '[email protected] ' ] , 334+ create_organization_enabled : true ,
335+ organization_memberships : [ { name : 'Org1' , id : '1' , role : 'admin' } ] ,
336+ } ) ;
337+ } ) ;
338+
339+ props . setProps ( { hidePersonal : true } ) ;
340+ const { queryByText, getByRole, userEvent } = render ( < OrganizationSwitcher /> , { wrapper } ) ;
341+ await userEvent . click ( getByRole ( 'button' , { name : 'Open organization switcher' } ) ) ;
342+ expect ( queryByText ( 'Create organization' ) ) . toBeInTheDocument ( ) ;
343+ } ) ;
344+
311345 it . each ( [
312346 [ 'Admin' , 'admin' ] ,
313347 [ 'Member' , 'basic_member' ] ,
0 commit comments