- 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
59 lines
1.9 KiB
C#
59 lines
1.9 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 AiSettingsSectionTests : PageTestBase
|
|
{
|
|
private static AppSettingItem Setting(string key, string value) =>
|
|
new(Guid.NewGuid(), key, value, key, "ai", "string", null, DateTime.UtcNow.AddDays(-1));
|
|
|
|
[Fact]
|
|
public void AiSection_AfficheChampsIA()
|
|
{
|
|
Handler.OnGet("api/settings", new List<AppSettingItem>
|
|
{
|
|
Setting("ai.cpaiUrl", "http://cpai:32168"),
|
|
Setting("ai.ollamaUrl", "http://ollama:11434"),
|
|
Setting("ai.detection.enabled", "true"),
|
|
});
|
|
LoginAs();
|
|
|
|
var cut = Render<AiSettingsSection>();
|
|
|
|
cut.WaitForAssertion(() =>
|
|
{
|
|
cut.Markup.ShouldContain("URL CodeProject.AI");
|
|
cut.Markup.ShouldContain("URL Ollama");
|
|
cut.Markup.ShouldContain("http://cpai:32168");
|
|
cut.Markup.ShouldContain("http://ollama:11434");
|
|
cut.Markup.ShouldContain("Détection IA activée");
|
|
});
|
|
}
|
|
|
|
[Fact]
|
|
public void AiSection_ModifieCpaiUrl_AppellePutAvecBonneCle()
|
|
{
|
|
Handler.OnGet("api/settings", new List<AppSettingItem> { Setting("ai.cpaiUrl", "http://cpai:32168") });
|
|
Handler.On(HttpMethod.Put, "api/settings/ai.cpaiUrl", System.Net.HttpStatusCode.OK);
|
|
LoginAs();
|
|
|
|
var cut = Render<AiSettingsSection>();
|
|
cut.WaitForAssertion(() => cut.Markup.ShouldContain("http://cpai:32168"));
|
|
|
|
cut.FindAll("input")[0].Change("http://cpai:32169");
|
|
|
|
cut.WaitForAssertion(() =>
|
|
{
|
|
Handler.Requests.ShouldContain(r =>
|
|
r.Method == HttpMethod.Put &&
|
|
r.RequestUri!.AbsolutePath.Contains("ai.cpaiUrl", StringComparison.OrdinalIgnoreCase));
|
|
});
|
|
}
|
|
}
|