diff --git a/cmuxTests/AppDelegateShortcutRoutingTests.swift b/cmuxTests/AppDelegateShortcutRoutingTests.swift index 250a3247..61b83a2a 100644 --- a/cmuxTests/AppDelegateShortcutRoutingTests.swift +++ b/cmuxTests/AppDelegateShortcutRoutingTests.swift @@ -855,6 +855,21 @@ final class AppDelegateShortcutRoutingTests: XCTestCase { ) } + func testKeyboardShortcutSettingsSetShortcutPostsSpecificChangeNotification() { + let notificationName = Notification.Name("cmux.keyboardShortcutSettingsDidChange") + let expectedAction = KeyboardShortcutSettings.Action.toggleSidebar.rawValue + let expectation = expectation(forNotification: notificationName, object: nil) { notification in + notification.userInfo?["action"] as? String == expectedAction + } + + KeyboardShortcutSettings.setShortcut( + StoredShortcut(key: "s", command: true, shift: false, option: false, control: true), + for: .toggleSidebar + ) + + wait(for: [expectation], timeout: 0.2) + } + func testCmdPhysicalPWithDvorakCharactersDoesNotTriggerCommandPaletteSwitcher() { guard let appDelegate = AppDelegate.shared else { XCTFail("Expected AppDelegate.shared") diff --git a/cmuxTests/GhosttyEnsureFocusWindowActivationTests.swift b/cmuxTests/GhosttyEnsureFocusWindowActivationTests.swift index e2718c9a..308c5ce2 100644 --- a/cmuxTests/GhosttyEnsureFocusWindowActivationTests.swift +++ b/cmuxTests/GhosttyEnsureFocusWindowActivationTests.swift @@ -12,34 +12,40 @@ final class GhosttyEnsureFocusWindowActivationTests: XCTestCase { func testAllowsActivationForActiveManager() { let activeManager = TabManager() let otherManager = TabManager() + let targetWindow = NSWindow() + let otherWindow = NSWindow() XCTAssertTrue( shouldAllowEnsureFocusWindowActivation( activeTabManager: activeManager, targetTabManager: activeManager, - keyWindow: NSWindow(), - mainWindow: NSWindow() + keyWindow: targetWindow, + mainWindow: targetWindow, + targetWindow: targetWindow ) ) XCTAssertFalse( shouldAllowEnsureFocusWindowActivation( activeTabManager: activeManager, targetTabManager: otherManager, - keyWindow: NSWindow(), - mainWindow: NSWindow() + keyWindow: otherWindow, + mainWindow: otherWindow, + targetWindow: targetWindow ) ) } func testAllowsActivationWhenAppHasNoKeyAndNoMainWindow() { let targetManager = TabManager() + let targetWindow = NSWindow() XCTAssertTrue( shouldAllowEnsureFocusWindowActivation( activeTabManager: nil, targetTabManager: targetManager, keyWindow: nil, - mainWindow: nil + mainWindow: nil, + targetWindow: targetWindow ) ) XCTAssertFalse( @@ -47,7 +53,8 @@ final class GhosttyEnsureFocusWindowActivationTests: XCTestCase { activeTabManager: nil, targetTabManager: targetManager, keyWindow: NSWindow(), - mainWindow: nil + mainWindow: nil, + targetWindow: targetWindow ) ) XCTAssertFalse( @@ -55,7 +62,8 @@ final class GhosttyEnsureFocusWindowActivationTests: XCTestCase { activeTabManager: nil, targetTabManager: targetManager, keyWindow: nil, - mainWindow: NSWindow() + mainWindow: NSWindow(), + targetWindow: targetWindow ) ) }