Files
LlamaCasty/ytLive.Tests/ScoreboardPropertiesTests.cs
T
gramps 8caee21b9a fix(scoreboard): the strip finally reaches the preview, and dev labels are orange
"Clicking on everything produces no visible effect" — the cause was upstream of the controls, and it
is the same defect as the invisible alert box (TASK 47):

- `Source.DisplaySource` returned `VideoImageSource` only for ChatBox / WebSource / MediaSource /
  AlertBox. The scoreboard's frame was rendered and published, then never displayed.
- the preview's Image has a per-type Visibility trigger for each of those and none for IsScoreboard,
  so even a correct DisplaySource would have stayed collapsed.

Both are fixed, and the layer test now pins the frame-source list AND the trigger so the pair cannot
drift apart again.

Dev-only affordances are ORANGE from now on (creator ruling): "Simulate (dev)" is a TextBlock in
Brush.Attention, so a development control can never be mistaken for product. The panel test pins the
colour.
2026-10-30 15:05:33 -07:00

69 lines
3.3 KiB
C#

using System.Reflection;
using Xunit;
using ytLive.ViewModels;
namespace ytLive.Tests;
/// <summary>The scoreboard's look and its eight fact switches live in the LAYER PROPERTIES, and the
/// panel must use the app's widgets — a hand-painted control is the TASK 58/63 defect, and the
/// guard that catches it is here because the type-based sweep cannot see a bespoke picker.</summary>
public class ScoreboardPropertiesTests
{
[Fact]
public void The_scoreboard_properties_are_themed_controls_bound_to_the_layer_surface()
{
var panel = SourceAssert.Text("Controls", "LeftPanel.xaml");
// Gated on the selected layer being a scoreboard.
Assert.Contains("SelectedElement.IsScoreboard", panel);
// Signed out: the block is inert with a one-line explanation — EXCEPT in a DEBUG build, where
// CanUseScoreboard is true so the strip can be previewed without an account.
var block = panel[panel.IndexOf("Scoreboard config", System.StringComparison.Ordinal)..];
block = block[..block.IndexOf("<!-- Countdown config -->", System.StringComparison.Ordinal)];
Assert.Contains("IsEnabled=\"{Binding CanUseScoreboard}\"", block);
Assert.Contains("Sign in to YouTube to use the scoreboard.", block);
Assert.Contains("CanUseScoreboard, Converter={StaticResource InverseBoolToVis}", block);
// Dev-only labels are ORANGE, so a development affordance cannot pass for product.
Assert.Contains("Simulate (dev)", block);
Assert.Contains("Brush.Attention", block);
// The master switch sits in the same panel: off hides the strip and stops the polling.
Assert.Contains("ScoreboardEnabled", panel);
// The eight fact switches.
foreach (var binding in new[]
{
"ScoreboardShowSubscribers", "ScoreboardShowWatchHours", "ScoreboardShowSuperChats",
"ScoreboardShowNewMembers", "ScoreboardShowMilestones", "ScoreboardShowLastMember",
"ScoreboardShowLastSuperChat", "ScoreboardShowLastGift",
})
Assert.Contains(binding, panel);
// Look controls: text colour, plate colour, plate opacity, text size.
foreach (var binding in new[]
{
"ScoreboardTextColor", "ScoreboardBackgroundColor",
"ScoreboardBackgroundOpacity", "ScoreboardFontSize",
})
Assert.Contains(binding, panel);
// Theme widgets only: the colour pickers are the app's drop-down (YtComboBox), never a
// hand-built menu, and the toggles are YtCheckBox.
Assert.Contains("Style=\"{StaticResource YtComboBox}\"", block);
Assert.Contains("Style=\"{StaticResource YtCheckBox}\"", block);
Assert.DoesNotContain("ContextMenu", block);
// The VM surface exists for every binding above (a typo would bind to nothing silently).
var type = typeof(MainViewModel);
foreach (var name in new[]
{
"ScoreboardTextColor", "ScoreboardBackgroundColor", "ScoreboardBackgroundOpacity",
"ScoreboardFontSize", "ScoreboardColorOptions", "ScoreboardShowSubscribers",
"ScoreboardEnabled", "CanUseScoreboard",
})
Assert.NotNull(type.GetProperty(name));
}
}