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.
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
using ClaudeDo.Ui.Services;
|
||||
|
||||
namespace ClaudeDo.Worker.Tests;
|
||||
|
||||
internal static class TestSetup
|
||||
{
|
||||
// Runs once when this test assembly loads, before any test executes. UiVm/*Tests.cs construct
|
||||
// real TasksIslandViewModel instances, whose LoadForListAsync/ReorderAsync/ReconcileTickAsync
|
||||
// call OperationTiming.Shared.Record directly — without a redirect those writes land in the
|
||||
// live app's ~/.todo-app/logs/operation-timing.ndjson (see ClaudeDo.Ui.Tests' TestSetup for
|
||||
// the same trap on the Ui.Tests side).
|
||||
[ModuleInitializer]
|
||||
internal static void RedirectOperationTimingAwayFromRealAppData()
|
||||
{
|
||||
var path = Path.Combine(Path.GetTempPath(), "claudedo-worker-tests", $"operation-timing-{Environment.ProcessId}.ndjson");
|
||||
OperationTiming.Shared = new OperationTiming(path);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user