Add shortcut change notification regression

This commit is contained in:
Lawrence Chen 2026-03-15 22:09:34 -07:00
parent eaa0d871fa
commit b1d4db1bdb
No known key found for this signature in database
2 changed files with 30 additions and 7 deletions

View file

@ -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")

View file

@ -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
)
)
}