feat: add persistent Markdown notes
This commit is contained in:
@@ -3,22 +3,27 @@ import ConjureKit
|
||||
import Testing
|
||||
@testable import Conjure
|
||||
|
||||
@Test(arguments: ["launcher", "launcher-actions", "emoji", "emoji-actions", "translate-input", "translate-output", "translate-key"])
|
||||
@Test(arguments: ["launcher", "launcher-actions", "emoji", "emoji-actions", "translate-input", "translate-output", "translate-key", "notes-editor"])
|
||||
@MainActor func escapeDismissesEntireLauncher(_ destination: String) throws {
|
||||
_ = NSApplication.shared
|
||||
let suite = "ConjureEscape.\(UUID().uuidString)"
|
||||
let defaults = UserDefaults(suiteName: suite)!
|
||||
defer { defaults.removePersistentDomain(forName: suite) }
|
||||
let notesDirectory = FileManager.default.temporaryDirectory.appendingPathComponent(suite)
|
||||
defer {
|
||||
defaults.removePersistentDomain(forName: suite)
|
||||
try? FileManager.default.removeItem(at: notesDirectory)
|
||||
}
|
||||
let launcher = LauncherWindowController(
|
||||
history: LaunchHistory(defaults: defaults, now: { Date(timeIntervalSinceReferenceDate: 12_000) }),
|
||||
defaults: defaults)
|
||||
defaults: defaults, notesDirectory: notesDirectory)
|
||||
let window = try #require(launcher.window)
|
||||
defer { window.orderOut(nil) }
|
||||
let content = try #require(window.contentView)
|
||||
func descendants(_ view: NSView) -> [NSView] { [view] + view.subviews.flatMap(descendants) }
|
||||
let search = try #require(descendants(content).compactMap { $0 as? NSSearchField }.first)
|
||||
if !destination.hasPrefix("launcher") {
|
||||
search.stringValue = destination.hasPrefix("emoji") ? "emoji" : "translate"
|
||||
search.stringValue = destination.hasPrefix("emoji") ? "emoji"
|
||||
: destination.hasPrefix("notes") ? "notes" : "translate"
|
||||
launcher.controlTextDidChange(Notification(name: NSControl.textDidChangeNotification, object: search))
|
||||
_ = launcher.control(search, textView: NSTextView(), doCommandBy: #selector(NSResponder.insertNewline(_:)))
|
||||
}
|
||||
@@ -48,6 +53,9 @@ import Testing
|
||||
_ = provider.target?.perform(provider.action, with: provider)
|
||||
let key = try #require(descendants(content).compactMap { $0 as? NSSecureTextField }.first)
|
||||
window.makeFirstResponder(key)
|
||||
} else if destination == "notes-editor" {
|
||||
let editor = try #require(descendants(content).compactMap { $0 as? NotesTextView }.first)
|
||||
window.makeFirstResponder(editor)
|
||||
}
|
||||
#expect(window.isVisible)
|
||||
let escape = try #require(NSEvent.keyEvent(
|
||||
|
||||
Reference in New Issue
Block a user