-
- -
-
-
- -
-
-
-
-
- {% include "regulation/_items.html.twig" with { pagination: temporaryRegulations } only %}
- {% include "common/pagination.html.twig" with {
- pagination: temporaryRegulations,
- currentPage: isTemporaryTab ? app.request.get('page', 1) : 1,
- queryParams: app.request.query.all|merge({ tab: 'temporary' }),
- } only %}
-
-
- {% include "regulation/_items.html.twig" with { pagination: permanentRegulations } only %}
- {% include "common/pagination.html.twig" with {
- pagination: permanentRegulations,
- currentPage: isPermanent ? app.request.get('page', 1) : 1,
- queryParams: app.request.query.all|merge({ tab: 'permanent' }),
- } only %}
-
+
+ {% include "regulation/_items.html.twig" with { pagination: regulations } only %}
+ {% include "common/pagination.html.twig" with {
+ pagination: regulations,
+ currentPage: app.request.get('page', 1),
+ queryParams: app.request.query.all(),
+ } only %}
{% endblock %}
diff --git a/tests/Integration/Infrastructure/Controller/Regulation/DeleteRegulationControllerTest.php b/tests/Integration/Infrastructure/Controller/Regulation/DeleteRegulationControllerTest.php
index 6133518e6..090c95d0e 100644
--- a/tests/Integration/Infrastructure/Controller/Regulation/DeleteRegulationControllerTest.php
+++ b/tests/Integration/Infrastructure/Controller/Regulation/DeleteRegulationControllerTest.php
@@ -13,52 +13,27 @@ final class DeleteRegulationControllerTest extends AbstractWebTestCase
{
use SessionHelper;
- private function countRows($crawler)
+ private function countRows($crawler): int
{
- $numTemporary = $crawler->filter('#temporary-panel tbody > tr:not([data-testid=empty-row])')->count();
- $numPermanent = $crawler->filter('#permanent-panel tbody > tr:not([data-testid=empty-row])')->count();
+ $num = $crawler->filter('.app-regulation-table tbody > tr:not([data-testid=empty-row])')->count();
- return [$numTemporary, $numPermanent];
+ return $num;
}
- public function testDeleteTemporary(): void
+ public function testDelete(): void
{
$client = $this->login();
$crawler = $client->request('GET', '/regulations');
- [$numTemporary, $numPermanent] = $this->countRows($crawler);
+ $num = $this->countRows($crawler);
$client->request('DELETE', '/regulations/' . RegulationOrderRecordFixture::UUID_TYPICAL, [
'token' => $this->generateCsrfToken($client, 'delete-regulation'),
]);
- $this->assertResponseRedirects('/regulations?tab=temporary', 303);
+ $this->assertResponseRedirects('/regulations', 303);
$crawler = $client->followRedirect();
// Doesn't appear in list of temporary regulations anymore.
- $this->assertEquals([$numTemporary - 1, $numPermanent], $this->countRows($crawler));
- }
-
- public function testDeletePermanent(): void
- {
- $client = $this->login();
-
- $client->request('GET', '/regulations/' . RegulationOrderRecordFixture::UUID_PERMANENT);
- $this->assertResponseStatusCodeSame(200);
-
- $crawler = $client->request('GET', '/regulations');
- [$numTemporary, $numPermanent] = $this->countRows($crawler);
-
- $client->request('DELETE', '/regulations/' . RegulationOrderRecordFixture::UUID_PERMANENT, [
- 'token' => $this->generateCsrfToken($client, 'delete-regulation'),
- ]);
- $this->assertResponseRedirects('/regulations?tab=permanent', 303);
- $crawler = $client->followRedirect();
-
- // Doesn't appear in list of permanent regulations anymore.
- $this->assertSame([$numTemporary, $numPermanent - 1], $this->countRows($crawler), $crawler->html());
-
- // Detail page doesn't exist anymore.
- $client->request('GET', '/regulations/' . RegulationOrderRecordFixture::UUID_PERMANENT);
- $this->assertResponseStatusCodeSame(404);
+ $this->assertEquals($num - 1, $this->countRows($crawler));
}
public function testCannotDeleteBecauseDifferentOrganization(): void
@@ -76,7 +51,7 @@ public function testRegulationOrderRecordNotFound(): void
$client->request('DELETE', '/regulations/' . RegulationOrderRecordFixture::UUID_DOES_NOT_EXIST, [
'token' => $this->generateCsrfToken($client, 'delete-regulation'),
]);
- $this->assertResponseRedirects('/regulations?tab=temporary', 303);
+ $this->assertResponseRedirects('/regulations', 303);
}
public function testInvalidCsrfToken(): void
diff --git a/tests/Integration/Infrastructure/Controller/Regulation/ListRegulationsControllerTest.php b/tests/Integration/Infrastructure/Controller/Regulation/ListRegulationsControllerTest.php
index b10a08087..dc040be58 100644
--- a/tests/Integration/Infrastructure/Controller/Regulation/ListRegulationsControllerTest.php
+++ b/tests/Integration/Infrastructure/Controller/Regulation/ListRegulationsControllerTest.php
@@ -4,17 +4,15 @@
namespace App\Tests\Integration\Infrastructure\Controller\Regulation;
-use App\Infrastructure\Persistence\Doctrine\Fixtures\RegulationOrderFixture;
use App\Infrastructure\Persistence\Doctrine\Fixtures\RegulationOrderRecordFixture;
-use App\Infrastructure\Persistence\Doctrine\Fixtures\UserFixture;
use App\Tests\Integration\Infrastructure\Controller\AbstractWebTestCase;
final class ListRegulationsControllerTest extends AbstractWebTestCase
{
- public function testPageAndTabs(): void
+ public function testNavAndPagination(): void
{
$client = $this->login();
- $crawler = $client->request('GET', '/regulations');
+ $crawler = $client->request('GET', '/regulations?pageSize=1&page=1');
$this->assertResponseStatusCodeSame(200);
$this->assertSecurityHeaders();
@@ -28,62 +26,69 @@ public function testPageAndTabs(): void
$crawler,
);
- $tabs = $crawler->filter('.fr-tabs__list')->eq(0);
- $this->assertSame('tablist', $tabs->attr('role'));
- $this->assertSame('Temporaires (' . RegulationOrderFixture::NUM_TEMPORARY . ') Permanents (' . RegulationOrderFixture::NUM_PERMANENT . ')', $tabs->text());
+ $navLi = $crawler->filter('nav.fr-pagination')->filter('li');
+ $this->assertSame('Première page', $navLi->eq(0)->filter('a')->text());
+ $this->assertSame('Page précédente', $navLi->eq(1)->filter('a')->text());
+ $this->assertSame('1', $navLi->eq(2)->filter('a')->text());
+ $this->assertSame('2', $navLi->eq(3)->filter('a')->text());
+ $this->assertSame('3', $navLi->eq(4)->filter('a')->text());
+ $this->assertSame('...', $navLi->eq(5)->text());
+ $this->assertSame('10', $navLi->eq(6)->filter('a')->text());
+ $this->assertSame('Page suivante', $navLi->eq(7)->filter('a')->text());
+ $this->assertSame('Dernière page', $navLi->eq(8)->filter('a')->text());
$client->clickLink('Ajouter un arrêté');
$this->assertRouteSame('app_regulation_add');
}
- public function testTemporaryRegulationRendering(): void
+ public function testRegulationRendering(): void
{
$client = $this->login();
// First item
- $pageOne = $client->request('GET', '/regulations?pageSize=1&tab=temporary&page=1');
+ $pageOne = $client->request('GET', '/regulations?pageSize=1&page=1');
$this->assertResponseStatusCodeSame(200);
$this->assertSecurityHeaders();
- $pageOneTemporaryRows = $pageOne->filter('#temporary-panel tbody > tr');
- $this->assertSame(1, $pageOneTemporaryRows->count());
+ $pageOneRows = $pageOne->filter('.app-regulation-table tbody > tr');
+ $this->assertSame(1, $pageOneRows->count());
- $pageOneTemporaryRow0 = $pageOneTemporaryRows->eq(0)->filter('td');
- $this->assertSame('F2023/no-locations', $pageOneTemporaryRow0->eq(0)->text());
- $this->assertSame('Main Org', $pageOneTemporaryRow0->eq(1)->text());
- $this->assertEmpty($pageOneTemporaryRow0->eq(2)->text()); // No location set
- $this->assertSame('du 13/07/2023 au 15/07/2023 passé', $pageOneTemporaryRow0->eq(3)->text());
- $this->assertSame('Brouillon', $pageOneTemporaryRow0->eq(4)->text());
+ $pageOneRow0 = $pageOneRows->eq(0)->filter('td');
+ $this->assertSame('F2023/no-locations', $pageOneRow0->eq(0)->text());
+ $this->assertSame('Main Org', $pageOneRow0->eq(1)->text());
+ $this->assertEmpty($pageOneRow0->eq(2)->text()); // No location set
+ $this->assertSame('du 13/07/2023 au 15/07/2023 passé', $pageOneRow0->eq(3)->text());
+ $this->assertSame('Brouillon', $pageOneRow0->eq(4)->text());
- $links = $pageOneTemporaryRow0->eq(5)->filter('a');
+ $links = $pageOneRow0->eq(5)->filter('a');
$this->assertSame('Modifier', $links->eq(0)->text());
$this->assertSame('http://localhost/regulations/' . RegulationOrderRecordFixture::UUID_NO_LOCATIONS, $links->eq(0)->link()->getUri());
// Second item
- $pageTwo = $client->request('GET', '/regulations?pageSize=1&tab=temporary&page=2');
+ $pageTwo = $client->request('GET', '/regulations?pageSize=1&page=2');
$this->assertResponseStatusCodeSame(200);
$this->assertSecurityHeaders();
- $pageTwoTemporaryRows = $pageTwo->filter('#temporary-panel tbody > tr');
- $this->assertSame(1, $pageTwoTemporaryRows->count()); // One item per page
+ $pageTwoRows = $pageTwo->filter('.app-regulation-table tbody > tr');
+ $this->assertSame(1, $pageTwoRows->count()); // One item per page
- $pageTwoTemporaryRow0 = $pageTwoTemporaryRows->eq(0)->filter('td');
- $this->assertSame('F/CIFS/2023', $pageTwoTemporaryRow0->eq(0)->text());
- $this->assertSame('Main Org', $pageTwoTemporaryRow0->eq(1)->text());
- $this->assertSame('Montauban (82000) Rue de la République + 1 localisation', $pageTwoTemporaryRow0->eq(2)->text());
- $this->assertSame('du 02/06/2023 au 10/06/2023 passé', $pageTwoTemporaryRow0->eq(3)->text());
- $this->assertSame('Publié', $pageTwoTemporaryRow0->eq(4)->text());
+ $pageTwoRow0 = $pageTwoRows->eq(0)->filter('td');
+ $this->assertSame('F/CIFS/2023', $pageTwoRow0->eq(0)->text());
+ $this->assertSame('Main Org', $pageTwoRow0->eq(1)->text());
+ $this->assertSame('Montauban (82000) Rue de la République + 1 localisation', $pageTwoRow0->eq(2)->text());
+ $this->assertSame('du 02/06/2023 au 10/06/2023 passé', $pageTwoRow0->eq(3)->text());
+ $this->assertSame('Publié', $pageTwoRow0->eq(4)->text());
}
public function testPublishedRegulationRendering(): void
{
$client = $this->login();
- $crawler = $client->request('GET', '/regulations?pageSize=1&tab=temporary&page=5');
+ $crawler = $client->request('GET', '/regulations?pageSize=1&page=6');
$this->assertResponseStatusCodeSame(200);
$this->assertSecurityHeaders();
- $rows = $crawler->filter('#temporary-panel tbody > tr');
+ $rows = $crawler->filter('.app-regulation-table tbody > tr');
$this->assertSame(1, $rows->count());
$row0 = $rows->eq(0)->filter('td');
@@ -98,73 +103,6 @@ public function testPublishedRegulationRendering(): void
$this->assertSame('http://localhost/regulations/' . RegulationOrderRecordFixture::UUID_PUBLISHED, $links->eq(0)->link()->getUri());
}
- public function testPermanentRegulationRendering(): void
- {
- $client = $this->login();
- $pageOne = $client->request('GET', '/regulations?pageSize=1&tab=permanent&page=1');
- $this->assertResponseStatusCodeSame(200);
- $this->assertSecurityHeaders();
-
- $pageOnePermanentRows = $pageOne->filter('#permanent-panel tbody > tr');
- $this->assertSame(1, $pageOnePermanentRows->count());
-
- $pageOnePermanentRow0 = $pageOnePermanentRows->eq(0)->filter('td');
- $this->assertSame('FO3/2023', $pageOnePermanentRow0->eq(0)->text());
- $this->assertSame('Main Org', $pageOnePermanentRow0->eq(1)->text());
- $this->assertSame('Paris 18e Arrondissement (75018) Rue du Simplon', $pageOnePermanentRow0->eq(2)->text());
- $this->assertSame('à partir du 11/03/2023 en cours', $pageOnePermanentRow0->eq(3)->text());
- $this->assertSame('Brouillon', $pageOnePermanentRow0->eq(4)->text());
-
- $links = $pageOnePermanentRow0->eq(5)->filter('a');
- $this->assertSame('Modifier', $links->eq(0)->text());
- $this->assertSame('http://localhost/regulations/' . RegulationOrderRecordFixture::UUID_PERMANENT, $links->eq(0)->link()->getUri());
- }
-
- public function testPaginationRendering(): void
- {
- $client = $this->login();
- $pageOne = $client->request('GET', '/regulations?pageSize=1&tab=temporary&page=1');
- $this->assertResponseStatusCodeSame(200);
- $this->assertSecurityHeaders();
-
- $navLi = $pageOne->filter('nav.fr-pagination')->filter('li');
- $this->assertSame('Première page', $navLi->eq(0)->filter('a')->text());
- $this->assertSame('Page précédente', $navLi->eq(1)->filter('a')->text());
- $this->assertSame('1', $navLi->eq(2)->filter('a')->text());
- $this->assertSame('2', $navLi->eq(3)->filter('a')->text());
- $this->assertSame('3', $navLi->eq(4)->filter('a')->text());
- $this->assertSame('...', $navLi->eq(5)->text());
- $this->assertSame((string) RegulationOrderFixture::NUM_TEMPORARY, $navLi->eq(6)->filter('a')->text());
- $this->assertSame('Page suivante', $navLi->eq(7)->filter('a')->text());
- $this->assertSame('Dernière page', $navLi->eq(8)->filter('a')->text());
- }
-
- public function testListWithOtherOrganization(): void
- {
- $client = $this->login(UserFixture::OTHER_ORG_USER_EMAIL);
- $pageOne = $client->request('GET', '/regulations');
- $this->assertResponseStatusCodeSame(200);
- $this->assertSecurityHeaders();
-
- $tabs = $pageOne->filter('.fr-tabs__list')->eq(0);
- $this->assertSame('tablist', $tabs->attr('role'));
- $this->assertSame('Temporaires (4) Permanents (1)', $tabs->text());
-
- $pageOnePermanentRows = $pageOne->filter('#permanent-panel tbody > tr');
- $this->assertSame(1, $pageOnePermanentRows->count()); // One item per page
-
- $pageOnePermanentRow0 = $pageOnePermanentRows->eq(0)->filter('td');
- $this->assertSame('FO4/2023', $pageOnePermanentRow0->eq(0)->text());
- $this->assertSame('Mairie de Savenay', $pageOnePermanentRow0->eq(1)->text());
- $this->assertEmpty($pageOnePermanentRow0->eq(2)->text()); // No location set
- $this->assertEmpty($pageOnePermanentRow0->eq(3)->text()); // No period set
- $this->assertSame('Brouillon', $pageOnePermanentRow0->eq(4)->text());
-
- $links = $pageOnePermanentRow0->eq(5)->filter('a');
- $this->assertSame('Modifier', $links->eq(0)->text());
- $this->assertSame('http://localhost/regulations/' . RegulationOrderRecordFixture::UUID_OTHER_ORG, $links->eq(0)->link()->getUri());
- }
-
public function testInvalidPageSize(): void
{
$client = $this->login();
@@ -198,12 +136,8 @@ public function testWithoutAuthenticatedUser(): void
$this->assertResponseStatusCodeSame(200);
- $tabs = $pageOne->filter('.fr-tabs__list')->eq(0);
- $this->assertSame('tablist', $tabs->attr('role'));
- $this->assertSame('Temporaires (4) Permanents (0)', $tabs->text());
-
// check that the only link of the first row is to view the regulation
- $rows = $pageOne->filter('#temporary-panel tbody > tr');
+ $rows = $pageOne->filter('.app-regulation-table tbody > tr');
$row = $rows->eq(0)->filter('td');
$links = $row->filter('a');
$this->assertCount(1, $links);
diff --git a/tests/Integration/Infrastructure/Controller/Regulation/RegulationDetailControllerTest.php b/tests/Integration/Infrastructure/Controller/Regulation/RegulationDetailControllerTest.php
index 1fa55e9a4..213132025 100644
--- a/tests/Integration/Infrastructure/Controller/Regulation/RegulationDetailControllerTest.php
+++ b/tests/Integration/Infrastructure/Controller/Regulation/RegulationDetailControllerTest.php
@@ -79,7 +79,7 @@ public function testDraftRegulationDetailAsAdmin(): void
// Go back link
$goBackLink = $crawler->selectLink('Revenir aux arrêtés');
- $this->assertSame('/regulations?tab=temporary', $goBackLink->extract(['href'])[0]);
+ $this->assertSame('/regulations', $goBackLink->extract(['href'])[0]);
}
public function testDraftRegulationDetailAsContributor(): void
@@ -101,7 +101,7 @@ public function testPermanentRegulationDetail(): void
$this->assertMetaTitle('Arrêté permanent FO3/2023 - DiaLog', $crawler);
$goBackLink = $crawler->selectLink('Revenir aux arrêtés');
- $this->assertSame('/regulations?tab=permanent', $goBackLink->extract(['href'])[0]);
+ $this->assertSame('/regulations', $goBackLink->extract(['href'])[0]);
}
public function testDraftRegulationDetailWithoutLocations(): void
@@ -138,22 +138,6 @@ public function testPublishedRegulationDetail(): void
$this->assertSame($formDelete->getMethod(), 'DELETE');
}
- public function testSeeAll(): void
- {
- $client = $this->login();
- $client->request('GET', '/regulations/' . RegulationOrderRecordFixture::UUID_TYPICAL);
-
- $this->assertSecurityHeaders();
- $this->assertResponseStatusCodeSame(200);
-
- $crawler = $client->clickLink('Arrêtés de circulation');
- $this->assertRouteSame('app_regulations_list');
-
- // Temporary regulation order list is shown.
- $temporaryPanel = $crawler->filter('#temporary-panel');
- $this->assertStringContainsString('fr-tabs__panel--selected', $temporaryPanel->attr('class'));
- }
-
public function testCannotAccessBecauseDifferentOrganization(): void
{
$client = $this->login(UserFixture::OTHER_ORG_USER_EMAIL);
diff --git a/tests/Unit/Application/Regulation/Query/GetRegulationsQueryHandlerTest.php b/tests/Unit/Application/Regulation/Query/GetRegulationsQueryHandlerTest.php
index 9ff6d82e0..d08538daf 100644
--- a/tests/Unit/Application/Regulation/Query/GetRegulationsQueryHandlerTest.php
+++ b/tests/Unit/Application/Regulation/Query/GetRegulationsQueryHandlerTest.php
@@ -64,7 +64,7 @@ public function testGetAll(): void
$regulationOrderRecordRepository
->expects(self::once())
->method('findAllRegulations')
- ->with(20, 1, true, ['dcab837f-4460-4355-99d5-bf4891c35f8f'])
+ ->with(20, 1, ['dcab837f-4460-4355-99d5-bf4891c35f8f'])
->willReturn([
'count' => 3,
'items' => $rows,
@@ -74,7 +74,6 @@ public function testGetAll(): void
$regulationOrders = $handler(new GetRegulationsQuery(
pageSize: 20,
page: 1,
- isPermanent: true,
organizationUuids: ['dcab837f-4460-4355-99d5-bf4891c35f8f'],
));