-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🥅(frontend) catch new errors on mailbox creation
- catch errors related to MAIL_PROVISIONING_API_CREDENTIALS introduced in commit #ba30b1d3eec73718add6585f30c6b7959cb21850. Intentionally does not parse the error "Permission denied. Please check your MAIL_PROVISIONING_API_CREDENTIALS." as it means the user is neither admin or owner of the domain and should not access the mailbox creation form - update translations and component tests
- Loading branch information
1 parent
77cc64a
commit ca192c9
Showing
3 changed files
with
125 additions
and
12 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 |
---|---|---|
|
@@ -105,12 +105,12 @@ export const ModalCreateMailbox = ({ | |
}, | ||
secret: { | ||
causes: [ | ||
"Please configure your domain's secret before creating any mailbox.", | ||
`Secret not valid for this domain`, | ||
'Token denied. Please check your MAIL_PROVISIONING_API_CREDENTIALS.', | ||
'Please configure MAIL_PROVISIONING_API_CREDENTIALS before creating any mailbox.', | ||
], | ||
causeShown: t( | ||
'The mail domain secret is misconfigured. Please, contact ' + | ||
'our support team to solve the issue: [email protected]', | ||
'Your request to create a mailbox cannot be completed due to incorrect settings on our server. ' + | ||
'Please contact our support team to resolve the problem: [email protected]', | ||
), | ||
handleError: () => { | ||
methods.setFocus('first_name'); | ||
|
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 |
---|---|---|
|
@@ -252,13 +252,7 @@ describe('ModalCreateMailbox', () => { | |
expect(mockOnSuccess).toHaveBeenCalled(); | ||
}); | ||
|
||
it('displays right error message error when mailbox prefix is already used', async () => { | ||
// mockCreateMailbox.mockRejectedValueOnce( | ||
// new APIError('Failed to create the mailbox', { | ||
// status: 400, | ||
// cause: ['Mailbox with this Local_part and Domain already exists.'], | ||
// }), | ||
// ); | ||
it('displays right error message when mailbox prefix is already used', async () => { | ||
fetchMock.mock(`end:mail-domains/${mockMailDomain.slug}/mailboxes/`, { | ||
status: 400, | ||
body: { | ||
|
@@ -294,6 +288,125 @@ describe('ModalCreateMailbox', () => { | |
expect(inputLocalPart).toHaveFocus(); | ||
}); | ||
|
||
it('displays right error message when DImail api token is invalid', async () => { | ||
fetchMock.mock(`end:mail-domains/${mockMailDomain.slug}/mailboxes/`, { | ||
status: 400, | ||
body: { | ||
secret: | ||
'Token denied. Please check your MAIL_PROVISIONING_API_CREDENTIALS.', | ||
}, | ||
}); | ||
|
||
const user = userEvent.setup(); | ||
|
||
renderModalCreateMailbox(); | ||
|
||
const { | ||
inputFirstName, | ||
inputLastName, | ||
inputLocalPart, | ||
inputEmailAddress, | ||
buttonSubmit, | ||
} = getFormElements(); | ||
|
||
await user.type(inputFirstName, 'John'); | ||
await user.type(inputLastName, 'Doe'); | ||
await user.type(inputLocalPart, 'john.doe'); | ||
await user.type(inputEmailAddress, '[email protected]'); | ||
|
||
await user.click(buttonSubmit); | ||
|
||
await waitFor(() => { | ||
expect( | ||
screen.getByText( | ||
'Your request to create a mailbox cannot be completed due to incorrect settings on our server. ' + | ||
'Please contact our support team to resolve the problem: [email protected]', | ||
), | ||
).toBeInTheDocument(); | ||
}); | ||
|
||
expect(inputFirstName).toHaveFocus(); | ||
}); | ||
|
||
it('displays unhandled error cause', async () => { | ||
fetchMock.mock(`end:mail-domains/${mockMailDomain.slug}/mailboxes/`, { | ||
status: 400, | ||
body: { | ||
secret: | ||
'Permission denied. Please check your MAIL_PROVISIONING_API_CREDENTIALS.', | ||
}, | ||
}); | ||
|
||
const user = userEvent.setup(); | ||
|
||
renderModalCreateMailbox(); | ||
|
||
const { | ||
inputFirstName, | ||
inputLastName, | ||
inputLocalPart, | ||
inputEmailAddress, | ||
buttonSubmit, | ||
} = getFormElements(); | ||
|
||
await user.type(inputFirstName, 'John'); | ||
await user.type(inputLastName, 'Doe'); | ||
await user.type(inputLocalPart, 'john.doe'); | ||
await user.type(inputEmailAddress, '[email protected]'); | ||
|
||
await user.click(buttonSubmit); | ||
|
||
await waitFor(() => { | ||
expect( | ||
screen.getByText( | ||
'Permission denied. Please check your MAIL_PROVISIONING_API_CREDENTIALS.', | ||
), | ||
).toBeInTheDocument(); | ||
}); | ||
|
||
expect(buttonSubmit).toHaveFocus(); | ||
}); | ||
|
||
it('displays right error message when DImail api token is missing', async () => { | ||
fetchMock.mock(`end:mail-domains/${mockMailDomain.slug}/mailboxes/`, { | ||
status: 400, | ||
body: { | ||
secret: | ||
'Please configure MAIL_PROVISIONING_API_CREDENTIALS before creating any mailbox.', | ||
}, | ||
}); | ||
|
||
const user = userEvent.setup(); | ||
|
||
renderModalCreateMailbox(); | ||
|
||
const { | ||
inputFirstName, | ||
inputLastName, | ||
inputLocalPart, | ||
inputEmailAddress, | ||
buttonSubmit, | ||
} = getFormElements(); | ||
|
||
await user.type(inputFirstName, 'John'); | ||
await user.type(inputLastName, 'Doe'); | ||
await user.type(inputLocalPart, 'john.doe'); | ||
await user.type(inputEmailAddress, '[email protected]'); | ||
|
||
await user.click(buttonSubmit); | ||
|
||
await waitFor(() => { | ||
expect( | ||
screen.getByText( | ||
'Your request to create a mailbox cannot be completed due to incorrect settings on our server. ' + | ||
'Please contact our support team to resolve the problem: [email protected]', | ||
), | ||
).toBeInTheDocument(); | ||
}); | ||
|
||
expect(inputFirstName).toHaveFocus(); | ||
}); | ||
|
||
it('displays right error message error when error 500 is received', async () => { | ||
fetchMock.mock(`end:mail-domains/${mockMailDomain.slug}/mailboxes/`, { | ||
status: 500, | ||
|
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 |
---|---|---|
|
@@ -136,7 +136,6 @@ | |
"Teams": "Équipes", | ||
"The National Agency for Territorial Cohesion undertakes to make its\n service accessible, in accordance with article 47 of law no. 2005-102\n of February 11, 2005.": "L'Agence Nationale de la Cohésion des Territoires s’engage à rendre son service accessible, conformément à l’article 47 de la loi n° 2005-102 du 11 février 2005.", | ||
"The domain name encounters an error. Please contact our support team to solve the problem:": "Le nom de domaine rencontre une erreur. Veuillez contacter notre support pour résoudre le problème :", | ||
"The mail domain secret is misconfigured. Please, contact our support team to solve the issue: [email protected]": "Le secret du domaine de messagerie est mal configuré. Veuillez contacter notre support pour résoudre le problème : [email protected]", | ||
"The member has been removed from the team": "Le membre a été supprimé de votre groupe", | ||
"The role has been updated": "Le rôle a bien été mis à jour", | ||
"The team has been removed.": "Le groupe a été supprimé.", | ||
|
@@ -168,6 +167,7 @@ | |
"You must have minimum 1 character": "Vous devez entrer au moins 1 caractère", | ||
"Your domain name is being validated. You will not be able to create mailboxes until your domain name has been validated by our team.": "Votre nom de domaine est en cours de validation. Vous ne pourrez créer de boîtes mail que lorsque votre nom de domaine sera validé par notre équipe.", | ||
"Your request cannot be processed because the server is experiencing an error. If the problem persists, please contact our support to resolve the issue: [email protected]": "Votre demande ne peut pas être traitée car le serveur rencontre une erreur. Si le problème persiste, veuillez contacter notre support pour résoudre le problème : [email protected]", | ||
"Your request to create a mailbox cannot be completed due to incorrect settings on our server. Please contact our support team to resolve the problem: [email protected]": "Votre demande de création de boîte mail ne peut pas être complétée en raison de paramètres incorrects sur notre serveur. Veuillez contacter notre équipe support pour résoudre le problème : [email protected]", | ||
"[disabled]": "[désactivé]", | ||
"[enabled]": "[actif]", | ||
"[failed]": "[erroné]", | ||
|