Skip to content

Commit

Permalink
Adjust adhesion page
Browse files Browse the repository at this point in the history
  • Loading branch information
ottaviano committed Sep 11, 2024
1 parent f2296bc commit 3596a11
Show file tree
Hide file tree
Showing 11 changed files with 10 additions and 658 deletions.
1 change: 1 addition & 0 deletions .env.test
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ APP_DEBUG=false
APP_HOST=test.enmarche.code
RENAISSANCE_HOST=test.renaissance.code
APP_RENAISSANCE_HOST=test.renaissance.code
USER_VOX_HOST=test.renaissance.code
WEBHOOK_RENAISSANCE_HOST=test.renaissance.code
PROCURATION_HOST=test.enmarche.code
LEGISLATIVES_AVECVOUS_HOST=test.enmarche.code
Expand Down
12 changes: 1 addition & 11 deletions config/routes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -252,20 +252,10 @@ app_webhook_renaissance:
type: "annotation"

app_renaissance:
host: "%app_renaissance_host%"
host: "%user_vox_host%"
resource: "../src/Controller/Renaissance"
type: "annotation"

app_adherent_elected_contribution:
host: "%user_vox_host%"
resource: "../src/Controller/Renaissance/Adherent/Contribution"
type: "annotation"

app_adhesion:
host: "%user_vox_host%"
resource: "../src/Controller/Renaissance/Adhesion"
type: "annotation"

app_besoindeurope:
host: "%user_vox_host%"
resource: "../src/Controller/BesoinDEurope"
Expand Down
2 changes: 1 addition & 1 deletion features/api/membership_avecvous.feature
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ Feature:
"global_merge_vars": [
{
"name": "create_password_link",
"content": "http://utilisateur.renaissance.code/changer-mot-de-passe/@string@/@string@"
"content": "http://test.renaissance.code/changer-mot-de-passe/@string@/@string@"
}
],
"to": [
Expand Down
4 changes: 2 additions & 2 deletions features/api/membership_jemengage.feature
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ Feature:
},
{
"name": "create_password_link",
"content": "http://utilisateur.renaissance.code/changer-mot-de-passe/@string@/@string@"
"content": "http://test.renaissance.code/changer-mot-de-passe/@string@/@string@"
}
],
"from_name": "Je m'engage",
Expand Down Expand Up @@ -124,7 +124,7 @@ Feature:
},
{
"name": "reset_link",
"content": "http://utilisateur.renaissance.code/changer-mot-de-passe/@string@/@string@"
"content": "http://test.renaissance.code/changer-mot-de-passe/@string@/@string@"
}
],
"from_name": "Renaissance",
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/Renaissance/Adhesion/AdhesionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function __invoke(Request $request): Response
if (($currentUser = $this->getUser()) instanceof Adherent && $currentUser->hasActiveMembership()) {
$this->addFlash('success', 'Vous êtes déjà à jour de cotisation.');

return $this->redirectToRoute('app_renaissance_adherent_space');
return $this->redirectToRoute('vox_app_redirect');
}

/** @var MembershipRequest $membershipRequest */
Expand Down
19 changes: 0 additions & 19 deletions src/Controller/Renaissance/HomeController.php

This file was deleted.

416 changes: 0 additions & 416 deletions templates/renaissance/home.html.twig

This file was deleted.

2 changes: 1 addition & 1 deletion tests/AbstractWebTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ protected function makeEMClient(): void

protected function makeRenaissanceClient(): void
{
$this->client->setServerParameter('HTTP_HOST', static::getContainer()->getParameter('app_renaissance_host'));
$this->client->setServerParameter('HTTP_HOST', static::getContainer()->getParameter('user_vox_host'));
}

protected function makeAdminClient(): void
Expand Down
1 change: 0 additions & 1 deletion tests/Controller/EnMarche/UnregistrationControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ class UnregistrationControllerTest extends AbstractEnMarcheWebTestCase
use ControllerTestTrait;

#[DependsExternal('Tests\App\Controller\Renaissance\Adherent\Contribution\ContributionControllerTest', 'testOnGoingElectedRepresentativeCanSeeContributionWorkflow')]
#[DependsExternal('Tests\App\Controller\Renaissance\AdherentControllerTest', 'testBlockedCertificationRequest')]
#[DependsExternal('Tests\App\Controller\Renaissance\UnregistrationControllerTest', 'testAdherentCanUnregisterSuccessfully')]
public function testAdherentCanUnregisterSuccessfully(): void
{
Expand Down
153 changes: 3 additions & 150 deletions tests/Controller/Renaissance/AdherentControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,10 @@

namespace Tests\App\Controller\Renaissance;

use App\Adherent\Command\RemoveAdherentAndRelatedDataCommand;
use App\Adherent\Handler\RemoveAdherentAndRelatedDataCommandHandler;
use App\DataFixtures\ORM\LoadAdherentData;
use App\Entity\Adherent;
use App\Entity\Reporting\EmailSubscriptionHistory;
use App\Entity\Unregistration;
use App\Mailer\Message\Renaissance\RenaissanceAdherentTerminateMembershipMessage;
use App\Repository\Email\EmailLogRepository;
use App\Repository\UnregistrationRepository;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Group;
use Ramsey\Uuid\Uuid;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Tests\App\AbstractRenaissanceWebTestCase;
Expand All @@ -28,16 +20,13 @@ class AdherentControllerTest extends AbstractRenaissanceWebTestCase
/* @var EmailLogRepository */
private $emailRepository;

#[DataProvider('provideProfilePage')]
public function testProfileActionIsAccessibleForAdherent(string $profilePage): void
public function testProfileActionIsAccessibleForAdherent(): void
{
$this->authenticateAsAdherent($this->client, '[email protected]');

$crawler = $this->client->request(Request::METHOD_GET, $profilePage);
$this->client->request(Request::METHOD_GET, '/app');

$this->assertResponseStatusCode(Response::HTTP_OK, $this->client->getResponse());
$this->assertSame('Laure Fenix', trim($crawler->filter('h6')->text()));
$this->assertStringContainsString('Inscrite depuis le 25 janvier 2017', $crawler->filter('#adherent-since')->text());
$this->assertClientIsRedirectedTo('/oauth/v2/auth?response_type=code&client_id=8128979a-cfdb-45d1-a386-f14f22bb19ae&redirect_uri=http://localhost:8081&scope=jemarche_app%20read:profile%20write:profile', $this->client);
}

public static function provideProfilePage(): \Generator
Expand Down Expand Up @@ -215,50 +204,6 @@ public function testCertifiedAdherentCanNotEditFields(): void
self::assertEquals('adherent_profile[gender]', $disabledFields->eq(3)->attr('name'));
}

public function testAdherentChangePassword(): void
{
$this->authenticateAsAdherent($this->client, '[email protected]');

$crawler = $this->client->request(Request::METHOD_GET, '/parametres/mon-compte/changer-mot-de-passe');
$this->assertStatusCode(Response::HTTP_OK, $this->client);

$this->assertCount(1, $crawler->filter('input[name="adherent_change_password[old_password]"]'));
$this->assertCount(1, $crawler->filter('input[name="adherent_change_password[password][first]"]'));
$this->assertCount(1, $crawler->filter('input[name="adherent_change_password[password][second]"]'));

// Submit the profile form with invalid data
$crawler = $this->client->submit($crawler->selectButton('adherent_change_password[submit]')->form(), [
'adherent_change_password' => [
'old_password' => '',
'password' => [
'first' => '',
'second' => '',
],
],
]);

$errors = $crawler->filter('.re-form-error');

$this->assertResponseStatusCode(Response::HTTP_OK, $this->client->getResponse());
self::assertSame(3, $errors->count());
self::assertSame('Le mot de passe est invalide.', $errors->eq(0)->text());
self::assertSame('Cette valeur ne doit pas être vide.', $errors->eq(1)->text());
self::assertSame('Votre mot de passe doit comporter au moins 8 caractères.', $errors->eq(2)->text());

// Submit the profile form with valid data
$this->client->submit($crawler->selectButton('adherent_change_password[submit]')->form(), [
'adherent_change_password' => [
'old_password' => 'secret!12345',
'password' => [
'first' => 'heaneaheah',
'second' => 'heaneaheah',
],
],
]);

$this->assertClientIsRedirectedTo('/parametres/mon-compte/changer-mot-de-passe', $this->client);
}

/**
* @return EmailSubscriptionHistory[]
*/
Expand All @@ -282,98 +227,6 @@ public function findEmailSubscriptionHistoryByAdherent(Adherent $adherent, ?stri
return $qb->getQuery()->getResult();
}

#[DataProvider('dataProviderCannotTerminateMembership')]
public function testCannotTerminateMembership(string $email): void
{
$this->authenticateAsAdherent($this->client, $email);

$crawler = $this->client->request(Request::METHOD_GET, '/parametres/mon-compte');

$this->assertStatusCode(Response::HTTP_OK, $this->client);
$this->assertStringNotContainsString(
'Si vous souhaitez désadhérer et supprimer votre compte En Marche, cliquez-ici.',
$crawler->text()
);

$this->client->request(Request::METHOD_GET, '/parametres/mon-compte/desadherer');

$this->assertStatusCode(Response::HTTP_FORBIDDEN, $this->client);
}

public static function dataProviderCannotTerminateMembership(): \Generator
{
yield 'PAD' => ['[email protected]'];
yield 'RCL' => ['[email protected]'];
}

#[DataProvider('provideAdherentCredentials')]
public function testAdherentTerminatesMembership(string $userEmail, string $uuid): void
{
/** @var Adherent $adherent */
$adherentBeforeUnregistration = $this->getAdherentRepository()->findOneByEmail($userEmail);

$this->authenticateAsAdherent($this->client, $userEmail);

$crawler = $this->client->request(Request::METHOD_GET, '/parametres/mon-compte/desadherer');
$this->assertStatusCode(Response::HTTP_OK, $this->client);

$crawler = $this->client->submit($crawler->selectButton('Je confirme la suppression de mon adhésion')->form());

$this->assertEquals('http://'.$this->getParameter('app_renaissance_host').'/parametres/mon-compte/desadherer', $this->client->getRequest()->getUri());

$errors = $crawler->filter('.re-form-error');

$this->assertStatusCode(Response::HTTP_OK, $this->client);
$this->assertSame(0, $errors->count());
$this->assertStringContainsString('Votre adhésion et votre compte Renaissance ont bien été supprimés, vos données personnelles ont été effacées de notre base.', $this->client->getResponse()->getContent());

$this->assertCount(1, $this->getEmailRepository()->findRecipientMessages(RenaissanceAdherentTerminateMembershipMessage::class, $userEmail));

$this->client->getContainer()->get('test.'.RemoveAdherentAndRelatedDataCommandHandler::class)(
new RemoveAdherentAndRelatedDataCommand(Uuid::fromString($uuid))
);

/** @var Adherent $adherent */
$adherent = $this->getAdherentRepository()->findOneByEmail($userEmail);

$this->assertNull($adherent);

/** @var Unregistration $unregistration */
$unregistration = $this->get(UnregistrationRepository::class)->findOneByUuid($uuid);
$mailHistorySubscriptions = $this->findEmailSubscriptionHistoryByAdherent($adherentBeforeUnregistration, 'subscribe');
$mailHistoryUnsubscriptions = $this->findEmailSubscriptionHistoryByAdherent($adherentBeforeUnregistration, 'unsubscribe');

$this->assertSame(\count($mailHistorySubscriptions), \count($mailHistoryUnsubscriptions));
$this->assertEmpty($unregistration->getReasons());
$this->assertNull($unregistration->getComment());
$this->assertSame($adherentBeforeUnregistration->getRegisteredAt()->format('Y-m-d H:i:s'), $unregistration->getRegisteredAt()->format('Y-m-d H:i:s'));
$this->assertSame((new \DateTime())->format('Y-m-d'), $unregistration->getUnregisteredAt()->format('Y-m-d'));
$this->assertSame($adherentBeforeUnregistration->getUuid()->toString(), $unregistration->getUuid()->toString());
$this->assertSame($adherentBeforeUnregistration->getPostalCode(), $unregistration->getPostalCode());
}

public function testBlockedCertificationRequest(): void
{
$this->authenticateAsAdherent($this->client, '[email protected]');

$crawler = $this->client->request('GET', '/espace-adherent/mon-compte/certification');
$this->assertResponseStatusCode(200, $this->client->getResponse());
$this->assertStringContainsString('Demande de certification bloquée', $crawler->filter('#certification')->text());

$this->client->request('GET', '/espace-adherent/mon-compte/certification/demande');
$this->assertClientIsRedirectedTo('/espace-adherent/mon-compte/certification', $this->client);

$this->client->followRedirect();
$this->assertResponseStatusCode(200, $this->client->getResponse());
}

public static function provideAdherentCredentials(): array
{
return [
'adherent 1' => ['[email protected]', LoadAdherentData::RENAISSANCE_USER_1_UUID],
];
}

protected function setUp(): void
{
parent::setUp();
Expand Down
56 changes: 0 additions & 56 deletions tests/Controller/Renaissance/UnregistrationControllerTest.php

This file was deleted.

0 comments on commit 3596a11

Please sign in to comment.