Creator design (2026-11-05). A stack of red rows at the top of the left panel, above both mode grids so it shows while editing and while live, pushing the panel's content down. - Row 1 is the **Steam licence indicator** and nothing displaces it. It reads as status, not a warning: "Entitlement 30 fps · Maximum 60 fps", both numbers derived from QualityOptions and HasProOutput. While higher tiers are unavailable it shows a **pin** (standing indicator, no close control); once ownership is verified the pin becomes a **close control** and the dismissal is persisted (`Steam.LicenceIndicatorDismissed`), permanent while ownership holds. Losing ownership restores it as pinned — a change of state, not a preference. Click → About. - **Event rows stack beneath, newest first**, one row per episode (an episode advancing its state updates its own row rather than adding another). Each is dismissible. Click → the Logs tab opens with that event's sequence range painted red (`HighlightedLogFrom/To` + `LogInRangeConverter`; two numbers rather than a collection because the log list is virtualised and realised rows do not re-evaluate on membership changes). - Replaces the old red panel under the quality picker, which is removed. - The Steam diagnostic text loses "Contact the creator or support" for a neutral "Steam licensing is not configured in this build." Tests: `AttentionAlertStackTests` — pinned first with the status text; owned → closable and the close survives a reload but ownership loss restores it pinned; pinned cannot be dismissed; event rows LIFO with in-place episode updates; clicking an event opens Logs and sets its range. AboutHub + Entitlement tests updated for the removed panel and the new wording. FAST gate: 532 passed, 0 failed, 0 warnings.
150 lines
5.8 KiB
C#
150 lines
5.8 KiB
C#
using System;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using Microsoft.Data.Sqlite;
|
|
using Xunit;
|
|
using ytLive.Models;
|
|
using ytLive.Services.Entitlement;
|
|
using ytLive.ViewModels;
|
|
|
|
namespace ytLive.Tests;
|
|
|
|
/// <summary>
|
|
/// The left panel's alert stack (creator design, 2026-11-05). Row 1 is the Steam licence indicator and
|
|
/// nothing displaces it: pinned (no close) while higher tiers are unavailable, closable — permanently —
|
|
/// once ownership is verified, and back as pinned if ownership is later lost.
|
|
/// <para>Event rows stack beneath it, newest first, each dismissible, and clicking one opens the Logs
|
|
/// tab with that event's lines painted (the range is what the row carries).</para>
|
|
/// </summary>
|
|
[Collection("RealApp")]
|
|
public sealed class AttentionAlertStackTests
|
|
{
|
|
private readonly RealAppHost _app;
|
|
|
|
public AttentionAlertStackTests(RealAppHost app) => _app = app;
|
|
|
|
[Fact]
|
|
public void LicenceIndicator_IsPinnedFirst_AndShowsStatusNotAPunishment()
|
|
{
|
|
WithVm(vm =>
|
|
{
|
|
// A Debug build fakes ownership; this test is about the NOT-OWNED state.
|
|
vm.EntitlementOverride = new FakeEntitlement(false, "Steam licensing is not configured in this build.");
|
|
|
|
var row = Assert.Single(vm.AttentionAlerts);
|
|
Assert.Equal("STEAM LICENCE", row.Label);
|
|
Assert.True(row.IsPinned);
|
|
Assert.True(row.ShowsPin);
|
|
Assert.False(row.CanDismiss);
|
|
Assert.Equal(AttentionAlertAction.About, row.Action);
|
|
|
|
// A status readout: what this build is entitled to, and the maximum.
|
|
Assert.Contains("Entitlement 30 fps", row.Text);
|
|
Assert.Contains("Maximum 60 fps", row.Text);
|
|
Assert.DoesNotContain("unavailable", row.Text, StringComparison.OrdinalIgnoreCase);
|
|
});
|
|
}
|
|
|
|
[Fact]
|
|
public void OwnedLicence_MakesTheIndicatorClosable_AndTheCloseIsPermanent()
|
|
{
|
|
WithVm((vm, db) =>
|
|
{
|
|
vm.EntitlementOverride = new FakeEntitlement(true);
|
|
|
|
var row = Assert.Single(vm.AttentionAlerts);
|
|
Assert.False(row.IsPinned);
|
|
Assert.False(row.ShowsPin);
|
|
Assert.True(row.CanDismiss);
|
|
Assert.Contains("Entitlement 60 fps", row.Text);
|
|
|
|
vm.DismissAlertCommand.Execute(row);
|
|
Assert.Empty(vm.AttentionAlerts);
|
|
|
|
// Permanent: a fresh view-model on the same profile must not bring it back…
|
|
var reloaded = new MainViewModel();
|
|
Assert.DoesNotContain(reloaded.AttentionAlerts, alert => alert.Label == "STEAM LICENCE");
|
|
|
|
// …but losing ownership restores it as a pinned indicator: a change of state, not a preference.
|
|
reloaded.EntitlementOverride = new FakeEntitlement(false, "Steam licensing is not configured in this build.");
|
|
var restored = reloaded.AttentionAlerts.First(alert => alert.Label == "STEAM LICENCE");
|
|
Assert.True(restored.IsPinned);
|
|
});
|
|
}
|
|
|
|
[Fact]
|
|
public void PinnedIndicator_CannotBeDismissed()
|
|
{
|
|
WithVm(vm =>
|
|
{
|
|
vm.EntitlementOverride = new FakeEntitlement(false, "Steam licensing is not configured in this build.");
|
|
var row = vm.AttentionAlerts.Single();
|
|
vm.DismissAlertCommand.Execute(row);
|
|
Assert.Single(vm.AttentionAlerts); // still there: it is state, not an alert to clear
|
|
});
|
|
}
|
|
|
|
[Fact]
|
|
public void EventRows_StackBeneathTheIndicator_NewestFirst_AndDismissIndividually()
|
|
{
|
|
WithVm(vm =>
|
|
{
|
|
vm.PushAttentionAlertForTest("drop-1", "STREAM", "Stream dropped — reconnecting (attempt 1 of 4)", 10, 12);
|
|
vm.PushAttentionAlertForTest("drop-2", "STREAM", "Stream dropped — reconnecting (attempt 2 of 4)", 13, 15);
|
|
|
|
Assert.Equal(new[] { "STEAM LICENCE", "STREAM", "STREAM" }, vm.AttentionAlerts.Select(a => a.Label));
|
|
// Newest event sits directly under the indicator.
|
|
Assert.Contains("attempt 2", vm.AttentionAlerts[1].Text);
|
|
Assert.Contains("attempt 1", vm.AttentionAlerts[2].Text);
|
|
|
|
// The same event advancing updates its row instead of adding another.
|
|
vm.PushAttentionAlertForTest("drop-2", "STREAM", "Stream recovered after 1.4 s", 13, 16);
|
|
Assert.Equal(3, vm.AttentionAlerts.Count);
|
|
Assert.Contains("recovered", vm.AttentionAlerts[1].Text);
|
|
|
|
vm.DismissAlertCommand.Execute(vm.AttentionAlerts[1]);
|
|
Assert.Equal(2, vm.AttentionAlerts.Count);
|
|
Assert.Equal("STEAM LICENCE", vm.AttentionAlerts[0].Label);
|
|
});
|
|
}
|
|
|
|
[Fact]
|
|
public void ClickingAnEventRow_OpensTheLogsTab_AndHighlightsItsRange()
|
|
{
|
|
WithVm(vm =>
|
|
{
|
|
vm.PushAttentionAlertForTest("drop-1", "STREAM", "Stream dropped", 41, 47);
|
|
|
|
vm.ActivateAlertCommand.Execute(vm.AttentionAlerts[1]);
|
|
|
|
Assert.True(vm.IsLogsTabSelected);
|
|
Assert.Equal(41, vm.HighlightedLogFrom);
|
|
Assert.Equal(47, vm.HighlightedLogTo);
|
|
});
|
|
}
|
|
|
|
private void WithVm(Action<MainViewModel> body) => WithVm((vm, _) => body(vm));
|
|
|
|
private void WithVm(Action<MainViewModel, string> body)
|
|
{
|
|
_app.Run(() =>
|
|
{
|
|
var tempDb = Path.Combine(Path.GetTempPath(), $"ytLlive-alerts-{Guid.NewGuid():N}.db");
|
|
MainViewModel.LayoutPathOverride = tempDb;
|
|
var window = new MainWindow();
|
|
var vm = (MainViewModel)window.DataContext;
|
|
try
|
|
{
|
|
body(vm, tempDb);
|
|
}
|
|
finally
|
|
{
|
|
window.Close();
|
|
MainViewModel.LayoutPathOverride = null;
|
|
SqliteConnection.ClearAllPools();
|
|
try { File.Delete(tempDb); } catch { /* best-effort cleanup */ }
|
|
}
|
|
});
|
|
}
|
|
}
|