2026-08-10 12:46:15 +02:00
|
|
|
|
using Bunit;
|
|
|
|
|
|
using Bunit.TestDoubles;
|
|
|
|
|
|
using Heimdall.Web.Components.Pages;
|
|
|
|
|
|
using Heimdall.Web.Services;
|
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
|
using MudBlazor;
|
|
|
|
|
|
using Shouldly;
|
2026-11-06 11:14:49 +01:00
|
|
|
|
using YamlDotNet.RepresentationModel;
|
2026-08-10 12:46:15 +02:00
|
|
|
|
|
|
|
|
|
|
namespace Heimdall.Web.Tests.Components.Pages;
|
|
|
|
|
|
|
|
|
|
|
|
public class SiteDetailTests : PageTestBase
|
|
|
|
|
|
{
|
|
|
|
|
|
private static readonly Guid SiteId = Guid.NewGuid();
|
|
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
|
public void SiteDetail_AfficheInformations()
|
|
|
|
|
|
{
|
|
|
|
|
|
Handler.OnGet("api/sites/", new SiteItem(
|
2026-08-27 18:56:57 +02:00
|
|
|
|
SiteId, "Site Principal", "12 rue des Caméras", "Europe/Paris", null, true, false, DateTime.UtcNow.AddDays(-10)));
|
2026-08-10 12:46:15 +02:00
|
|
|
|
LoginAs();
|
|
|
|
|
|
|
|
|
|
|
|
var cut = RenderPage<SiteDetail>(p => p.Add(x => x.Id, SiteId));
|
|
|
|
|
|
|
|
|
|
|
|
cut.WaitForAssertion(() =>
|
|
|
|
|
|
{
|
|
|
|
|
|
cut.Markup.ShouldContain("Site : Site Principal");
|
|
|
|
|
|
cut.Markup.ShouldContain("12 rue des Caméras");
|
|
|
|
|
|
cut.Markup.ShouldContain("Europe/Paris");
|
|
|
|
|
|
cut.Markup.ShouldContain("● Actif");
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
|
public void SiteDetail_SiteIntrouvable_AfficheAlerte()
|
|
|
|
|
|
{
|
|
|
|
|
|
Handler.OnGet("api/sites/", System.Net.HttpStatusCode.NotFound);
|
|
|
|
|
|
LoginAs();
|
|
|
|
|
|
|
|
|
|
|
|
var cut = RenderPage<SiteDetail>(p => p.Add(x => x.Id, SiteId));
|
|
|
|
|
|
|
|
|
|
|
|
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Site introuvable"));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
|
public void SiteDetail_GenererToken_AfficheDockerCompose()
|
|
|
|
|
|
{
|
2026-10-23 18:58:06 +02:00
|
|
|
|
Handler.OnGet("api/updates/latest", AgentRelease());
|
2026-08-10 12:46:15 +02:00
|
|
|
|
Handler.OnGet("api/sites/", new SiteItem(
|
2026-08-27 18:56:57 +02:00
|
|
|
|
SiteId, "Site Principal", null, "UTC", null, true, false, DateTime.UtcNow.AddDays(-10)));
|
2026-08-10 12:46:15 +02:00
|
|
|
|
Handler.On(HttpMethod.Post, "api/sites/", new TokenResult("tok-detail-42", DateTime.UtcNow.AddHours(24)));
|
|
|
|
|
|
LoginAs();
|
|
|
|
|
|
|
|
|
|
|
|
var cut = RenderPage<SiteDetail>(p => p.Add(x => x.Id, SiteId));
|
|
|
|
|
|
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Générer un token"));
|
|
|
|
|
|
|
|
|
|
|
|
cut.FindAll("button").Single(b => b.TextContent.Contains("Générer un token")).Click();
|
2026-10-26 12:15:21 +01:00
|
|
|
|
cut.WaitForAssertion(() => cut.Markup.ShouldContain("tok-detail-42"));
|
|
|
|
|
|
cut.FindAll("button").Single(b => b.TextContent.Contains("Docker", StringComparison.OrdinalIgnoreCase)).Click();
|
2026-08-10 12:46:15 +02:00
|
|
|
|
|
|
|
|
|
|
cut.WaitForAssertion(() =>
|
|
|
|
|
|
{
|
|
|
|
|
|
cut.Markup.ShouldContain("Docker Compose");
|
2026-08-10 15:29:35 +02:00
|
|
|
|
cut.Markup.ShouldContain("Agent__SiteToken");
|
2026-08-10 12:46:15 +02:00
|
|
|
|
cut.Markup.ShouldContain("Régénérer");
|
2026-10-26 05:59:55 +01:00
|
|
|
|
var compose = cut.Find("pre code").TextContent;
|
|
|
|
|
|
compose.ShouldContain("registry.example/heimdall-agent@sha256:");
|
|
|
|
|
|
compose.ShouldContain("network_mode: host");
|
2026-11-04 20:55:14 +01:00
|
|
|
|
compose.ShouldContain("Agent__CentralUrl: \"http://localhost\"");
|
2026-10-26 12:26:22 +01:00
|
|
|
|
compose.ShouldContain("Agent__SiteToken: \"tok-detail-42\"");
|
2026-11-06 11:14:49 +01:00
|
|
|
|
compose.ShouldContain("Agent__InferenceExecutionProvider: CPU");
|
|
|
|
|
|
compose.ShouldNotContain("driver: nvidia");
|
|
|
|
|
|
compose.ShouldNotContain("--gpus");
|
2026-10-26 05:59:55 +01:00
|
|
|
|
compose.ShouldNotContain("postgresql");
|
|
|
|
|
|
compose.ShouldNotContain("ollama");
|
2026-11-06 11:14:49 +01:00
|
|
|
|
var agent = GetAgentService(ParseCompose(compose));
|
|
|
|
|
|
agent.Children.ShouldNotContainKey(new YamlScalarNode("deploy"));
|
|
|
|
|
|
var environment = (YamlMappingNode)agent.Children[new YamlScalarNode("environment")];
|
|
|
|
|
|
((YamlScalarNode)environment.Children[new YamlScalarNode("Agent__InferenceExecutionProvider")]).Value.ShouldBe("CPU");
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
|
public void SiteDetail_ChoisirImageNvidia_GenereComposeAvecGpuEtProviderCuda()
|
|
|
|
|
|
{
|
|
|
|
|
|
Handler.OnGet("api/updates/latest", AgentReleaseWithGpu());
|
|
|
|
|
|
Handler.OnGet("api/sites/", new SiteItem(
|
|
|
|
|
|
SiteId, "Site Principal", null, "UTC", null, true, false, DateTime.UtcNow.AddDays(-10)));
|
|
|
|
|
|
Handler.On(HttpMethod.Post, "api/sites/", new TokenResult("tok-detail-gpu", DateTime.UtcNow.AddHours(24)));
|
|
|
|
|
|
LoginAs();
|
|
|
|
|
|
|
|
|
|
|
|
var cut = RenderPage<SiteDetail>(p => p.Add(x => x.Id, SiteId));
|
|
|
|
|
|
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Générer un token"));
|
|
|
|
|
|
cut.FindAll("button").Single(b => b.TextContent.Contains("Générer un token")).Click();
|
|
|
|
|
|
cut.WaitForAssertion(() => cut.Markup.ShouldContain("tok-detail-gpu"));
|
|
|
|
|
|
cut.FindAll("button").Single(b => b.TextContent.Contains("Docker", StringComparison.OrdinalIgnoreCase)).Click();
|
|
|
|
|
|
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Utiliser l’inférence GPU NVIDIA"));
|
|
|
|
|
|
|
|
|
|
|
|
cut.Find("input[type=checkbox]").Change(true);
|
|
|
|
|
|
cut.WaitForAssertion(() =>
|
|
|
|
|
|
{
|
|
|
|
|
|
var compose = cut.Find("pre code").TextContent;
|
|
|
|
|
|
compose.ShouldContain("image: registry.example/heimdall-agent-gpu@sha256:" + new string('b', 64));
|
|
|
|
|
|
compose.ShouldContain("Agent__InferenceExecutionProvider: CUDA");
|
|
|
|
|
|
compose.ShouldContain("driver: nvidia");
|
|
|
|
|
|
compose.ShouldContain("capabilities: [gpu]");
|
|
|
|
|
|
compose.ShouldContain("\n deploy:\n resources:\n reservations:");
|
|
|
|
|
|
var agent = GetAgentService(ParseCompose(compose));
|
|
|
|
|
|
((YamlScalarNode)agent.Children[new YamlScalarNode("image")]).Value.ShouldBe(
|
|
|
|
|
|
"registry.example/heimdall-agent-gpu@sha256:" + new string('b', 64));
|
|
|
|
|
|
var deploy = (YamlMappingNode)agent.Children[new YamlScalarNode("deploy")];
|
|
|
|
|
|
var resources = (YamlMappingNode)deploy.Children[new YamlScalarNode("resources")];
|
|
|
|
|
|
var reservations = (YamlMappingNode)resources.Children[new YamlScalarNode("reservations")];
|
|
|
|
|
|
var devices = (YamlSequenceNode)reservations.Children[new YamlScalarNode("devices")];
|
|
|
|
|
|
((YamlScalarNode)((YamlMappingNode)devices.Children[0]).Children[new YamlScalarNode("driver")]).Value.ShouldBe("nvidia");
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
cut.FindAll("button").Single(b => b.TextContent.Contains("Docker Run", StringComparison.OrdinalIgnoreCase)).Click();
|
|
|
|
|
|
cut.WaitForAssertion(() =>
|
|
|
|
|
|
{
|
|
|
|
|
|
var commands = cut.FindAll("pre code").Select(code => code.TextContent).ToArray();
|
|
|
|
|
|
var run = commands[1];
|
|
|
|
|
|
run.ShouldContain("--gpus all");
|
|
|
|
|
|
run.ShouldContain("Agent__InferenceExecutionProvider=CUDA");
|
|
|
|
|
|
run.ShouldContain("registry.example/heimdall-agent-gpu@sha256:" + new string('b', 64));
|
2026-08-10 12:46:15 +02:00
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
|
public void SiteDetail_CopierDockerCompose_AppellePressePapier()
|
|
|
|
|
|
{
|
2026-10-23 18:58:06 +02:00
|
|
|
|
Handler.OnGet("api/updates/latest", AgentRelease());
|
2026-08-10 12:46:15 +02:00
|
|
|
|
Handler.OnGet("api/sites/", new SiteItem(
|
2026-08-27 18:56:57 +02:00
|
|
|
|
SiteId, "Site Principal", null, "UTC", null, true, false, DateTime.UtcNow.AddDays(-10)));
|
2026-08-10 12:46:15 +02:00
|
|
|
|
Handler.On(HttpMethod.Post, "api/sites/", new TokenResult("tok-detail-42", DateTime.UtcNow.AddHours(24)));
|
|
|
|
|
|
JSInterop.SetupVoid("navigator.clipboard.writeText", _ => true).SetVoidResult();
|
|
|
|
|
|
LoginAs();
|
|
|
|
|
|
|
|
|
|
|
|
var cut = RenderPage<SiteDetail>(p => p.Add(x => x.Id, SiteId));
|
|
|
|
|
|
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Générer un token"));
|
|
|
|
|
|
cut.FindAll("button").Single(b => b.TextContent.Contains("Générer un token")).Click();
|
2026-10-26 12:15:21 +01:00
|
|
|
|
cut.WaitForAssertion(() => cut.Markup.ShouldContain("tok-detail-42"));
|
|
|
|
|
|
cut.FindAll("button").Single(b => b.TextContent.Contains("Docker", StringComparison.OrdinalIgnoreCase)).Click();
|
2026-08-10 15:29:35 +02:00
|
|
|
|
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Copier le docker-compose.yml"));
|
2026-08-10 12:46:15 +02:00
|
|
|
|
|
2026-08-10 15:29:35 +02:00
|
|
|
|
cut.FindAll("button").Single(b => b.TextContent.Contains("Copier le docker-compose.yml")).Click();
|
2026-08-10 12:46:15 +02:00
|
|
|
|
|
|
|
|
|
|
cut.WaitForAssertion(() =>
|
|
|
|
|
|
{
|
|
|
|
|
|
JSInterop.VerifyInvoke("navigator.clipboard.writeText");
|
|
|
|
|
|
var snackbar = Services.GetRequiredService<ISnackbar>();
|
|
|
|
|
|
snackbar.ShownSnackbars.Select(m => m.Message?.ToString() ?? "").ShouldContain(m => m.Contains("copié", StringComparison.OrdinalIgnoreCase));
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
|
public void SiteDetail_NavigationCameras_Redirige()
|
|
|
|
|
|
{
|
|
|
|
|
|
Handler.OnGet("api/sites/", new SiteItem(
|
2026-08-27 18:56:57 +02:00
|
|
|
|
SiteId, "Site Principal", null, "UTC", null, true, false, DateTime.UtcNow.AddDays(-10)));
|
2026-08-10 12:46:15 +02:00
|
|
|
|
LoginAs();
|
|
|
|
|
|
|
|
|
|
|
|
var nav = Services.GetRequiredService<BunitNavigationManager>();
|
|
|
|
|
|
var cut = RenderPage<SiteDetail>(p => p.Add(x => x.Id, SiteId));
|
|
|
|
|
|
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Caméras"));
|
|
|
|
|
|
|
|
|
|
|
|
cut.FindAll("div") // la MudPaper avec @onclick navigation
|
|
|
|
|
|
.First(d => d.ClassList.Contains("mud-paper") && d.TextContent.Contains("Caméras"))
|
|
|
|
|
|
.Click();
|
|
|
|
|
|
|
|
|
|
|
|
cut.WaitForAssertion(() => nav.Uri.ShouldBe($"http://localhost/sites/{SiteId}/cameras"));
|
|
|
|
|
|
}
|
2026-08-11 16:15:41 +02:00
|
|
|
|
|
|
|
|
|
|
// ─── Identifiants caméras (pool de credentials) ────────────────────
|
|
|
|
|
|
|
|
|
|
|
|
private static SiteCredentialItem Credential(string label, string username, DateTime? lastUsed = null) => new()
|
|
|
|
|
|
{
|
|
|
|
|
|
Id = Guid.NewGuid(),
|
|
|
|
|
|
SiteId = SiteId,
|
|
|
|
|
|
Label = label,
|
|
|
|
|
|
Username = username,
|
|
|
|
|
|
CreatedAt = DateTime.UtcNow.AddDays(-3),
|
|
|
|
|
|
LastUsedAt = lastUsed,
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2026-10-23 18:58:06 +02:00
|
|
|
|
private static LatestReleaseInfo AgentRelease() => new()
|
|
|
|
|
|
{
|
|
|
|
|
|
Version = "1.0.0",
|
|
|
|
|
|
ContainerImage = "registry.example/heimdall-agent",
|
2026-10-26 12:15:21 +01:00
|
|
|
|
ContainerImageDigest = "sha256:" + new string('a', 64),
|
|
|
|
|
|
UpdatePublicKeyPem = "test-public-key"
|
2026-10-23 18:58:06 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
2026-11-06 11:14:49 +01:00
|
|
|
|
private static LatestReleaseInfo AgentReleaseWithGpu() => new()
|
|
|
|
|
|
{
|
|
|
|
|
|
Version = "1.0.0",
|
|
|
|
|
|
ContainerImage = "registry.example/heimdall-agent",
|
|
|
|
|
|
ContainerImageDigest = "sha256:" + new string('a', 64),
|
|
|
|
|
|
ContainerImageGpu = "registry.example/heimdall-agent-gpu",
|
|
|
|
|
|
ContainerImageGpuDigest = "sha256:" + new string('b', 64),
|
|
|
|
|
|
UpdatePublicKeyPem = "test-public-key"
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
private static YamlMappingNode ParseCompose(string compose)
|
|
|
|
|
|
{
|
|
|
|
|
|
var stream = new YamlStream();
|
|
|
|
|
|
stream.Load(new StringReader(compose));
|
|
|
|
|
|
return (YamlMappingNode)stream.Documents[0].RootNode;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private static YamlMappingNode GetAgentService(YamlMappingNode root)
|
|
|
|
|
|
{
|
|
|
|
|
|
var services = (YamlMappingNode)root.Children[new YamlScalarNode("services")];
|
|
|
|
|
|
return (YamlMappingNode)services.Children[new YamlScalarNode("heimdall-agent")];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-08-11 16:15:41 +02:00
|
|
|
|
[Fact]
|
|
|
|
|
|
public void SiteDetail_AucunIdentifiant_AfficheMessage()
|
|
|
|
|
|
{
|
|
|
|
|
|
// Routes spécifiques AVANT la route générique (le handler matche par substring).
|
|
|
|
|
|
Handler.OnGet($"api/sites/{SiteId}/credentials", Array.Empty<SiteCredentialItem>());
|
|
|
|
|
|
Handler.OnGet("api/sites/", new SiteItem(
|
2026-08-27 18:56:57 +02:00
|
|
|
|
SiteId, "Site Principal", null, "UTC", null, true, false, DateTime.UtcNow.AddDays(-10)));
|
2026-08-11 16:15:41 +02:00
|
|
|
|
LoginAs();
|
|
|
|
|
|
|
|
|
|
|
|
var cut = RenderPage<SiteDetail>(p => p.Add(x => x.Id, SiteId));
|
|
|
|
|
|
|
|
|
|
|
|
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Aucun identifiant déclaré"));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
|
public void SiteDetail_AfficheIdentifiantsDeclares()
|
|
|
|
|
|
{
|
|
|
|
|
|
Handler.OnGet($"api/sites/{SiteId}/credentials",
|
|
|
|
|
|
new List<SiteCredentialItem>
|
|
|
|
|
|
{
|
|
|
|
|
|
Credential("admin principal", "admin"),
|
|
|
|
|
|
Credential("compte NVR", "nvr", DateTime.UtcNow.AddHours(-1)),
|
|
|
|
|
|
});
|
|
|
|
|
|
Handler.OnGet("api/sites/", new SiteItem(
|
2026-08-27 18:56:57 +02:00
|
|
|
|
SiteId, "Site Principal", null, "UTC", null, true, false, DateTime.UtcNow.AddDays(-10)));
|
2026-08-11 16:15:41 +02:00
|
|
|
|
LoginAs();
|
|
|
|
|
|
|
|
|
|
|
|
var cut = RenderPage<SiteDetail>(p => p.Add(x => x.Id, SiteId));
|
|
|
|
|
|
|
|
|
|
|
|
cut.WaitForAssertion(() =>
|
|
|
|
|
|
{
|
2026-10-25 06:35:00 +01:00
|
|
|
|
cut.Markup.ShouldContain("Identifiants des caméras");
|
2026-08-11 16:15:41 +02:00
|
|
|
|
cut.Markup.ShouldContain("admin principal");
|
|
|
|
|
|
cut.Markup.ShouldContain("compte NVR");
|
|
|
|
|
|
cut.Markup.ShouldContain("<code>admin</code>");
|
|
|
|
|
|
cut.Markup.ShouldContain("<code>nvr</code>");
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Fact]
|
2026-08-11 16:56:19 +02:00
|
|
|
|
public async Task SiteDetail_AjouterIdentifiant_PostEtAffiche()
|
2026-08-11 16:15:41 +02:00
|
|
|
|
{
|
|
|
|
|
|
Handler.OnGet($"api/sites/{SiteId}/credentials", new List<SiteCredentialItem>());
|
|
|
|
|
|
Handler.OnGet("api/sites/", new SiteItem(
|
2026-08-27 18:56:57 +02:00
|
|
|
|
SiteId, "Site Principal", null, "UTC", null, true, false, DateTime.UtcNow.AddDays(-10)));
|
2026-08-11 16:15:41 +02:00
|
|
|
|
Handler.On(HttpMethod.Post, $"api/sites/{SiteId}/credentials",
|
|
|
|
|
|
Credential("admin principal", "admin"));
|
|
|
|
|
|
LoginAs();
|
|
|
|
|
|
|
|
|
|
|
|
var cut = RenderPage<SiteDetail>(p => p.Add(x => x.Id, SiteId));
|
2026-10-25 06:35:00 +01:00
|
|
|
|
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Identifiants des caméras"));
|
2026-08-11 16:15:41 +02:00
|
|
|
|
|
|
|
|
|
|
// Ouvrir le dialog d'ajout (bouton "Ajouter" de la section, pas du dialog).
|
|
|
|
|
|
cut.FindAll("button").First(b => b.TextContent.Trim() == "Ajouter").Click();
|
|
|
|
|
|
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Ajouter un identifiant caméra"));
|
|
|
|
|
|
|
|
|
|
|
|
// Remplir les 3 champs (Immediate=true → .Input). Les seuls inputs de la
|
|
|
|
|
|
// page sont ceux du dialog d'ajout.
|
|
|
|
|
|
var inputs = cut.FindAll("input");
|
|
|
|
|
|
inputs.Count.ShouldBeGreaterThanOrEqualTo(3);
|
|
|
|
|
|
inputs[0].Input("admin principal");
|
|
|
|
|
|
inputs[1].Input("admin");
|
|
|
|
|
|
inputs[2].Input("secret");
|
|
|
|
|
|
|
|
|
|
|
|
// Le bouton "Ajouter" du dialog s'active une fois les 3 champs remplis.
|
|
|
|
|
|
// (Le provider du dialog est rendu AVANT le contenu de la page : cibler
|
|
|
|
|
|
// les actions du dialog, pas tous les boutons "Ajouter".)
|
2026-08-11 16:56:19 +02:00
|
|
|
|
// Find+Click dans InvokeAsync (handler périmé sinon, flaky CI).
|
|
|
|
|
|
await cut.InvokeAsync(() => cut.FindAll("div.mud-dialog-actions button")
|
2026-08-11 16:15:41 +02:00
|
|
|
|
.Single(b => b.TextContent.Trim() == "Ajouter")
|
2026-08-11 16:56:19 +02:00
|
|
|
|
.Click());
|
2026-08-11 16:15:41 +02:00
|
|
|
|
|
|
|
|
|
|
cut.WaitForAssertion(() =>
|
|
|
|
|
|
{
|
|
|
|
|
|
var snackbar = Services.GetRequiredService<ISnackbar>();
|
|
|
|
|
|
snackbar.ShownSnackbars.Select(m => m.Message?.ToString() ?? "")
|
|
|
|
|
|
.ShouldContain("Identifiant ajouté");
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
|
public void SiteDetail_SupprimerIdentifiant_DeleteEtAffiche()
|
|
|
|
|
|
{
|
|
|
|
|
|
var cred = Credential("admin principal", "admin");
|
|
|
|
|
|
Handler.OnGet($"api/sites/{SiteId}/credentials", new List<SiteCredentialItem> { cred });
|
|
|
|
|
|
Handler.OnGet("api/sites/", new SiteItem(
|
2026-08-27 18:56:57 +02:00
|
|
|
|
SiteId, "Site Principal", null, "UTC", null, true, false, DateTime.UtcNow.AddDays(-10)));
|
2026-08-11 16:15:41 +02:00
|
|
|
|
Handler.On(HttpMethod.Delete, $"api/sites/{SiteId}/credentials/{cred.Id}", System.Net.HttpStatusCode.NoContent);
|
|
|
|
|
|
LoginAs();
|
|
|
|
|
|
|
|
|
|
|
|
var cut = RenderPage<SiteDetail>(p => p.Add(x => x.Id, SiteId));
|
|
|
|
|
|
cut.WaitForAssertion(() => cut.Markup.ShouldContain("admin principal"));
|
|
|
|
|
|
|
|
|
|
|
|
cut.FindAll("button[aria-label=\"Supprimer l'identifiant\"]")[0].Click();
|
|
|
|
|
|
|
|
|
|
|
|
cut.WaitForAssertion(() =>
|
|
|
|
|
|
{
|
|
|
|
|
|
var snackbar = Services.GetRequiredService<ISnackbar>();
|
|
|
|
|
|
snackbar.ShownSnackbars.Select(m => m.Message?.ToString() ?? "")
|
|
|
|
|
|
.ShouldContain(m => m.Contains("supprimé", StringComparison.OrdinalIgnoreCase));
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2026-08-10 12:46:15 +02:00
|
|
|
|
}
|