Files
ClaudeDo/tests/ClaudeDo.Ui.Tests/TestSetup.cs
T
Mika Kuns c1ec05a437 fix(ui): stop tests from polluting the live operation-timing.ndjson
DetailsIsland.BindAsync churn (~1900 binds/day, 91-96% cancelled) was not a
UI reactivity bug: OperationTiming.Shared is a static singleton hardcoded to
~/.todo-app/logs/operation-timing.ndjson, and Ui.Tests/Worker.Tests both
construct real DetailsIslandViewModel/TasksIslandViewModel instances that
call Shared.Record directly. Every dotnet test run appended 50-100 lines
straight into the live app's log — pid-burst analysis showed 13 distinct
test-run pids in the ":?" bucket (tests never pass a source) plus a
no-suffix bucket with no pid field at all (pre-dating the pid-per-line
feature). Real user-driven binds that day: 4.

Made Shared settable and added a [ModuleInitializer]-based TestSetup in
both test projects that redirects it to a per-process temp file before any
test runs.
2026-08-13 08:35:09 +02:00

21 lines
940 B
C#

using System.Runtime.CompilerServices;
using ClaudeDo.Ui.Services;
namespace ClaudeDo.Ui.Tests;
internal static class TestSetup
{
// Runs once when this test assembly loads, before any test executes. Without it, every test
// that constructs a real DetailsIslandViewModel/TasksIslandViewModel/WorkerClient and calls a
// method instrumented with OperationTiming.Shared.Record writes straight into the live app's
// ~/.todo-app/logs/operation-timing.ndjson — a single Ui.Tests run added 50-100 cancelled
// "DetailsIsland.BindAsync:?" lines to that file, dwarfing real usage and making the churn
// look like a UI bug.
[ModuleInitializer]
internal static void RedirectOperationTimingAwayFromRealAppData()
{
var path = Path.Combine(Path.GetTempPath(), "claudedo-ui-tests", $"operation-timing-{Environment.ProcessId}.ndjson");
OperationTiming.Shared = new OperationTiming(path);
}
}