- 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
80 lines
2.8 KiB
C#
80 lines
2.8 KiB
C#
using Bunit;
|
|
using Heimdall.Web.Components.Settings;
|
|
using Heimdall.Web.Services;
|
|
using Heimdall.Web.Tests.Components.Pages;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using MudBlazor;
|
|
using Shouldly;
|
|
|
|
namespace Heimdall.Web.Tests.Components.Settings;
|
|
|
|
public class AgentDefaultsSectionTests : PageTestBase
|
|
{
|
|
private static AppSettingItem Setting(string key, string value) =>
|
|
new(Guid.NewGuid(), key, value, key, "agent", "string", null, DateTime.UtcNow.AddDays(-1));
|
|
|
|
[Fact]
|
|
public void AgentDefaults_AfficheChampsLogsHeartbeatEtDiagnostic()
|
|
{
|
|
Handler.OnGet("api/settings", new List<AppSettingItem>
|
|
{
|
|
Setting("log.level", "info"),
|
|
Setting("log.retentionDays", "7"),
|
|
Setting("heartbeat.interval.seconds", "30"),
|
|
Setting("sentry.dsn", "***REDACTED***"),
|
|
});
|
|
LoginAs();
|
|
|
|
var cut = Render<AgentDefaultsSection>();
|
|
|
|
cut.WaitForAssertion(() =>
|
|
{
|
|
cut.Markup.ShouldContain("Niveau de log global");
|
|
cut.Markup.ShouldContain("Rétention des logs agents");
|
|
cut.Markup.ShouldContain("Intervalle de heartbeat");
|
|
cut.Markup.ShouldContain("DSN Sentry / GlitchTip");
|
|
});
|
|
}
|
|
|
|
[Fact]
|
|
public void AgentDefaults_ModifieRetention_AppellePutAvecBonneCle()
|
|
{
|
|
Handler.OnGet("api/settings", new List<AppSettingItem> { Setting("log.retentionDays", "7") });
|
|
Handler.On(HttpMethod.Put, "api/settings/log.retentionDays", System.Net.HttpStatusCode.OK);
|
|
LoginAs();
|
|
|
|
var cut = Render<AgentDefaultsSection>();
|
|
cut.WaitForAssertion(() => cut.Markup.ShouldContain("7"));
|
|
|
|
// Inputs : [0]=select log.level (readonly), [1]=rétention
|
|
cut.FindAll("input")[1].Change("14");
|
|
|
|
cut.WaitForAssertion(() =>
|
|
{
|
|
Handler.Requests.ShouldContain(r =>
|
|
r.Method == HttpMethod.Put &&
|
|
r.RequestUri!.AbsolutePath.Contains("log.retentionDays", StringComparison.OrdinalIgnoreCase));
|
|
});
|
|
}
|
|
|
|
[Fact]
|
|
public void AgentDefaults_ModifieHeartbeat_AppellePutAvecBonneCle()
|
|
{
|
|
Handler.OnGet("api/settings", new List<AppSettingItem> { Setting("heartbeat.interval.seconds", "30") });
|
|
Handler.On(HttpMethod.Put, "api/settings/heartbeat.interval.seconds", System.Net.HttpStatusCode.OK);
|
|
LoginAs();
|
|
|
|
var cut = Render<AgentDefaultsSection>();
|
|
cut.WaitForAssertion(() => cut.Markup.ShouldContain("30"));
|
|
|
|
cut.FindAll("input")[2].Change("45");
|
|
|
|
cut.WaitForAssertion(() =>
|
|
{
|
|
Handler.Requests.ShouldContain(r =>
|
|
r.Method == HttpMethod.Put &&
|
|
r.RequestUri!.AbsolutePath.Contains("heartbeat.interval.seconds", StringComparison.OrdinalIgnoreCase));
|
|
});
|
|
}
|
|
}
|