@@ -1792,6 +1792,27 @@ final class GhosttySurfaceOverlayTests: XCTestCase {
17921792 return
17931793 }
17941794
1795+ func assertPendingSurfaceWidth(
1796+ _ expectedWidth: CGFloat ,
1797+ _ message: String ,
1798+ file: StaticString = #filePath,
1799+ line: UInt = #line
1800+ ) {
1801+ guard let pendingSurfaceWidth = hostedView. debugPendingSurfaceSize ( ) ? . width else {
1802+ XCTFail ( " Expected a pending terminal surface size " , file: file, line: line)
1803+ return
1804+ }
1805+
1806+ XCTAssertEqual (
1807+ pendingSurfaceWidth,
1808+ expectedWidth,
1809+ accuracy: 0.5 ,
1810+ message,
1811+ file: file,
1812+ line: line
1813+ )
1814+ }
1815+
17951816 let initialContentWidth = scrollView. contentSize. width
17961817 XCTAssertEqual ( initialSurfaceSize. width, initialContentWidth, accuracy: 0.5 )
17971818
@@ -1803,21 +1824,17 @@ final class GhosttySurfaceOverlayTests: XCTestCase {
18031824 initialContentWidth,
18041825 " Legacy scrollbars should reserve width in the scroll view content area "
18051826 )
1806- XCTAssertEqual (
1807- hostedView. debugPendingSurfaceSize ( ) ? . width,
1827+ assertPendingSurfaceWidth (
18081828 initialSurfaceSize. width,
1809- accuracy: 0.5 ,
18101829 " Changing the scroll view style alone should leave the terminal grid stale until the scroller-style observer runs "
18111830 )
18121831
18131832 NotificationCenter . default. post ( name: NSScroller . preferredScrollerStyleDidChangeNotification, object: nil )
18141833 RunLoop . current. run ( until: Date ( ) . addingTimeInterval ( 0.05 ) )
18151834
18161835 XCTAssertEqual ( scrollView. scrollerStyle, . legacy)
1817- XCTAssertEqual (
1818- hostedView. debugPendingSurfaceSize ( ) ? . width,
1836+ assertPendingSurfaceWidth (
18191837 legacyContentWidth,
1820- accuracy: 0.5 ,
18211838 " Preferred scroller style changes should recalculate the terminal grid width immediately "
18221839 )
18231840
@@ -1829,21 +1846,17 @@ final class GhosttySurfaceOverlayTests: XCTestCase {
18291846 legacyContentWidth,
18301847 " Overlay scrollbars should restore the full terminal content width "
18311848 )
1832- XCTAssertEqual (
1833- hostedView. debugPendingSurfaceSize ( ) ? . width,
1849+ assertPendingSurfaceWidth (
18341850 legacyContentWidth,
1835- accuracy: 0.5 ,
18361851 " Changing the scroll view style alone should leave the terminal grid stale until the scroller-style observer runs "
18371852 )
18381853
18391854 NotificationCenter . default. post ( name: NSScroller . preferredScrollerStyleDidChangeNotification, object: nil )
18401855 RunLoop . current. run ( until: Date ( ) . addingTimeInterval ( 0.05 ) )
18411856
18421857 XCTAssertEqual ( scrollView. scrollerStyle, . overlay)
1843- XCTAssertEqual (
1844- hostedView. debugPendingSurfaceSize ( ) ? . width,
1858+ assertPendingSurfaceWidth (
18451859 overlayContentWidth,
1846- accuracy: 0.5 ,
18471860 " Preferred scroller style changes should also restore the wider terminal grid when overlay scrollbars return "
18481861 )
18491862 }
0 commit comments