-
Notifications
You must be signed in to change notification settings - Fork 265
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(clerk-js): Hide Members page of OrgProfile if user doesn't have a…
- Loading branch information
1 parent
383d336
commit d8cd0e2
Showing
6 changed files
with
89 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@clerk/clerk-js': patch | ||
--- | ||
|
||
Hide members page of <OrganizationProfile/> if user doesn't have any membership related permissions. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,7 +70,7 @@ describe('OrganizationMembers', () => { | |
f.withOrganizations(); | ||
f.withUser({ | ||
email_addresses: ['[email protected]'], | ||
organization_memberships: [{ name: 'Org1', permissions: [] }], | ||
organization_memberships: [{ name: 'Org1', permissions: ['org:sys_memberships:read'] }], | ||
}); | ||
}); | ||
|
||
|
@@ -85,6 +85,26 @@ describe('OrganizationMembers', () => { | |
}); | ||
}); | ||
|
||
it('does not show members tab or navbar route if user is lacking permissions', async () => { | ||
const { wrapper, fixtures } = await createFixtures(f => { | ||
f.withOrganizations(); | ||
f.withUser({ | ||
email_addresses: ['[email protected]'], | ||
organization_memberships: [{ name: 'Org1', permissions: [] }], | ||
}); | ||
}); | ||
|
||
fixtures.clerk.organization?.getRoles.mockRejectedValue(null); | ||
|
||
const { queryByRole } = render(<OrganizationMembers />, { wrapper }); | ||
|
||
await waitFor(() => { | ||
expect(queryByRole('tab', { name: 'Members' })).not.toBeInTheDocument(); | ||
expect(queryByRole('tab', { name: 'Invitations' })).not.toBeInTheDocument(); | ||
expect(queryByRole('tab', { name: 'Requests' })).not.toBeInTheDocument(); | ||
}); | ||
}); | ||
|
||
it('navigates to invite screen when user clicks on Invite button', async () => { | ||
const { wrapper, fixtures } = await createFixtures(f => { | ||
f.withOrganizations(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,4 +53,24 @@ describe('OrganizationProfile', () => { | |
expect(getByText('Custom1')).toBeDefined(); | ||
expect(getByText('ExternalLink')).toBeDefined(); | ||
}); | ||
|
||
it('removes member nav item if user is lacking permissions', async () => { | ||
const { wrapper } = await createFixtures(f => { | ||
f.withOrganizations(); | ||
f.withUser({ | ||
email_addresses: ['[email protected]'], | ||
organization_memberships: [ | ||
{ | ||
name: 'Org1', | ||
permissions: [], | ||
}, | ||
], | ||
}); | ||
}); | ||
|
||
const { queryByText } = render(<OrganizationProfile />, { wrapper }); | ||
expect(queryByText('Org1')).toBeInTheDocument(); | ||
expect(queryByText('Members')).not.toBeInTheDocument(); | ||
expect(queryByText('Settings')).toBeInTheDocument(); | ||
}); | ||
}); |