From f52de5aa2ea6d493c4c036ef1fb50233621b0b46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Gardien?= Date: Fri, 3 Jun 2022 17:16:10 +0200 Subject: [PATCH] Debug behat default suite --- features/admin/adherent.feature | 60 +++++++++++++++++++++------- features/registration.feature | 2 +- tests/Behat/Context/EmailContext.php | 9 ++++- 3 files changed, 54 insertions(+), 17 deletions(-) diff --git a/features/admin/adherent.feature b/features/admin/adherent.feature index 18c7c3c4cb6..cb0f6038508 100644 --- a/features/admin/adherent.feature +++ b/features/admin/adherent.feature @@ -37,6 +37,37 @@ Feature: Manage adherent from admin panel When I press "Je rejoins La République En Marche" Then I should be on "/espace-adherent/accueil" And I should see "Votre compte adhérent est maintenant actif." + And I should have 1 email + And I should have 1 email "AdherentAccountConfirmationMessage" for "je-mengage-user-1@en-marche-dev.fr" with payload: + """ + { + "template_name": "adherent-account-confirmation", + "template_content": [], + "message": { + "subject": "Et maintenant ?", + "from_email": "contact@en-marche.fr", + "merge_vars": [ + { + "rcpt": "je-mengage-user-1@en-marche-dev.fr", + "vars": [ + { + "name": "target_firstname", + "content": "Jules" + } + ] + } + ], + "from_name": "La République En Marche !", + "to": [ + { + "email": "je-mengage-user-1@en-marche-dev.fr", + "type": "to", + "name": "Jules Fullstack" + } + ] + } + } + """ Then I go to "/deconnexion" Then I should be on "/" @@ -51,7 +82,6 @@ Feature: Manage adherent from admin panel Then I follow "Connexion" Then I should be on "/connexion" - And I should have 0 email Then I follow "Mot de passe oublié ? Cliquez ici" Then I should be on "/mot-de-passe-oublie" And I fill in the following: @@ -60,31 +90,31 @@ Feature: Manage adherent from admin panel And I press "Envoyer un e-mail" Then I should be on "/connexion" And I should see "Si l'adresse que vous avez saisie est valide, un e-mail vous a été envoyé contenant un lien pour réinitialiser votre mot de passe." - And I should have 1 email + And I should have 2 emails And I should have 1 email "AdherentResetPasswordMessage" for "je-mengage-user-1@en-marche-dev.fr" with payload: """ { - "template_name": "adherent-reset-password, - "template_content": [], + "template_name":"adherent-reset-password", + "template_content":[], "message": { - "subject": "Réinitialisation de votre mot de passe", - "from_email": "contact@en-marche.fr", - "from_name": "La République En Marche !", + "subject":"Réinitialisation de votre mot de passe", + "from_email":"contact@en-marche.fr", "global_merge_vars": [ { - "name": "first_name", - "content": "Jules" + "name":"first_name", + "content":"Jules" }, { - "name": "reset_link", - "content": "http://enmarche.code/changer-mot-de-passe/@string@/@string@" + "name":"reset_link", + "content":"http://test.enmarche.code/changer-mot-de-passe/@uuid@/@string@" } ], - "to": [ + "from_name":"La République En Marche !", + "to":[ { - "email": "je-mengage-user-1@en-marche-dev.fr", - "type": "to", - "name": "Jules Fullstack" + "email":"je-mengage-user-1@en-marche-dev.fr", + "type":"to", + "name":"Jules Fullstack" } ] } diff --git a/features/registration.feature b/features/registration.feature index 5271f62ac68..1c83a0212fa 100644 --- a/features/registration.feature +++ b/features/registration.feature @@ -242,7 +242,7 @@ Feature: ] } ], - "from_name": "La R\u00e9publique En Marche !", + "from_name": "La République En Marche !", "to": [ { "email": "jp@test.com", diff --git a/tests/Behat/Context/EmailContext.php b/tests/Behat/Context/EmailContext.php index 4f6bf0663e1..9e3e39bd806 100644 --- a/tests/Behat/Context/EmailContext.php +++ b/tests/Behat/Context/EmailContext.php @@ -42,7 +42,14 @@ public function gatherContexts(BeforeScenarioScope $scope): void public function iShouldHaveMessages(int $number) { if (($nb = $this->emailRepository->count([])) !== $number) { - throw new \RuntimeException(sprintf('I found %d email(s) instead of %d', $nb, $number)); + $messages = []; + if ($nb > 0) { + foreach ($this->emailRepository->findAll() as $email) { + $messages[] = sprintf('%s (%s) - ', $email->getMessageClass(), $email->getRecipientsAsString()); + } + } + + throw new \RuntimeException(sprintf('I found %d email(s) instead of %d. (%s)', $nb, $number, implode(', ', $messages))); } }