-
Notifications
You must be signed in to change notification settings - Fork 245
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): Initialize default role with form controls (#4281)
- Loading branch information
1 parent
5aeff83
commit d2ec88e
Showing
3 changed files
with
79 additions
and
4 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 | ||
--- | ||
|
||
Enable "Send invitation" button when default role is loaded |
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 |
---|---|---|
|
@@ -189,6 +189,70 @@ describe('InviteMembersPage', () => { | |
await userEvent.type(getByTestId('tag-input'), '[email protected],'); | ||
await waitFor(() => expect(getByRole('button', { name: /select role/i })).toBeInTheDocument()); | ||
}); | ||
|
||
it('enables send button with default role once email address has been entered', async () => { | ||
const defaultRole = 'mydefaultrole'; | ||
|
||
const { wrapper, fixtures } = await createFixtures(f => { | ||
f.withOrganizations(); | ||
f.withOrganizationDomains(undefined, defaultRole); | ||
f.withUser({ | ||
email_addresses: ['[email protected]'], | ||
organization_memberships: [{ name: 'Org1', role: 'admin' }], | ||
}); | ||
}); | ||
|
||
fixtures.clerk.organization?.getRoles.mockResolvedValue({ | ||
total_count: 3, | ||
data: [ | ||
{ | ||
pathRoot: '', | ||
reload: jest.fn(), | ||
id: 'member', | ||
key: 'member', | ||
name: 'member', | ||
description: '', | ||
permissions: [], | ||
createdAt: new Date(), | ||
updatedAt: new Date(), | ||
}, | ||
{ | ||
pathRoot: '', | ||
reload: jest.fn(), | ||
id: 'admin', | ||
key: 'admin', | ||
name: 'Admin', | ||
description: '', | ||
permissions: [], | ||
createdAt: new Date(), | ||
updatedAt: new Date(), | ||
}, | ||
{ | ||
pathRoot: '', | ||
reload: jest.fn(), | ||
id: defaultRole, | ||
key: defaultRole, | ||
name: defaultRole, | ||
description: '', | ||
permissions: [], | ||
createdAt: new Date(), | ||
updatedAt: new Date(), | ||
}, | ||
], | ||
}); | ||
|
||
const { getByRole, userEvent, getByTestId } = render( | ||
<Action.Root> | ||
<InviteMembersScreen /> | ||
</Action.Root>, | ||
{ wrapper }, | ||
); | ||
|
||
expect(getByRole('button', { name: 'Send invitations' })).toBeDisabled(); | ||
await userEvent.type(getByTestId('tag-input'), '[email protected],'); | ||
expect(getByRole('button', { name: 'Send invitations' })).not.toBeDisabled(); | ||
await userEvent.click(getByRole('button', { name: /mydefaultrole/i })); | ||
}); | ||
}); | ||
|
||
describe('when submitting', () => { | ||
|