From c15231cc182af4333a4f04590e72dc2046670046 Mon Sep 17 00:00:00 2001 From: Leo Li Date: Mon, 28 Sep 2026 03:49:56 -0400 Subject: [PATCH] test: pin font magnification in the Cloud outline attention test outlineAttentionTransitions measures the 100% leading slot, but Cloud rows read the global font magnification from UserDefaults.standard when they render. With a leftover 80% in the app-host defaults the dot and content offsets came out exactly 1 to 3 points off. Pin 100% for the test the way attentionPlacement already pins its own percent. Co-Authored-By: Claude Opus 5.5 (1M context) --- .../CloudSidebarAttentionLayoutTests.swift | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/cmuxTests/CloudSidebarAttentionLayoutTests.swift b/cmuxTests/CloudSidebarAttentionLayoutTests.swift index a4ba60001b14..a83a2a3f200e 100644 --- a/cmuxTests/CloudSidebarAttentionLayoutTests.swift +++ b/cmuxTests/CloudSidebarAttentionLayoutTests.swift @@ -21,13 +21,25 @@ struct CloudSidebarAttentionLayoutTests { } } - private func attentionPlacement(width: Double, kind: String, percent: Int, pinned: Bool) throws { + /// Rows read the magnification from `UserDefaults.standard` when they render, + /// so geometry assertions pin it instead of inheriting app-host state. + private func withMagnification(_ percent: Int, _ body: () throws -> T) rethrows -> T { let oldPercent = UserDefaults.standard.object(forKey: GlobalFontMagnification.percentKey) UserDefaults.standard.set(percent, forKey: GlobalFontMagnification.percentKey) defer { if let oldPercent { UserDefaults.standard.set(oldPercent, forKey: GlobalFontMagnification.percentKey) } else { UserDefaults.standard.removeObject(forKey: GlobalFontMagnification.percentKey) } } + return try body() + } + + private func attentionPlacement(width: Double, kind: String, percent: Int, pinned: Bool) throws { + try withMagnification(percent) { + try renderAttentionPlacement(width: width, kind: kind, percent: percent, pinned: pinned) + } + } + + private func renderAttentionPlacement(width: Double, kind: String, percent: Int, pinned: Bool) throws { let fixture = CloudSidebarOrderingFixture() defer { fixture.close() } fixture.coordinator.apply(nodes: fixture.nodes()) @@ -117,6 +129,11 @@ struct CloudSidebarAttentionLayoutTests { @Test("The real outline repaints unread and cleared rows without changing disclosure geometry", arguments: [220.0, 380.0]) func outlineAttentionTransitions(width: Double) throws { + // The expectations below measure the 100% leading slot. + try withMagnification(100) { try renderOutlineAttentionTransitions(width: width) } + } + + private func renderOutlineAttentionTransitions(width: Double) throws { let fixture = CloudSidebarOrderingFixture() defer { fixture.close() } fixture.window.setContentSize(NSSize(width: width, height: 560))