From fc73b5343297b0c09db791d1387af17e0a2807cf Mon Sep 17 00:00:00 2001 From: Leo Li Date: Thu, 24 Sep 2026 19:01:47 -0400 Subject: [PATCH] test(minimal-mode): measure the toggle only after setup stops re-rendering testMinimalModeToggleDoesNotReevaluateChromeHeavyBodies drained a fixed 20 runloop iterations after the first render, then counted body evaluations across the minimal-mode toggle. Setup keeps publishing after that: the selected workspace's directory reaches the file explorer a few turns later, and the store change re-evaluates ContentView. PR run 36016958288 logged "ContentView: _fileExplorerStore changed." inside the toggle's window and failed with contentViewBody and workspaceContentBody at 1. Wait for three consecutive quiet drains (bounded) before measuring, so the counts only cover what the toggle itself invalidates. Co-Authored-By: Claude Opus 5.5 --- .../WorkspaceContentViewVisibilityTests.swift | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/cmuxTests/WorkspaceContentViewVisibilityTests.swift b/cmuxTests/WorkspaceContentViewVisibilityTests.swift index f2f4e856af08..61c22b3ee865 100644 --- a/cmuxTests/WorkspaceContentViewVisibilityTests.swift +++ b/cmuxTests/WorkspaceContentViewVisibilityTests.swift @@ -264,6 +264,22 @@ final class WorkspaceContentViewVisibilityTests { #expect(counts.contentViewBody > 0) #expect(counts.workspaceContentBody > 0) #expect(counts.verticalTabsSidebarBody > 0) + // Setup work keeps publishing after the first render: the selected + // workspace's directory reaches the file explorer a few runloop turns + // later, and that store change re-evaluates ContentView. On a loaded + // runner it landed inside the toggle's window (PR run 36016958288 logged + // "ContentView: _fileExplorerStore changed."), so measure only once the + // window has gone quiet. + var quietRounds = 0 + for _ in 0..<100 where quietRounds < 3 { + counts.reset() + await Self.drainMainRunLoop(for: window) + let settled = counts.contentViewBody == 0 + && counts.workspaceContentBody == 0 + && counts.verticalTabsSidebarBody == 0 + quietRounds = settled ? quietRounds + 1 : 0 + } + try #require(quietRounds >= 3, "The window must stop re-evaluating chrome bodies before the toggle is measured") counts.reset() counts.isMeasuringInvalidations = true defer { counts.isMeasuringInvalidations = false }