Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions cmuxTests/AppDelegateMainWindowTestingSupport.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import AppKit
import Bonsplit
import CmuxTerminal
import Foundation
import Testing
Expand Down Expand Up @@ -239,6 +240,32 @@ extension AppDelegate {
}
}

extension Workspace {
/// Splits `panelId` after giving `window` and its split container a
/// realistic size.
///
/// `AppDelegate.createMainWindow()` copies the size of the current main
/// window, by design, and earlier tests in the same app host leave narrow
/// (320-point) main windows registered. After the 240-point sidebar, that
/// container is narrower than two minimum-width panes, so split admission
/// (#15392) correctly refuses a side-by-side split and the fixture gets
/// nil. A test that needs a split must set the geometry it depends on
/// instead of inheriting whatever the previous test left behind.
func newTerminalSplitInRealisticWindowForTesting(
window: NSWindow,
from panelId: UUID,
orientation: SplitOrientation,
focus: Bool = true
) -> TerminalPanel? {
window.setContentSize(NSSize(width: 1_000, height: 700))
window.contentView?.layoutSubtreeIfNeeded()
bonsplitController.setContainerFrame(
CGRect(x: 0, y: 0, width: 1_000, height: 1_000)
)
return newTerminalSplit(from: panelId, orientation: orientation, focus: focus)
}
}

/// The tab id a portal-rendering fixture must build its surface with, and the
/// teardown for the context registered to authorize it.
///
Expand Down
9 changes: 2 additions & 7 deletions cmuxTests/AppDelegateShortcutRoutingRepairProbe.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,8 @@ extension AppDelegateShortcutRoutingTests {
orientation: SplitOrientation,
focus: Bool = true
) -> TerminalPanel? {
window.setContentSize(NSSize(width: 1_000, height: 700))
window.contentView?.layoutSubtreeIfNeeded()
workspace.bonsplitController.setContainerFrame(
CGRect(x: 0, y: 0, width: 1_000, height: 1_000)
)
return workspace.newTerminalSplit(
from: panelId, orientation: orientation, focus: focus
workspace.newTerminalSplitInRealisticWindowForTesting(
window: window, from: panelId, orientation: orientation, focus: focus
)
}

Expand Down
4 changes: 3 additions & 1 deletion cmuxTests/RemoteTmuxMirrorSplitRoutingTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@ import Testing
defer { harness.tearDown() }

let panelsBefore = harness.workspace.panels.count
let window = try #require(harness.appDelegate.windowForMainWindowId(harness.windowId))

let panel = harness.workspace.newTerminalSplit(
let panel = harness.workspace.newTerminalSplitInRealisticWindowForTesting(
window: window,
from: harness.sourcePanelId,
orientation: .horizontal,
focus: false
Expand Down
4 changes: 2 additions & 2 deletions cmuxTests/WorkspaceManualUnreadTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,7 @@ final class WorkspaceManualUnreadTests: XCTestCase {
let manager = try XCTUnwrap(appDelegate.tabManagerFor(windowId: windowId))
let workspace = try XCTUnwrap(manager.selectedWorkspace)
let leftPanelId = try XCTUnwrap(workspace.focusedPanelId)
let rightPanel = try XCTUnwrap(workspace.newTerminalSplit(from: leftPanelId, orientation: .horizontal, focus: false))
let rightPanel = try XCTUnwrap(workspace.newTerminalSplitInRealisticWindowForTesting(window: window, from: leftPanelId, orientation: .horizontal, focus: false))
let leftTabId = try XCTUnwrap(workspace.surfaceIdFromPanelId(leftPanelId))
let rightTabId = try XCTUnwrap(workspace.surfaceIdFromPanelId(rightPanel.id))

Expand Down Expand Up @@ -994,7 +994,7 @@ final class WorkspaceManualUnreadTests: XCTestCase {
let manager = try XCTUnwrap(appDelegate.tabManagerFor(windowId: windowId))
let currentWorkspace = try XCTUnwrap(manager.selectedWorkspace)
let focusedPanelId = try XCTUnwrap(currentWorkspace.focusedPanelId)
let otherPanel = try XCTUnwrap(currentWorkspace.newTerminalSplit(from: focusedPanelId, orientation: .horizontal, focus: false))
let otherPanel = try XCTUnwrap(currentWorkspace.newTerminalSplitInRealisticWindowForTesting(window: window, from: focusedPanelId, orientation: .horizontal, focus: false))
let nextWorkspace = manager.addWorkspace(select: false, eagerLoadTerminal: false)

currentWorkspace.focusPanel(focusedPanelId)
Expand Down
Loading