2026-08-11 09:20:31 +02:00
|
|
|
using Bunit;
|
|
|
|
|
using Bunit.TestDoubles;
|
|
|
|
|
using Heimdall.Web.Components.Layout;
|
|
|
|
|
using Heimdall.Web.Services;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using Shouldly;
|
|
|
|
|
|
|
|
|
|
namespace Heimdall.Web.Tests.Components.Pages;
|
|
|
|
|
|
|
|
|
|
public class NavigationTests : PageTestBase
|
|
|
|
|
{
|
2026-11-09 10:10:22 +01:00
|
|
|
[Fact]
|
|
|
|
|
public void MainLayout_AfficheVersionDuServeur()
|
|
|
|
|
{
|
|
|
|
|
Handler.OnGet("api/version", new { version = "0.0.0-ci.abcdef123456" });
|
|
|
|
|
Services.GetRequiredService<BunitNavigationManager>()
|
|
|
|
|
.NavigateTo("http://localhost/dashboard");
|
|
|
|
|
|
|
|
|
|
var cut = Render<MainLayout>();
|
|
|
|
|
|
|
|
|
|
cut.WaitForAssertion(() => cut.Find("[data-testid='server-version']")
|
|
|
|
|
.TextContent.ShouldContain("0.0.0-ci.abcdef123456"));
|
|
|
|
|
}
|
|
|
|
|
|
2026-08-11 09:20:31 +02:00
|
|
|
[Fact]
|
|
|
|
|
public void MainLayout_Admin_VoitSousMenuGestionUtilisateurs()
|
|
|
|
|
{
|
|
|
|
|
LoginAs();
|
|
|
|
|
Services.GetRequiredService<BunitNavigationManager>()
|
|
|
|
|
.NavigateTo("http://localhost/dashboard");
|
|
|
|
|
|
|
|
|
|
var cut = Render<MainLayout>();
|
|
|
|
|
|
|
|
|
|
cut.Markup.ShouldContain("Gestion des utilisateurs");
|
|
|
|
|
// Sur /dashboard, le groupe est replié (aria-expanded=false).
|
|
|
|
|
var group = cut.FindAll(".mud-nav-group").FirstOrDefault(b => b.TextContent.Contains("Gestion des utilisateurs"));
|
|
|
|
|
group.ShouldNotBeNull();
|
|
|
|
|
group!.OuterHtml.ShouldContain("aria-expanded=\"false\"");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void MainLayout_SurPageUtilisateurs_DeplieLeSousMenu()
|
|
|
|
|
{
|
|
|
|
|
LoginAs();
|
|
|
|
|
Services.GetRequiredService<BunitNavigationManager>()
|
|
|
|
|
.NavigateTo("http://localhost/users");
|
|
|
|
|
|
|
|
|
|
var cut = Render<MainLayout>();
|
|
|
|
|
|
|
|
|
|
// Sur /users, le sous-menu est déplié (aria-expanded=true).
|
|
|
|
|
cut.Markup.ShouldContain("Gestion des utilisateurs");
|
|
|
|
|
var group = cut.FindAll(".mud-nav-group").FirstOrDefault(b => b.TextContent.Contains("Gestion des utilisateurs"));
|
|
|
|
|
group.ShouldNotBeNull();
|
|
|
|
|
group!.OuterHtml.ShouldContain("aria-expanded=\"true\"");
|
|
|
|
|
cut.Markup.ShouldContain("href=\"/users\"");
|
|
|
|
|
cut.Markup.ShouldContain("href=\"/admin/groups\"");
|
|
|
|
|
cut.Markup.ShouldContain("href=\"/admin/roles\"");
|
|
|
|
|
cut.Markup.ShouldContain("href=\"/admin/claims\"");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void MainLayout_Viewer_NeVoitPasLeSousMenuAdmin()
|
|
|
|
|
{
|
|
|
|
|
LoginAs("Viewer");
|
|
|
|
|
Services.GetRequiredService<BunitNavigationManager>()
|
|
|
|
|
.NavigateTo("http://localhost/dashboard");
|
|
|
|
|
|
|
|
|
|
var cut = Render<MainLayout>();
|
|
|
|
|
|
|
|
|
|
cut.Markup.ShouldNotContain("Gestion des utilisateurs");
|
|
|
|
|
cut.Markup.ShouldNotContain("href=\"/users\"");
|
|
|
|
|
cut.Markup.ShouldNotContain("href=\"/admin/agents\"");
|
|
|
|
|
}
|
2026-10-10 17:50:33 +02:00
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void MainLayout_AfficheLienPersonnes()
|
|
|
|
|
{
|
|
|
|
|
LoginAs();
|
|
|
|
|
Services.GetRequiredService<BunitNavigationManager>()
|
|
|
|
|
.NavigateTo("http://localhost/dashboard");
|
|
|
|
|
|
|
|
|
|
var cut = Render<MainLayout>();
|
|
|
|
|
|
|
|
|
|
cut.Markup.ShouldContain("href=\"/persons\"");
|
|
|
|
|
cut.Markup.ShouldContain("Personnes");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void MainLayout_SurPagePersonnes_LienActif()
|
|
|
|
|
{
|
|
|
|
|
LoginAs();
|
|
|
|
|
Services.GetRequiredService<BunitNavigationManager>()
|
|
|
|
|
.NavigateTo("http://localhost/persons");
|
|
|
|
|
|
|
|
|
|
var cut = Render<MainLayout>();
|
|
|
|
|
|
|
|
|
|
var link = cut.FindAll(".mud-nav-link").FirstOrDefault(b => b.TextContent.Contains("Personnes"));
|
|
|
|
|
link.ShouldNotBeNull();
|
|
|
|
|
link!.OuterHtml.ShouldContain("active");
|
|
|
|
|
}
|
2026-08-11 09:20:31 +02:00
|
|
|
}
|