Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix mail box creation error handling and mail domain addition form #355

Merged
merged 3 commits into from
Sep 9, 2024

Conversation

daproclaima
Copy link
Collaborator

@daproclaima daproclaima commented Aug 22, 2024

Purpose

When we want to create a mailbox for a mail domain, it takes for this mail domain to have a valid secret configured. As far as I understand, this is done manually. So, this is a complex use case to cover with automated tests, which could not be tested with the e2e tests.

Concerning the form to add a mail domain, it could not be submitted when pressing the 'enter' key and would instead update the URL with a query and a page refresh.

Proposal

  • mailbox creation:
    • catch error 500 when the mail domain secret is invalid and display an error cause message
    • catch error 400 and cause when the mail domain secret is empty and display an error cause message

(watch video from 00:30 to 1:15)

before.fix.api.error.handling.mp4
after.fix.api.error.handling.mp4
  • mail domain addition:
    • preventing default behavior on form submission at the "Enter" key down event
before.form.add.mail.domain.fix.mp4
after.form.add.mail.domain.fix.mp4

Error catching and cause replacement were already done on the app, but not with a centralized method. Also, no error message used to be shown for the error 500 type (not shown in the video).

Fix #350, resolves #351

@daproclaima daproclaima added the frontend Relative to the frontend label Aug 22, 2024
@daproclaima daproclaima self-assigned this Aug 22, 2024
@daproclaima daproclaima force-pushed the fix/mail-domains branch 2 times, most recently from 7a96b17 to 2ebd036 Compare August 22, 2024 15:39
Copy link
Collaborator

@sdemagny sdemagny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

En attendant le sentry, est-ce qu'on pourrait pas avoir quelque soit le code d'erreur (tous les codes d'erreur) le code d'erreur récupéré et le message associé affiché sur l'interface ?
Dès qu'on aura sentry on aura des log clairs et on cachera tout ça à l'utilisateur.
Le but c'est de ne plus avoir d'interface/validation de formulaire qui ne fonctionne pas en silence.
Qu'est-ce que vous en dites ? @AntoLC @daproclaima

@daproclaima daproclaima force-pushed the fix/mail-domains branch 2 times, most recently from 9847f15 to 011732b Compare August 27, 2024 18:47
@daproclaima
Copy link
Collaborator Author

@sdemagny, je suis du même avis. C'est ce que j'ai fait ici: add mail domain error handling et create mailbox error handling

Copy link
Collaborator

@AntoLC AntoLC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

useCreateMailboxApiError.tsx and useAddMailDomainApiError.tsx are very similar, I think you can merge them to have just one hook, no?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't seem to add or update dependencies, this file should not have changes.

Copy link
Collaborator

@AntoLC AntoLC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bit more work, you will be a jest hero soon.

Copy link
Collaborator

@AntoLC AntoLC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

- allow to submit form by pressing "Enter" key
- force focus on form when form is submited
but is invalid
- add error 500 handling
- update related e2e tests
- add hook to handle api errors.
- add related component tests
- rename CreateMailboxForm into ModalCreateMailbox,
and useCreateMailDomain into useAddMailDomain
- use useAPIError hook in ModalCreateMailbox.tsx and ModalAddMailDomain
- update translations and tests (include removal of e2e test able
to be asserted by component tests)
@daproclaima daproclaima merged commit e4aed82 into main Sep 9, 2024
14 checks passed
@daproclaima daproclaima deleted the fix/mail-domains branch September 9, 2024 10:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
frontend Relative to the frontend
Projects
None yet
3 participants