From 677a4c1853d24a5c001d71a52885d146534abca2 Mon Sep 17 00:00:00 2001 From: mika kuns Date: Wed, 5 Aug 2026 14:06:00 +0200 Subject: [PATCH] fix(ui-tests): install a real localizer in UsagePillViewModelTests The pill tests asserted on real localized strings but never set Loc.Current, which defaults to a key-echo localizer. They only passed because an unrelated test class happened to install a real Localizer first; adding the usage-monitor modal tests changed the ordering and the assertions started seeing raw keys. Initialize Loc.Current in the constructor, matching every other UI test class. --- .../ViewModels/UsagePillViewModelTests.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/ClaudeDo.Ui.Tests/ViewModels/UsagePillViewModelTests.cs b/tests/ClaudeDo.Ui.Tests/ViewModels/UsagePillViewModelTests.cs index 472849cc..e5bffe5e 100644 --- a/tests/ClaudeDo.Ui.Tests/ViewModels/UsagePillViewModelTests.cs +++ b/tests/ClaudeDo.Ui.Tests/ViewModels/UsagePillViewModelTests.cs @@ -1,4 +1,7 @@ using System; +using System.IO; +using ClaudeDo.Localization; +using ClaudeDo.Ui.Localization; using ClaudeDo.Ui.Services; using ClaudeDo.Ui.ViewModels; using Xunit; @@ -7,6 +10,18 @@ namespace ClaudeDo.Ui.Tests.ViewModels; public class UsagePillViewModelTests { + // Loc.Current is ambient static state defaulting to a key-echo localizer, so these + // assertions on real strings must install a real one instead of relying on whichever + // other test class happened to run first. + public UsagePillViewModelTests() + { + var dir = AppContext.BaseDirectory; + while (dir is not null && !Directory.Exists(Path.Combine(dir, "src", "ClaudeDo.Localization", "locales"))) + dir = Path.GetDirectoryName(dir); + Loc.Current = new Localizer( + LocaleStore.Load(Path.Combine(dir!, "src", "ClaudeDo.Localization", "locales")), "en"); + } + private sealed class FakeWorker : StubWorkerClient { public UsageSnapshotDto? InitialSnapshot;