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

[API] Mise à jour affectation #3655

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

sfinx13
Copy link
Collaborator

@sfinx13 sfinx13 commented Jan 31, 2025

Ticket

#3619

Description

Mise à jour des affectations selon le workflow de l'application

flowchart TD
    NOUVEAU[NOUVEAU] -->|Accepter| EN_COURS[EN COURS]
    NOUVEAU -->|Refuser| REFUSE[REFUSÉ]
    EN_COURS -->|Fermer| FERME[FERMÉ]
    REFUSE -->|Annuler le refus| EN_COURS
    FERME -->|Ré-ouvrir| NOUVEAU
Loading

Changements apportés

  • Mise à jour documentation
  • Définition d'un nouveau modèle Affectation pour signalementResponse
  • Ajout d'une nouvelle colonne uuid sur la table affectation
  • Ajout d'une nouvelle route pour la mise à jour d'affectation
  • Définition d'un workflow AffectationVoter::VALID_WORKFLOW_STATUT dans le voter afin de restreindre les mises à jour aux seules transitions valides.
  • Gestion des erreurs d'autorisation API SecurityApiExceptionListener
  • Refactorisation et centralisation des actions dans les subscribers
  • Ajout d'un nouvel événement affectation.closed
  • Ajout d'une affectation dans les fixtures (implique de mettre à jour quelques tests hors scopes)

Pré-requis

make create-db

Configuration

  • Importer le fichier openapi.json dans POSTMAN

Tests

  • Revue de la documentation http://localhost:8080/api/doc#tag/Affectations/operation/patch_api_affectations_update
  • Tester les mises à jour du statut /api/affectations/{{affectation_uuid}} avec un workflow valide (Même comportement que sur l'app)
    • Vérifier le statut de l'affectation sur la fiche
    • Vérifier que les suivi sont bien crée selon le statut
    • Vérifier que les mails sont bien envoyés
  • Vérifier que les erreurs sont gérés
    • Affectation inexistante
    • Non autorisé à modifier l'affectation
    • Workflow invalide
    • Mauvais statut
    • Champs manquant

Tests TNR

  • Vérifier qu'il n’ya pas de régression sur le workflow de mise à jour de statut signalement/affectation

@sfinx13 sfinx13 force-pushed the feature/3619-update-affectation branch from 9592304 to cb21afe Compare February 4, 2025 08:30
@sfinx13 sfinx13 marked this pull request as ready for review February 4, 2025 09:47
@sfinx13 sfinx13 requested review from numew, emilschn and hmeneuvrier and removed request for numew and emilschn February 4, 2025 09:47
Copy link
Collaborator

@numew numew left a comment

Choose a reason for hiding this comment

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

Quelques commentaires dans le code (pas grand choses)

Quelques test KO :

  1. Si j'envoie un payload sans valeur
{
  "statut": null,
  "motifCloture": null,
  "motifRefus": null,
  "message": null,
  "notifyUsager": null
}

J'ai un crash erreur 500 (si possible et pas trop compliqué à corriger en erreur propre)

  1. Si j'envoi le payload d'exemple de la doc
    Screenshot 2025-02-04 at 15-15-19 Histologe
{
    "statut": "EN_COURS",
    "motifCloture": "DEPART_OCCUPANT",
    "motifRefus": "EN_COURS",
    "message": "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
    "notifyUsager": "true"

}

Le payload d'exemple génère des erreurs (notifyUsager, motifRefus)

Difficile d'être exhaustif dans les tests

src/Controller/Api/AffectationUpdateController.php Outdated Show resolved Hide resolved
src/Controller/Api/AffectationUpdateController.php Outdated Show resolved Hide resolved
Signalement $signalement,
Affectation $affectation,
User $user,
Request $request,
FirstAffectationAcceptedSpecification $firstAcceptedAffectationSpecification,
DossierMessageFactory $dossierMessageFactory,
MessageBusInterface $bus,
): Response {
$this->denyAccessUnlessGranted(AffectationVoter::ANSWER, $affectation);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Est-ce qu'on ne devrait pas ici ajouter un check du statut existant pour autoriser uniquement si STATUS_WAIT ?

Copy link
Collaborator Author

@sfinx13 sfinx13 Feb 4, 2025

Choose a reason for hiding this comment

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

Je pourrais à la place appliquer le nouveau voter la ou il est applicable ? (Je voudrais le faire valider avant et faire un autre ticket)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Pour ce cas précis le workflow me parait pas assez restrictif, on veux uniquement que ce soit possible si le statut est STATUS_WAIT (mais ca peux en effet attendre le ticket dédié d'application du voter)

src/Entity/Affectation.php Outdated Show resolved Hide resolved
src/Security/Voter/AffectationVoter.php Show resolved Hide resolved
src/Entity/Affectation.php Outdated Show resolved Hide resolved
Copy link
Collaborator Author

@sfinx13 sfinx13 left a comment

Choose a reason for hiding this comment

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

@numew
Erreur 500 sur une payload avec des propriétés null corrigé
OK j'ai mis à jour la doc avec des vrai exemples de payload

image

image

@sfinx13 sfinx13 force-pushed the feature/3619-update-affectation branch from c75a78a to 53d478c Compare February 4, 2025 20:13
Copy link
Collaborator

@hmeneuvrier hmeneuvrier left a comment

Choose a reason for hiding this comment

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

tests OK

src/Dto/Api/Request/AffectationRequest.php Outdated Show resolved Hide resolved
src/Dto/Api/Request/AffectationRequest.php Outdated Show resolved Hide resolved
src/Controller/Api/AffectationUpdateController.php Outdated Show resolved Hide resolved
src/Manager/AffectationManager.php Show resolved Hide resolved
src/EventSubscriber/AffectationAnsweredSubscriber.php Outdated Show resolved Hide resolved
);

$signalement->addSuivi($suivi);
$this->sendMailToPartner(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Pourquoi le dispatch de SuiviCreatedEvent dans le SuiviManager ne suffit pas ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ça fait planter les tests, il faudrait faire un tour sur ce qui reste comme envoi de mail après création de suivi je crée un ticket

@@ -61,22 +57,6 @@ public function onSignalementClosed(SignalementClosedEvent $event): void
$this->sendMailToPartners($signalement);
Copy link
Collaborator

Choose a reason for hiding this comment

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

idem

Copy link
Collaborator Author

@sfinx13 sfinx13 Feb 7, 2025

Choose a reason for hiding this comment

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

Y'a des conditions dans le SuiviCreatedEventSubscriber pour ignorer les signalement cloturés.
Faudrait une suite au ticket refacto suppression ActivityListener mais dans l'absolu je suis d'accord de tout centraliser. Mais pas dans cette PR

Copy link

sonarqubecloud bot commented Feb 7, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants