- SettingsPage refondue : plus de création/édition clé/valeur arbitraire, chaque domaine a sa section dédiée (pattern StorageSettingsSection) - NotificationSettingsSection : ntfy (baseUrl, token) + email SMTP (from, host, port, user, password, SSL) — secrets masqués, redaction API respectée - AiSettingsSection : URLs CodeProject.AI/Ollama + toggle détection IA - AgentDefaultsSection : niveau de log global (select), rétention logs, intervalle heartbeat, DSN Sentry - Seed #80 étendu : ai.detection.enabled, log.level, log.retentionDays, heartbeat.interval.seconds, sentry.dsn (idempotent, catégories cohérentes) - Tests bUnit : 12 tests (4 page + 8 sections) — rendu, PUT par clé, secrets redactés invisibles ; 221 tests Web verts
79 lines
2.5 KiB
C#
79 lines
2.5 KiB
C#
using Bunit;
|
|
using Heimdall.Web.Components.Pages;
|
|
using Heimdall.Web.Services;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using MudBlazor;
|
|
using Shouldly;
|
|
|
|
namespace Heimdall.Web.Tests.Components.Pages;
|
|
|
|
public class SettingsPageTests : PageTestBase
|
|
{
|
|
[Fact]
|
|
public void SettingsPage_AfficheLesSectionsVisuelles()
|
|
{
|
|
Handler.OnGet("api/settings", new List<AppSettingItem>());
|
|
LoginAs();
|
|
|
|
var cut = RenderPage<SettingsPage>();
|
|
|
|
cut.WaitForAssertion(() =>
|
|
{
|
|
// Plus de CRUD clé/valeur : chaque domaine a sa section dédiée
|
|
cut.Markup.ShouldContain("Stockage");
|
|
cut.Markup.ShouldContain("Notifications");
|
|
cut.Markup.ShouldContain("Intelligence artificielle");
|
|
cut.Markup.ShouldContain("Défauts agents");
|
|
});
|
|
}
|
|
|
|
[Fact]
|
|
public void SettingsPage_PasDeChampCleLibre()
|
|
{
|
|
Handler.OnGet("api/settings", new List<AppSettingItem>());
|
|
LoginAs();
|
|
|
|
var cut = RenderPage<SettingsPage>();
|
|
|
|
cut.WaitForAssertion(() =>
|
|
{
|
|
// L'exigence produit : plus aucun champ « Clé » libre dans l'UI
|
|
cut.Markup.ShouldNotContain("Clé *");
|
|
cut.Markup.ShouldNotContain("Nouveau paramètre");
|
|
});
|
|
}
|
|
|
|
[Fact]
|
|
public void SettingsPage_RechargerConfig_AfficheSucces()
|
|
{
|
|
Handler.OnGet("api/settings", new List<AppSettingItem>());
|
|
Handler.On(HttpMethod.Post, "api/settings/reload", System.Net.HttpStatusCode.OK);
|
|
LoginAs();
|
|
|
|
var cut = RenderPage<SettingsPage>();
|
|
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Configuration"));
|
|
|
|
// Le refresh est le seul MudIconButton de la page (header)
|
|
cut.FindAll("button.mud-icon-button")[0].Click();
|
|
|
|
cut.WaitForAssertion(() =>
|
|
{
|
|
var snackbar = Services.GetRequiredService<ISnackbar>();
|
|
snackbar.ShownSnackbars.Select(m => m.Message?.ToString() ?? "")
|
|
.ShouldContain(m => m.Contains("Configuration rechargée", StringComparison.OrdinalIgnoreCase));
|
|
});
|
|
}
|
|
|
|
[Fact]
|
|
public void SettingsPage_ApiIndisponible_LaPageRendSansCrash()
|
|
{
|
|
Handler.OnGet("api/settings", System.Net.HttpStatusCode.InternalServerError);
|
|
LoginAs();
|
|
|
|
var cut = RenderPage<SettingsPage>();
|
|
|
|
// Les sections gèrent leur propre échec de chargement (défauts) — pas de crash global
|
|
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Stockage"));
|
|
}
|
|
}
|