diff --git a/ViewModels/MainViewModel.Scenes.cs b/ViewModels/MainViewModel.Scenes.cs index f5173ab..e95bcad 100644 --- a/ViewModels/MainViewModel.Scenes.cs +++ b/ViewModels/MainViewModel.Scenes.cs @@ -33,6 +33,11 @@ public partial class MainViewModel foreach (var s in Scenes) s.IsStaged = s == value; + // Scene-scoped menu affordances: the (+) menu's Blur entry is Live-only, and a + // binding that is never re-notified stays collapsed for the rest of the session + // (build 1082: the option vanished after the first layout load). + OnPropertyChanged(nameof(CanAddBlur)); + SelectedElement = null; if (value != null) { diff --git a/ytLive.Tests/BlurMenuAvailabilityTests.cs b/ytLive.Tests/BlurMenuAvailabilityTests.cs new file mode 100644 index 0000000..f07521e --- /dev/null +++ b/ytLive.Tests/BlurMenuAvailabilityTests.cs @@ -0,0 +1,51 @@ +using System; +using System.IO; +using System.Linq; +using Xunit; +using ytLive.Models; +using ytLive.ViewModels; + +namespace ytLive.Tests; + +/// +/// The (+) menu's Blur entry is Live-scene only, and it is bound — so the view model has to +/// re-notify `CanAddBlur` whenever the staged scene changes. It did not, and the option stayed +/// collapsed for the rest of the session (build 1082: "it no longer appears as an option"). +/// +[Collection("MainViewModelLayoutPath")] +public class BlurMenuAvailabilityTests +{ + private static MainViewModel NewVm(out string dbPath) + { + dbPath = Path.Combine(Path.GetTempPath(), $"llamacasty-blurmenu-{Guid.NewGuid():N}.db"); + MainViewModel.LayoutPathOverride = dbPath; + return new MainViewModel(); + } + + [Fact] + public void Blur_is_offered_on_the_live_scene_only_and_the_flag_is_re_notified() + { + var vm = NewVm(out var dbPath); + try + { + var live = vm.Scenes.First(s => SceneCatalog.Is(s.Name, SceneCatalog.Live)); + var chat = vm.Scenes.First(s => SceneCatalog.Is(s.Name, SceneCatalog.Chat)); + + vm.StagedScene = live; + Assert.True(vm.CanAddBlur, "the Live scene must offer the blur layer"); + vm.StagedScene = chat; + Assert.False(vm.CanAddBlur, "other scenes must not offer a desktop blur"); + + // The regression: a bound property with no notification never re-evaluates. + var notified = 0; + vm.PropertyChanged += (_, e) => { if (e.PropertyName == nameof(MainViewModel.CanAddBlur)) notified++; }; + vm.StagedScene = live; + Assert.True(notified > 0, "changing the staged scene must re-notify CanAddBlur"); + } + finally + { + MainViewModel.LayoutPathOverride = null; + try { File.Delete(dbPath); } catch (IOException) { } + } + } +}