-
Notifications
You must be signed in to change notification settings - Fork 279
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(clerk-js): Fix broken Organization methods (#1871)
- Loading branch information
1 parent
13e9dfb
commit 70f2510
Showing
8 changed files
with
137 additions
and
24 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,7 @@ | ||
--- | ||
'@clerk/clerk-js': patch | ||
'@clerk/clerk-react': patch | ||
'@clerk/types': patch | ||
--- | ||
|
||
Fix methods in clerk-js that consumede paginated endpoints in order to retrieve single resources. |
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
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 |
---|---|---|
|
@@ -2,7 +2,11 @@ import { describe } from '@jest/globals'; | |
|
||
import { render, waitFor } from '../../../../testUtils'; | ||
import { bindCreateFixtures } from '../../../utils/test/createFixtures'; | ||
import { createFakeUserOrganizationMembership } from '../../OrganizationSwitcher/__tests__/utlis'; | ||
import { createFakeOrganization } from '../../CreateOrganization/__tests__/CreateOrganization.test'; | ||
import { | ||
createFakeUserOrganizationInvitation, | ||
createFakeUserOrganizationMembership, | ||
} from '../../OrganizationSwitcher/__tests__/utlis'; | ||
import { OrganizationList } from '../OrganizationList'; | ||
|
||
const { createFixtures } = bindCreateFixtures('OrganizationList'); | ||
|
@@ -109,6 +113,85 @@ describe('OrganizationList', () => { | |
expect(queryByRole('button', { name: 'Create organization' })).toBeInTheDocument(); | ||
}); | ||
}); | ||
|
||
it('lists invitations', async () => { | ||
const { wrapper, props, fixtures } = await createFixtures(f => { | ||
f.withOrganizations(); | ||
f.withUser({ | ||
email_addresses: ['[email protected]'], | ||
}); | ||
}); | ||
|
||
fixtures.clerk.user?.getOrganizationMemberships.mockReturnValueOnce( | ||
Promise.resolve({ | ||
data: [ | ||
createFakeUserOrganizationMembership({ | ||
id: '1', | ||
organization: { | ||
id: '1', | ||
name: 'Org1', | ||
slug: 'org1', | ||
membersCount: 1, | ||
adminDeleteEnabled: false, | ||
maxAllowedMemberships: 1, | ||
pendingInvitationsCount: 1, | ||
}, | ||
}), | ||
], | ||
total_count: 1, | ||
}), | ||
); | ||
|
||
const invitation = createFakeUserOrganizationInvitation({ | ||
id: '1', | ||
emailAddress: '[email protected]', | ||
publicOrganizationData: { | ||
name: 'OrgOne', | ||
}, | ||
}); | ||
|
||
invitation.accept = jest.fn().mockResolvedValue( | ||
createFakeUserOrganizationInvitation({ | ||
id: '1', | ||
emailAddress: '[email protected]', | ||
publicOrganizationData: { | ||
name: 'OrgOne', | ||
}, | ||
status: 'accepted', | ||
}), | ||
); | ||
|
||
fixtures.clerk.user?.getOrganizationInvitations.mockReturnValueOnce( | ||
Promise.resolve({ | ||
data: [invitation], | ||
total_count: 1, | ||
}), | ||
); | ||
|
||
fixtures.clerk.getOrganization.mockResolvedValue( | ||
createFakeOrganization({ | ||
adminDeleteEnabled: false, | ||
id: '2', | ||
maxAllowedMemberships: 0, | ||
membersCount: 1, | ||
name: 'OrgOne', | ||
pendingInvitationsCount: 0, | ||
slug: '', | ||
}), | ||
); | ||
|
||
props.setProps({ hidePersonal: true }); | ||
const { queryByText, userEvent, getByRole, queryByRole } = render(<OrganizationList />, { wrapper }); | ||
|
||
await waitFor(async () => { | ||
// Display membership | ||
expect(queryByText('Org1')).toBeInTheDocument(); | ||
// Display invitation | ||
expect(queryByText('OrgOne')).toBeInTheDocument(); | ||
await userEvent.click(getByRole('button', { name: 'Join' })); | ||
expect(queryByRole('button', { name: 'Join' })).not.toBeInTheDocument(); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('CreateOrganization', () => { | ||
|
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