Skip to content

Commit

Permalink
Add admin link (#965)
Browse files Browse the repository at this point in the history
  • Loading branch information
mmarchois authored Sep 19, 2024
1 parent 08b0120 commit d37d907
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions templates/my_area/index.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
<p>{{ 'user.myarea.description'|trans }}</p>
</div>
<div class="fr-mb-3w">
{% if is_granted('ROLE_SUPER_ADMIN') %}
<a class="fr-btn fr-btn--icon-left fr-icon-settings-5-line fr-btn--secondary" href="{{ path('app_admin') }}" data-testid="admin-link">
{{ 'common.admin'|trans }}
</a>
{% endif %}
<a class="fr-btn fr-btn--icon-left fr-icon-logout-box-r-line fr-btn--secondary" href="{{ path('app_logout') }}" data-testid="logout-link">
{{ 'common.logout'|trans }}
</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace App\Tests\Integration\Infrastructure\Controller\MyArea;

use App\Infrastructure\Persistence\Doctrine\Fixtures\UserFixture;
use App\Tests\Integration\Infrastructure\Controller\AbstractWebTestCase;

final class IndexControllerTest extends AbstractWebTestCase
Expand All @@ -21,6 +22,16 @@ public function testIndex(): void
$organizations = $crawler->filter('[data-testid="organization-list"]');
$this->assertCount(1, $organizations->filter('[data-testid="organization-detail"]'));
$this->assertSame('Main Org Contributeur', $organizations->filter('[data-testid="organization-detail"]')->text());
$this->assertCount(0, $crawler->filter('[data-testid="admin-link"]'));
}

public function testIndexAsAdmin(): void
{
$client = $this->login(UserFixture::MAIN_ORG_ADMIN_EMAIL);
$crawler = $client->request('GET', '/mon-espace');

$this->assertResponseStatusCodeSame(200);
$this->assertCount(1, $crawler->filter('[data-testid="admin-link"]'));
}

public function testWithoutAuthenticatedUser(): void
Expand Down
4 changes: 4 additions & 0 deletions translations/messages.fr.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
<source>common.blog</source>
<target>Blog</target>
</trans-unit>
<trans-unit id="common.admin">
<source>common.admin</source>
<target>Administration</target>
</trans-unit>
<trans-unit id="common.and">
<source>common.and</source>
<target>et</target>
Expand Down

0 comments on commit d37d907

Please sign in to comment.