feat: open providers with Command-P and dismiss pickers with Escape

This commit is contained in:
2026-10-18 00:34:15 +02:00
parent 86632f1d86
commit f12ef7e7a1
6 changed files with 42 additions and 10 deletions
@@ -3,8 +3,8 @@ import ConjureKit
import Testing
@testable import Conjure
@Test(arguments: ["launcher", "launcher-actions", "emoji", "emoji-actions", "translate-input", "translate-output", "notes-editor"])
@MainActor func escapeDismissesEntireLauncher(_ destination: String) throws {
@Test(arguments: ["launcher", "launcher-actions", "emoji", "emoji-actions", "translate-input", "translate-output", "translate-actions", "translate-providers", "notes-editor"])
@MainActor func escapeClosesPickerBeforeDismissingLauncher(_ destination: String) throws {
_ = NSApplication.shared
let suite = "ConjureEscape.\(UUID().uuidString)"
let defaults = UserDefaults(suiteName: suite)!
@@ -42,6 +42,17 @@ import Testing
$0.title == "Actions" && $0.target is EmojiPickerController
})
(button.target as? EmojiPickerController)?.showActions()
} else if destination == "translate-actions" {
let button = try #require(descendants(content).compactMap { $0 as? NSButton }.first {
$0.title == "Actions" && $0.target is TranslationController
})
button.performClick(nil)
} else if destination == "translate-providers" {
let shortcut = try #require(NSEvent.keyEvent(
with: .keyDown, location: .zero, modifierFlags: .command, timestamp: 1,
windowNumber: window.windowNumber, context: nil, characters: "p",
charactersIgnoringModifiers: "p", isARepeat: false, keyCode: 35))
#expect(window.performKeyEquivalent(with: shortcut))
} else if destination == "translate-output" {
let output = try #require(descendants(content).compactMap { $0 as? NSTextView }.first {
$0.accessibilityLabel() == "Japanese translation"
@@ -57,6 +68,11 @@ import Testing
windowNumber: window.windowNumber, context: nil, characters: "\u{1b}",
charactersIgnoringModifiers: "\u{1b}", isARepeat: false, keyCode: 53))
window.sendEvent(escape)
if destination.hasSuffix("-actions") || destination == "translate-providers" {
#expect(window.isVisible)
#expect(window.firstResponder === search.currentEditor())
window.sendEvent(escape)
}
#expect(!window.isVisible)
#expect(!descendants(content).contains { $0 is NSCollectionView })
}