test: cover account settings page

This commit is contained in:
Jannis committed 2026-10-10 18:46:19 +02:00
1 parent c04fa1df44
commit 81ab2af5e3
1 file changed
+41
@@ -0,0 +1,41 @@
using FamilyPlanner.Web.Client.Pages;
using FamilyPlanner.Web.Client.Services;
using Microsoft.Extensions.DependencyInjection;
using MudBlazor.Services;
namespace FamilyPlanner.Web.Tests.Account;
/// <summary>„Meine Einstellungen“ aus dem Benutzermenü: Theme-Wahl und Link zu den Benachrichtigungen.</summary>
public sealed class AccountSettingsPageTests : BunitContext
{
private readonly ThemeState _theme;
public AccountSettingsPageTests()
{
JSInterop.Mode = JSRuntimeMode.Loose;
Services.AddMudServices();
_theme = new ThemeState(JSInterop.JSRuntime);
Services.AddSingleton(_theme);
}
[Fact]
public void Offers_the_three_theme_choices_and_links_to_notifications()
{
var cut = Render<AccountSettings>();
var labels = cut.FindAll(".fp-theme-choice label").Select(l => l.TextContent.Trim()).ToList();
Assert.Equal(["Wie das Gerät", "Hell", "Dunkel"], labels);
Assert.Equal("konto/benachrichtigungen", cut.Find(".fp-settings-notifications").GetAttribute("href"));
}
[Fact]
public void Choosing_dark_updates_the_theme_state()
{
var cut = Render<AccountSettings>();
cut.FindAll(".fp-theme-choice input")[2].Click();
cut.WaitForAssertion(() => Assert.Equal(ThemePreference.Dark, _theme.Preference));
Assert.True(_theme.IsDarkMode);
}
}