-
Notifications
You must be signed in to change notification settings - Fork 246
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): Require role to be selected before sending organizatio…
…n invite (#2129)
- Loading branch information
1 parent
3007ebf
commit d005992
Showing
5 changed files
with
69 additions
and
36 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 | ||
--- | ||
|
||
Require role to be selected before sending organization invite, affects `<OrganizationProfile/>` and <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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,7 +24,7 @@ describe('InviteMembersPage', () => { | |
}); | ||
|
||
describe('Submitting', () => { | ||
it('enables the Send button when one or more email has been entered', async () => { | ||
it('keeps the Send button disabled until a role is selected and one or more email has been entered', async () => { | ||
const { wrapper, fixtures } = await createFixtures(f => { | ||
f.withOrganizations(); | ||
f.withUser({ | ||
|
@@ -34,10 +34,14 @@ describe('InviteMembersPage', () => { | |
}); | ||
|
||
fixtures.clerk.organization?.getRoles.mockRejectedValue(null); | ||
const { getByRole, userEvent, getByTestId } = render(<InviteMembersPage />, { wrapper }); | ||
const { getByText, getByRole, userEvent, getByTestId } = render(<InviteMembersPage />, { wrapper }); | ||
expect(getByRole('button', { name: 'Send invitations' })).toBeDisabled(); | ||
|
||
await userEvent.type(getByTestId('tag-input'), '[email protected],'); | ||
expect(getByRole('button', { name: 'Send invitations' })).toBeDisabled(); | ||
|
||
await userEvent.click(getByRole('button', { name: /select an option/i })); | ||
await userEvent.click(getByText(/^member$/i)); | ||
expect(getByRole('button', { name: 'Send invitations' })).not.toBeDisabled(); | ||
}); | ||
|
||
|
@@ -172,6 +176,9 @@ describe('InviteMembersPage', () => { | |
); | ||
const { getByRole, userEvent, getByText, getByTestId } = render(<InviteMembersPage />, { wrapper }); | ||
await userEvent.type(getByTestId('tag-input'), '[email protected],'); | ||
await waitFor(() => expect(getByRole('button', { name: /select an option/i })).not.toBeDisabled()); | ||
await userEvent.click(getByRole('button', { name: /select an option/i })); | ||
await userEvent.click(getByText(/^member$/i)); | ||
await userEvent.click(getByRole('button', { name: 'Send invitations' })); | ||
await waitFor(() => | ||
expect( | ||
|
@@ -206,8 +213,11 @@ describe('InviteMembersPage', () => { | |
status: 400, | ||
}), | ||
); | ||
const { getByRole, userEvent, getByTestId } = render(<InviteMembersPage />, { wrapper }); | ||
const { getByRole, userEvent, getByTestId, getByText } = render(<InviteMembersPage />, { wrapper }); | ||
await userEvent.type(getByTestId('tag-input'), '[email protected]'); | ||
await waitFor(() => expect(getByRole('button', { name: /select an option/i })).not.toBeDisabled()); | ||
await userEvent.click(getByRole('button', { name: /select an option/i })); | ||
await userEvent.click(getByText(/^member$/i)); | ||
await userEvent.click(getByRole('button', { name: 'Send invitations' })); | ||
|
||
expect(getByTestId('tag-input')).not.toHaveValue(); | ||
|
@@ -236,8 +246,11 @@ describe('InviteMembersPage', () => { | |
status: 403, | ||
}), | ||
); | ||
const { getByRole, userEvent, getByTestId } = render(<InviteMembersPage />, { wrapper }); | ||
const { getByRole, getByText, userEvent, getByTestId } = render(<InviteMembersPage />, { wrapper }); | ||
await userEvent.type(getByTestId('tag-input'), '[email protected]'); | ||
await waitFor(() => expect(getByRole('button', { name: /select an option/i })).not.toBeDisabled()); | ||
await userEvent.click(getByRole('button', { name: /select an option/i })); | ||
await userEvent.click(getByText(/^member$/i)); | ||
await userEvent.click(getByRole('button', { name: 'Send invitations' })); | ||
|
||
expect(getByTestId('tag-input')).not.toHaveValue(); | ||
|
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 |
---|---|---|
|
@@ -24,7 +24,7 @@ describe('InviteMembersPage', () => { | |
}); | ||
|
||
describe('Submitting', () => { | ||
it('enables the Send button when one or more email has been entered', async () => { | ||
it('keeps the Send button disabled until a role is selected and one or more email has been entered', async () => { | ||
const { wrapper, fixtures } = await createFixtures(f => { | ||
f.withOrganizations(); | ||
f.withUser({ | ||
|
@@ -34,10 +34,14 @@ describe('InviteMembersPage', () => { | |
}); | ||
|
||
fixtures.clerk.organization?.getRoles.mockRejectedValue(null); | ||
const { getByRole, userEvent, getByTestId } = render(<InviteMembersPage />, { wrapper }); | ||
const { getByText, getByRole, userEvent, getByTestId } = render(<InviteMembersPage />, { wrapper }); | ||
expect(getByRole('button', { name: 'Send invitations' })).toBeDisabled(); | ||
|
||
await userEvent.type(getByTestId('tag-input'), '[email protected],'); | ||
expect(getByRole('button', { name: 'Send invitations' })).toBeDisabled(); | ||
|
||
await userEvent.click(getByRole('button', { name: /select an option/i })); | ||
await userEvent.click(getByText(/^member$/i)); | ||
expect(getByRole('button', { name: 'Send invitations' })).not.toBeDisabled(); | ||
}); | ||
|
||
|
@@ -172,6 +176,9 @@ describe('InviteMembersPage', () => { | |
); | ||
const { getByRole, userEvent, getByText, getByTestId } = render(<InviteMembersPage />, { wrapper }); | ||
await userEvent.type(getByTestId('tag-input'), '[email protected],'); | ||
await waitFor(() => expect(getByRole('button', { name: /select an option/i })).not.toBeDisabled()); | ||
await userEvent.click(getByRole('button', { name: /select an option/i })); | ||
await userEvent.click(getByText(/^member$/i)); | ||
await userEvent.click(getByRole('button', { name: 'Send invitations' })); | ||
await waitFor(() => | ||
expect( | ||
|
@@ -206,8 +213,11 @@ describe('InviteMembersPage', () => { | |
status: 400, | ||
}), | ||
); | ||
const { getByRole, userEvent, getByTestId } = render(<InviteMembersPage />, { wrapper }); | ||
const { getByRole, userEvent, getByTestId, getByText } = render(<InviteMembersPage />, { wrapper }); | ||
await userEvent.type(getByTestId('tag-input'), '[email protected]'); | ||
await waitFor(() => expect(getByRole('button', { name: /select an option/i })).not.toBeDisabled()); | ||
await userEvent.click(getByRole('button', { name: /select an option/i })); | ||
await userEvent.click(getByText(/^member$/i)); | ||
await userEvent.click(getByRole('button', { name: 'Send invitations' })); | ||
|
||
expect(getByTestId('tag-input')).not.toHaveValue(); | ||
|
@@ -236,8 +246,11 @@ describe('InviteMembersPage', () => { | |
status: 403, | ||
}), | ||
); | ||
const { getByRole, userEvent, getByTestId } = render(<InviteMembersPage />, { wrapper }); | ||
const { getByRole, getByText, userEvent, getByTestId } = render(<InviteMembersPage />, { wrapper }); | ||
await userEvent.type(getByTestId('tag-input'), '[email protected]'); | ||
await waitFor(() => expect(getByRole('button', { name: /select an option/i })).not.toBeDisabled()); | ||
await userEvent.click(getByRole('button', { name: /select an option/i })); | ||
await userEvent.click(getByText(/^member$/i)); | ||
await userEvent.click(getByRole('button', { name: 'Send invitations' })); | ||
|
||
expect(getByTestId('tag-input')).not.toHaveValue(); | ||
|