- h1 unique par page : les 18 titres de page (Typo.h4) deviennent h1, rendant FocusOnNavigate Selector="h1" opérationnel ; les h4 de sections/stats (Dashboard) sont conservés. - Skip-link réel dans MainLayout (lien vers #main-content) + id sur le conteneur principal. - aria-label sur les 16 icon-buttons sans nom accessible (tooltip ne suffit pas) : refresh, delete, edit, visibility, snapshot, restore, download. - Tests a11y automatisés (A11yPageTests) : un seul h1 par page (Events, Dashboard, Cameras), aria-label sur tous les icon-buttons, skip-link présent dans le layout. 172 tests Web verts.
93 lines
3.1 KiB
C#
93 lines
3.1 KiB
C#
using Bunit;
|
|
using Heimdall.Web.Components.Layout;
|
|
using Heimdall.Web.Components.Pages;
|
|
using Heimdall.Web.Services;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Shouldly;
|
|
|
|
namespace Heimdall.Web.Tests.Components.Pages;
|
|
|
|
/// <summary>
|
|
/// A11y smoke tests (WCAG 2.2) — vérifie les invariants transverses posés
|
|
/// par l'issue #41 : un h1 par page (FocusOnNavigate cible h1), skip-link
|
|
/// dans le layout, aria-label sur les icon-buttons (le tooltip ne suffit pas).
|
|
/// </summary>
|
|
public class A11yPageTests : PageTestBase
|
|
{
|
|
private static readonly Guid SiteId = Guid.NewGuid();
|
|
private static readonly Guid CameraId = Guid.NewGuid();
|
|
|
|
[Fact]
|
|
public void EventsPage_AUnSeulH1()
|
|
{
|
|
Handler.OnGet("api/events", new EventPageResult([], 0, 1, 50));
|
|
LoginAs();
|
|
|
|
var cut = RenderPage<EventsPage>();
|
|
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Événements"));
|
|
|
|
cut.FindAll("h1").Count.ShouldBe(1);
|
|
}
|
|
|
|
[Fact]
|
|
public void DashboardPage_AUnSeulH1()
|
|
{
|
|
Handler.OnGet("api/stats", new StatsResult(0, 0, 0, 0, 0, 0, 0, 0, 0));
|
|
Handler.OnGet("api/sites", new PagedData<SiteItem>([], 0, 1, 5));
|
|
Handler.OnGet("api/agents", new PagedData<AgentItem>([], 0, 1, 5));
|
|
Handler.OnGet("api/events", new EventPageResult([], 0, 1, 10));
|
|
LoginAs();
|
|
|
|
var cut = RenderPage<Dashboard>();
|
|
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Dashboard"));
|
|
|
|
cut.FindAll("h1").Count.ShouldBe(1);
|
|
// Le titre de page est le seul h1 ; les compteurs de stats restent des h4
|
|
cut.FindAll("h4").Count.ShouldBeGreaterThan(0);
|
|
}
|
|
|
|
[Fact]
|
|
public void CamerasPage_AUnSeulH1()
|
|
{
|
|
Handler.OnGet("api/cameras/by-site", new PagedData<CameraItem>([], 0, 1, 20));
|
|
LoginAs();
|
|
|
|
var cut = RenderPage<CamerasPage>(p => p.Add(x => x.SiteId, SiteId));
|
|
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Caméras"));
|
|
|
|
cut.FindAll("h1").Count.ShouldBe(1);
|
|
}
|
|
|
|
[Fact]
|
|
public void IconButtons_SansTooltip_OntUnAriaLabel()
|
|
{
|
|
Handler.OnGet("api/events", new EventPageResult([], 0, 1, 50));
|
|
LoginAs();
|
|
|
|
var cut = RenderPage<EventsPage>();
|
|
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Événements"));
|
|
|
|
var buttons = cut.FindAll("button.mud-icon-button");
|
|
foreach (var btn in buttons)
|
|
{
|
|
btn.HasAttribute("aria-label").ShouldBeTrue(
|
|
$"Icon-button sans aria-label : {btn.OuterHtml[..Math.Min(120, btn.OuterHtml.Length)]}");
|
|
}
|
|
}
|
|
|
|
[Fact]
|
|
public void MainLayout_ContientSkipLinkVersMainContent()
|
|
{
|
|
// Le skip-link vit dans MainLayout ; on rend le layout directement
|
|
// (RenderPage<T> rend la page sans son layout).
|
|
LoginAs();
|
|
|
|
var cut = Render<MainLayout>();
|
|
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Heimdall"));
|
|
|
|
cut.Markup.ShouldContain("class=\"skip-link\"");
|
|
cut.Markup.ShouldContain("Aller au contenu principal");
|
|
cut.Markup.ShouldContain("id=\"main-content\"");
|
|
}
|
|
}
|