Skip to content

Commit

Permalink
Debug behat default suite
Browse files Browse the repository at this point in the history
  • Loading branch information
Remg committed Jun 3, 2022
1 parent d7aa9e6 commit c1dc12c
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 17 deletions.
62 changes: 47 additions & 15 deletions features/admin/adherent.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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 "[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 "/"

Expand All @@ -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:
Expand All @@ -60,33 +90,35 @@ 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 "[email protected]" 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": "[email protected]",
"from_name": "La République En Marche !",
"subject":"Réinitialisation de votre mot de passe",
"from_email":"[email protected]",
"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": "[email protected]",
"type": "to",
"name": "Jules Fullstack"
"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
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

0 comments on commit c1dc12c

Please sign in to comment.