Skip to content

Commit

Permalink
Merge pull request #1208 from stakovicz/feat-1110-tests-fonctionnels
Browse files Browse the repository at this point in the history
feat (#1110): test fonctionnels
  • Loading branch information
agallou authored Oct 20, 2022
2 parents efc402d + ba3ac8d commit acb9449
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 3 deletions.
29 changes: 29 additions & 0 deletions db/seeds/TechletterSubscriptions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

use Phinx\Seed\AbstractSeed;

class TechletterSubscriptions extends AbstractSeed
{
public function run()
{
$subscriptionDate = (new DateTime())->format(DateTime::ATOM);
$data = [
[
'user_id' => Users::ID_USER_ADMIN,
'subscription_date' => $subscriptionDate,
],
[
'user_id' => Users::ID_USER_EXPIRIE,
'subscription_date' => $subscriptionDate,
],
];

$table = $this->table('afup_techletter_subscriptions');

$table->truncate();

$table
->insert($data)
->save();
}
}
7 changes: 6 additions & 1 deletion db/seeds/Users.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public function run()
'niveau' => 2, // AFUP_DROITS_NIVEAU_ADMINISTRATEUR,
'prenom' => 'Admin',
'email' => '[email protected]',
'niveau_modules' => '00000'
],
// utilisateur ayant expiré, avec une date de cotisation fixe, utile pour les tests
[
Expand All @@ -61,6 +62,7 @@ public function run()
'niveau' => 0, // AFUP_DROITS_NIVEAU_MEMBRE,
'prenom' => 'Jean',
'email' => '[email protected]',
'niveau_modules' => '00000',
],
[
'id' => self::ID_USER_PERSONNE_MORALE,
Expand All @@ -72,6 +74,7 @@ public function run()
'email' => '[email protected]',
'roles' => '["ROLE_COMPANY_MANAGER"]',
'id_personne_morale' => self::ID_PERSONNE_MORALE_MY_CORP,
'niveau_modules' => '00000',
],
[
'id' => self::ID_USER_PERSONNE_MORALE_NON_MANAGER,
Expand All @@ -83,6 +86,7 @@ public function run()
'email' => '[email protected]',
'roles' => '[]',
'id_personne_morale' => self::ID_PERSONNE_MORALE_MY_CORP,
'niveau_modules' => '00000',
],
[
'id' => self::ID_USER_PERSONNE_PHYSIQUE,
Expand All @@ -93,7 +97,8 @@ public function run()
'niveau' => 0, // AFUP_DROITS_NIVEAU_MEMBRE,
'email' => '[email protected]',
'roles' => '[]',
'etat' => User::STATUS_ACTIVE
'etat' => User::STATUS_ACTIVE,
'niveau_modules' => '00000',
],
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ public function sendTestAction(Request $request)
]);
$this->mailer->send($message);

$this->addFlash('notice', 'Le mail de test à été envoyé');
$this->addFlash('notice', 'Le mail de test a été envoyé');

return $this->redirectToRoute('admin_techletter_generate', ['techletterId' => $sendingId]);
}
Expand Down
11 changes: 10 additions & 1 deletion tests/behat/features/Admin/Members/AdminMembersBadge.feature
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,17 @@ Feature: Administration - Partie Badge
When I follow "Ajouter"
Then the ".content h2" element should contain "Nouveau badge"
When I fill in "badge[label]" with "Un super Badge"
Then print last response
And I attach the file "badge1.png" to "badge[image]"
And I press "Créer"
Then I should see "Le badge a été ajouté"
And I should see "Un super Badge"

Scenario: Association d'un badge à une personne physique
Given I am logged in as admin and on the Administration
And I follow "Personnes physiques"
Then the ".content h2" element should contain "Personnes physiques"
# Suit le lien "Modifier la fiche de Personne Paul"
And I follow "modifier_5"
# Valide l'ajout du badge
And I press "user_badge_save"
Then the "table.ui.table.striped.compact.celled" element should contain "Un super Badge"
12 changes: 12 additions & 0 deletions tests/behat/features/Admin/Techletter/AdminVeilleAbonnés.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Feature: Administration - Veille - Abonnés

@reloadDbWithTestData @test
Scenario: Accès aux abonnés de la veille technique
Given I am logged in as admin and on the Administration
And I follow "Abonnés"
Then the ".content .statistic .value" element should contain "2"
And the ".content .statistic .label" element should contain "abonnés"
And I should see "Nom" in the "thead > tr:first-child > th:nth-child(1)" element
And I should see "Date d'enregistrement" in the "thead > tr:first-child > th:nth-child(2)" element
And I should see "Admin Admin" in the "tbody > tr:first-child > td:nth-child(1)" element
And I should see "Jean Maurice" in the "tbody > tr:last-child > td:nth-child(1)" element
34 changes: 34 additions & 0 deletions tests/behat/features/Admin/Techletter/AdminVeilleCampagnes.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
Feature: Administration - Veille - Campagnes

@reloadDbWithTestData
@test
@clearEmails
Scenario: Créer une campagne pour la veille tech
Given I am logged in as admin and on the Administration
And I follow "Campagnes"
Then the ".content h2" element should contain "Campagnes"
And I should see "ID" in the "thead > tr:first-child > th:nth-child(1)" element
And I should see "Date d'envoi planifiée" in the "thead > tr:first-child > th:nth-child(2)" element
And I should see "Envoyée à mailchimp ?" in the "thead > tr:first-child > th:nth-child(3)" element

When I select "1" from "sending_sendingDate_day"
And I select "2" from "sending_sendingDate_month"
And I select "2023" from "sending_sendingDate_year"
And I press "sending_save"
Then the ".content h2" element should contain "Veille de l'AFUP du 01/02/2023"

When I press "Envoyer une newsletter de test au Pôle"
And I should only receive the following emails:
| to | subject |
| <pole-veille@afup.org> | [Test] Veille de l'AFUP du 01/02/2023 |
And the ".content .header" element should contain "Le mail de test a été envoyé"

When I fill in "sendingDate" with "2023-02-01 12:00:00"
And I press "Mettre à jour la date de planification"
And the ".content .header" element should contain "Date mise à jour"

When I follow "Campagnes"
Then the ".content h2" element should contain "Campagnes"
And I should see "3" in the "tbody > tr:last-child > td:nth-child(1)" element
And I should see "01/02/2023" in the "tbody > tr:last-child > td:nth-child(2)" element
And I should see "non" in the "tbody > tr:last-child > td:nth-child(3)" element

0 comments on commit acb9449

Please sign in to comment.