-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Update error message while adding library team member [FC-0…
…062] (#1572) Update the error message while adding a library team member to show the error message generated by the server
- Loading branch information
Showing
3 changed files
with
42 additions
and
8 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 |
---|---|---|
|
@@ -183,10 +183,10 @@ describe('<LibraryTeam />', () => { | |
expect(await screen.findByText('Team Member added')).toBeInTheDocument(); | ||
}); | ||
|
||
it('shows error when user do not exist', async () => { | ||
it('shows error when specific error (string)', async () => { | ||
const url = getLibraryTeamApiUrl(libraryId); | ||
const axiosMock = new MockAdapter(getAuthenticatedHttpClient()); | ||
axiosMock.onPost(url).reply(400, { email: 'Error' }); | ||
axiosMock.onPost(url).reply(400, { email: 'This is a specific error.' }); | ||
|
||
await renderLibraryTeam(); | ||
|
||
|
@@ -204,7 +204,32 @@ describe('<LibraryTeam />', () => { | |
}); | ||
|
||
expect(await screen.findByText( | ||
'Error adding Team Member. Please verify that the email is correct and belongs to a registered user.', | ||
'Error adding Team Member. This is a specific error.', | ||
)).toBeInTheDocument(); | ||
}); | ||
|
||
it('shows error when specific error (Array)', async () => { | ||
const url = getLibraryTeamApiUrl(libraryId); | ||
const axiosMock = new MockAdapter(getAuthenticatedHttpClient()); | ||
axiosMock.onPost(url).reply(400, { email: ['This is a specific error.'] }); | ||
|
||
await renderLibraryTeam(); | ||
|
||
const addButton = screen.getByRole('button', { name: 'New team member' }); | ||
userEvent.click(addButton); | ||
const emailInput = screen.getByRole('textbox', { name: 'User\'s email address' }); | ||
userEvent.click(emailInput); | ||
userEvent.type(emailInput, '[email protected]'); | ||
|
||
const saveButton = screen.getByRole('button', { name: /add member/i }); | ||
userEvent.click(saveButton); | ||
|
||
await waitFor(() => { | ||
expect(axiosMock.history.post.length).toEqual(1); | ||
}); | ||
|
||
expect(await screen.findByText( | ||
'Error adding Team Member. This is a specific error.', | ||
)).toBeInTheDocument(); | ||
}); | ||
|
||
|
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