build: one version for the app and the plugin

D11 replaces an installed plugin only when the shipped manifest is
newer, but the manifest version was kept by hand and still said
1.0.0.1, the version of a test build installed before the snapshot
sharing and appPath fixes, so that stale plugin was never replaced.
Directory.Build.props now holds the only version, 1.0.1; publish.py
stamps it into the shipped manifest and the app shows it in its title.

Tests that waited on real time (file retry, popup expiry) use
controlled timers, and real process waits have wider margins.

Refs #1
This commit is contained in:
Florian Schmidt
2026-10-14 21:08:22 +02:00
parent 5c5973aa6c
commit 15c7e684bb
15 changed files with 126 additions and 18 deletions
+1
View File
@@ -4,3 +4,4 @@ Run `dotnet test --project tests/FinalToken.App.Tests -c Release` from the root.
View-model tests use public Core queries. Headless tests run on a dedicated UI thread with
Skia and HarfBuzz, exercise settings and popup actions, and save seven PNG screenshots outside
the repo at ../runs/shots/w2. FINALTOKEN_SCREENSHOT_DIR overrides that path.
Popup expiry uses an injected TimeProvider; fire timers and pump the dispatcher instead of sleeping.
+24 -2
View File
@@ -31,6 +31,7 @@ public sealed class HeadlessTests
var model = FakeData.Model();
var panel = new PanelWindow(model, () => { }, () => { }, () => { }, () => { }) { Height = 2450 };
panel.RequestedThemeVariant = ThemeVariant.Light; panel.Show(); Save(panel, "panel-light.png");
Assert.Equal($"FinalToken {typeof(Program).Assembly.GetName().Version!.ToString(3)}", panel.Title);
Assert.Contains(panel.GetVisualDescendants().OfType<TextBlock>(), t => t.Text == "Claude");
Assert.Contains(panel.GetVisualDescendants().OfType<TextBlock>(), t => t.Text == "Tokens per day");
var filters = panel.GetVisualDescendants().OfType<ComboBox>().ToArray();
@@ -74,7 +75,8 @@ public sealed class HeadlessTests
var install = new PopupWindow("Stream Deck plugin", "Update ready", () => { }, "Update", () => installed++);
install.Show(); install.GetVisualDescendants().OfType<Button>().Single(b => b.Content as string == "Update").RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
Assert.Equal(1, installed);
using var stack = new PopupStack(() => { });
var popupClock = new PopupClock();
using var stack = new PopupStack(() => { }, popupClock);
var first = PopupWindow.Pace(new(Provider.Claude, "a", "Session", PaceState.Ahead, 20, null), () => { });
var second = PopupWindow.Pace(new(Provider.Codex, "b", "Week", PaceState.Behind, -20, null), () => { });
stack.Show(first); stack.Show(second); Assert.True(second.Position.Y < first.Position.Y);
@@ -94,8 +96,9 @@ public sealed class HeadlessTests
{ Values = [new(time, "Claude", 1), new(time.AddHours(1), "Claude", 2), new(time.AddHours(2), "Claude", 3)] })),
Width = 620, Height = 260, RequestedThemeVariant = ThemeVariant.Light };
smallChart.Show(); Save(smallChart, "chart-max-3.png", polishShots); smallChart.Close();
Thread.Sleep(8200); Dispatcher.UIThread.RunJobs();
popupClock.Fire(); Dispatcher.UIThread.RunJobs();
Assert.False(first.IsVisible); Assert.False(second.IsVisible);
Assert.All(popupClock.Timers, timer => Assert.True(timer.Disposed));
completion.SetResult();
void Save(Window window, string name, string? destination = null)
{
@@ -112,4 +115,23 @@ public sealed class HeadlessTests
}
public sealed class TestApplication : Application
{ public override void Initialize() => Styles.Add(new FluentTheme()); }
private sealed class PopupClock : TimeProvider
{
public List<PopupTimer> Timers { get; } = [];
public override ITimer CreateTimer(TimerCallback callback, object? state, TimeSpan dueTime, TimeSpan period)
{
Assert.Equal(TimeSpan.FromSeconds(8), dueTime);
Assert.Equal(Timeout.InfiniteTimeSpan, period);
var timer = new PopupTimer(callback, state); Timers.Add(timer); return timer;
}
public void Fire() { foreach (var timer in Timers.Where(t => !t.Disposed)) timer.Fire(); }
}
private sealed class PopupTimer(TimerCallback callback, object? state) : ITimer
{
public bool Disposed { get; private set; }
public void Fire() => callback(state);
public bool Change(TimeSpan dueTime, TimeSpan period) => throw new NotSupportedException();
public void Dispose() => Disposed = true;
public ValueTask DisposeAsync() { Dispose(); return ValueTask.CompletedTask; }
}
}