diff --git a/features/admin/adherent.feature b/features/admin/adherent.feature index e72307da929..21f40cedb0f 100644 --- a/features/admin/adherent.feature +++ b/features/admin/adherent.feature @@ -1,18 +1,124 @@ @app Feature: Manage adherent from admin panel - Background: - When I am logged as "superadmin@en-marche-dev.fr" admin - Scenario: Display list of adherents + Given I am logged as "superadmin@en-marche-dev.fr" admin When I am on "/admin/app/adherent/list" Then the response status code should be 200 And I should see 32 "tbody tr" elements And I should see 14 "thead tr th" elements Scenario: A user update must trigger an event in RabbitMQ - Given I am on "/admin/app/adherent/list" + Given I am logged as "superadmin@en-marche-dev.fr" admin + When I am on "/admin/app/adherent/list" And I follow "SCHMIDT" And I clean the "api_sync" queue When I press "Mettre à jour" Then the response status code should be 200 + + @debug + Scenario: + As an administrator, I can manually register a user from another app. + The adherent can then change his password on the platform + Given I am logged as "superadmin@en-marche-dev.fr" admin + Then I should have 0 email + When I am on "/admin/app/adherent/list" + And I fill in the following: + | filter[emailAddress][value] | je-mengage-user-1@en-marche-dev.fr | + When I press "Filtrer" + Then I should be on "/admin/app/adherent/list" + And I should see "Jules Fullstack" + And I follow "EM" + Then I should be on "/" + + And I follow "Adhérer" + Then I should be on "/adhesion" + And I check "become_adherent[conditions]" + 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 "/" + + Then I follow "Connexion" + And I fill in the following: + | _login_email | je-mengage-user-1@en-marche-dev.fr | + | _login_password | secret!12345 | + And I press "Connexion" + And I should be on "/evenements" + Then I go to "/deconnexion" + Then I should be on "/" + + Then I follow "Connexion" + Then I should be on "/connexion" + Then I follow "Mot de passe oublié ? Cliquez ici" + Then I should be on "/mot-de-passe-oublie" + And I fill in the following: + | form[email] | je-mengage-user-1@en-marche-dev.fr | + And I clean the "api_sync" queue + 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 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":[], + "message": { + "subject":"Réinitialisation de votre mot de passe", + "from_email":"contact@en-marche.fr", + "global_merge_vars": [ + { + "name":"first_name", + "content":"Jules" + }, + { + "name":"reset_link", + "content":"http://test.enmarche.code/changer-mot-de-passe/@uuid@/@string@" + } + ], + "from_name":"La République En Marche !", + "to":[ + { + "email":"je-mengage-user-1@en-marche-dev.fr", + "type":"to", + "name":"Jules Fullstack" + } + ] + } + } + """ + When I click on the email link "reset_link" + Then the url should match "#^/changer-mot-de-passe/[a-z0-9-]+/[a-zA-Z0-9]+$#" 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/src/Entity/Adherent.php b/src/Entity/Adherent.php index 69b7a2e1d36..03e4ae3619a 100644 --- a/src/Entity/Adherent.php +++ b/src/Entity/Adherent.php @@ -2173,6 +2173,7 @@ public function isUser(): bool public function join(): void { + $this->source = null; $this->adherent = true; } diff --git a/src/Membership/AdherentResetPasswordHandler.php b/src/Membership/AdherentResetPasswordHandler.php index ed3c34da49e..6ff6c2ad9db 100644 --- a/src/Membership/AdherentResetPasswordHandler.php +++ b/src/Membership/AdherentResetPasswordHandler.php @@ -63,7 +63,7 @@ public function reset(Adherent $adherent, AdherentResetPasswordToken $token, str $this->manager->flush(); - if (null === $adherent->getSource()) { + if (null === $adherent->getSource() || $adherent->isAdherent()) { $this->mailer->sendMessage(AdherentResetPasswordConfirmationMessage::createFromAdherent($adherent)); } else { if ($hasBeenActivated) { 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))); } } diff --git a/tests/Test/Geocoder/DummyGeocoder.php b/tests/Test/Geocoder/DummyGeocoder.php index ebdfa63b021..60391358166 100644 --- a/tests/Test/Geocoder/DummyGeocoder.php +++ b/tests/Test/Geocoder/DummyGeocoder.php @@ -129,6 +129,10 @@ class DummyGeocoder implements Geocoder 'latitude' => 48.5278939, 'longitude' => 2.6484923, ], + '2 avenue jean jaurès, 77000 melun, france' => [ + 'latitude' => 48.5278939, + 'longitude' => 2.6484923, + ], '30 boulevard louis guichoux, 13003 marseille 3e, fr' => [ 'latitude' => 43.325900, 'longitude' => 5.374680,