-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: rules for invalid emails in group invite modal (#1227)
test: changed invite behavior fix: Allow inviting learners when error/duplicate entries exist test: Test invalid/duplicate email case
- Loading branch information
1 parent
b438ffd
commit 85e2cdf
Showing
3 changed files
with
98 additions
and
49 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
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 |
---|---|---|
|
@@ -230,7 +230,7 @@ describe('<InviteMemberModal />', () => { | |
}); | ||
}); | ||
}); | ||
it('throws up errors for incorrectly formatted emails', async () => { | ||
it('throws up errors for incorrectly formatted email', async () => { | ||
render(<InviteModalWrapper />); | ||
const textareaInputLabel = screen.getByLabelText('Member email addresses'); | ||
const textareaInput = textareaInputLabel.closest('textarea'); | ||
|
@@ -243,6 +243,38 @@ describe('<InviteMemberModal />', () => { | |
expect(inviteButton).toBeDisabled(); | ||
}, { timeout: EMAIL_ADDRESSES_INPUT_VALUE_DEBOUNCE_DELAY + 1000 }); | ||
}); | ||
it('throws up errors for incorrectly formatted emails', async () => { | ||
render(<InviteModalWrapper />); | ||
const textareaInputLabel = screen.getByLabelText('Member email addresses'); | ||
const textareaInput = textareaInputLabel.closest('textarea'); | ||
userEvent.type(textareaInput, 'sillygoosethisisntanemail'); | ||
userEvent.type(textareaInput, '{enter}'); | ||
userEvent.type(textareaInput, 'neitheristhis'); | ||
await waitFor(() => { | ||
expect(screen.getByText('Members can\'t be invited as entered.')).toBeInTheDocument(); | ||
expect(screen.getByText('Please check your member emails and try again.')).toBeInTheDocument(); | ||
expect(screen.getByText('sillygoosethisisntanemail and 1 other email addresses are not valid.')).toBeInTheDocument(); | ||
const inviteButton = screen.getByRole('button', { name: 'Invite' }); | ||
expect(inviteButton).toBeDisabled(); | ||
}, { timeout: EMAIL_ADDRESSES_INPUT_VALUE_DEBOUNCE_DELAY + 1000 }); | ||
}); | ||
it('throws up errors for incorrectly formatted emails but allows inviting valid email', async () => { | ||
render(<InviteModalWrapper />); | ||
const textareaInputLabel = screen.getByLabelText('Member email addresses'); | ||
const textareaInput = textareaInputLabel.closest('textarea'); | ||
userEvent.type(textareaInput, 'sillygoosethisisntanemail'); | ||
userEvent.type(textareaInput, '{enter}'); | ||
userEvent.type(textareaInput, 'neitheristhis'); | ||
userEvent.type(textareaInput, '{enter}'); | ||
userEvent.type(textareaInput, '[email protected]'); | ||
await waitFor(() => { | ||
expect(screen.getByText('Summary (1)')).toBeInTheDocument(); | ||
expect(screen.getByText('Members can\'t be invited as entered.')).toBeInTheDocument(); | ||
expect(screen.getByText('sillygoosethisisntanemail and 1 other email addresses are not valid.')).toBeInTheDocument(); | ||
const inviteButton = screen.getByRole('button', { name: 'Invite' }); | ||
expect(inviteButton).not.toBeDisabled(); | ||
}, { timeout: EMAIL_ADDRESSES_INPUT_VALUE_DEBOUNCE_DELAY + 1000 }); | ||
}); | ||
it('throws up warning for duplicated emails', async () => { | ||
render(<InviteModalWrapper />); | ||
const textareaInputLabel = screen.getByLabelText('Member email addresses'); | ||
|
@@ -251,10 +283,29 @@ describe('<InviteMemberModal />', () => { | |
userEvent.type(textareaInput, '{enter}'); | ||
userEvent.type(textareaInput, '[email protected]'); | ||
await waitFor(() => { | ||
expect(screen.getByText('Summary (1)')).toBeInTheDocument(); | ||
expect(screen.getByText('[email protected] was entered more than once.')).toBeInTheDocument(); | ||
expect(screen.getByText('Only 1 invite per email address will be sent.')).toBeInTheDocument(); | ||
const inviteButton = screen.getByRole('button', { name: 'Invite' }); | ||
expect(inviteButton).not.toBeDisabled(); | ||
}, { timeout: EMAIL_ADDRESSES_INPUT_VALUE_DEBOUNCE_DELAY + 1000 }); | ||
}); | ||
it('throws up warning for invalid/duplicated emails', async () => { | ||
render(<InviteModalWrapper />); | ||
const textareaInputLabel = screen.getByLabelText('Member email addresses'); | ||
const textareaInput = textareaInputLabel.closest('textarea'); | ||
userEvent.type(textareaInput, '[email protected]'); | ||
userEvent.type(textareaInput, '{enter}'); | ||
userEvent.type(textareaInput, '[email protected]'); | ||
userEvent.type(textareaInput, '{enter}'); | ||
userEvent.type(textareaInput, 'sillygoosethisisntanemail'); | ||
await waitFor(() => { | ||
expect(screen.getByText('Summary (1)')).toBeInTheDocument(); | ||
expect(screen.getByText('sillygoosethisisntanemail is not a valid email.')).toBeInTheDocument(); | ||
expect(screen.getByText('Members can\'t be invited as entered.')).toBeInTheDocument(); | ||
expect(screen.getByText('Only 1 invite per email address will be sent.')).toBeInTheDocument(); | ||
const inviteButton = screen.getByRole('button', { name: 'Invite' }); | ||
expect(inviteButton).not.toBeDisabled(); | ||
}, { timeout: EMAIL_ADDRESSES_INPUT_VALUE_DEBOUNCE_DELAY + 1000 }); | ||
}); | ||
}); |