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

JME users can become adherents #7333

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 110 additions & 4 deletions features/admin/adherent.feature
Original file line number Diff line number Diff line change
@@ -1,18 +1,124 @@
@app
Feature: Manage adherent from admin panel

Background:
When I am logged as "[email protected]" admin

Scenario: Display list of adherents
Given I am logged as "[email protected]" 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 "[email protected]" 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 "[email protected]" admin
Then I should have 0 email
When I am on "/admin/app/adherent/list"
And I fill in the following:
| filter[emailAddress][value] | [email protected] |
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 "[email protected]" with payload:
"""
{
"template_name": "adherent-account-confirmation",
"template_content": [],
"message": {
"subject": "Et maintenant ?",
"from_email": "[email protected]",
"merge_vars": [
{
"rcpt": "[email protected]",
"vars": [
{
"name": "target_firstname",
"content": "Jules"
}
]
}
],
"from_name": "La République En Marche !",
"to": [
{
"email": "[email protected]",
"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 | [email protected] |
| _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] | [email protected] |
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 "[email protected]" with payload:
"""
{
"template_name":"adherent-reset-password",
"template_content":[],
"message": {
"subject":"Réinitialisation de votre mot de passe",
"from_email":"[email protected]",
"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":"[email protected]",
"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]+$#"
2 changes: 1 addition & 1 deletion features/registration.feature
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ Feature:
]
}
],
"from_name": "La R\u00e9publique En Marche !",
"from_name": "La République En Marche !",
"to": [
{
"email": "[email protected]",
Expand Down
1 change: 1 addition & 0 deletions src/Entity/Adherent.php
Original file line number Diff line number Diff line change
Expand Up @@ -2173,6 +2173,7 @@ public function isUser(): bool

public function join(): void
{
$this->source = null;
$this->adherent = true;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Membership/AdherentResetPasswordHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
9 changes: 8 additions & 1 deletion tests/Behat/Context/EmailContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
}
}

Expand Down
4 changes: 4 additions & 0 deletions tests/Test/Geocoder/DummyGeocoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down