feat: Notitie editor in the app, dictation routed to system or editor

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-02 09:47:54 +02:00
co-authored by Claude Sonnet 5.5
parent ab7359156b
commit f390d310f4
12 changed files with 433 additions and 34 deletions
+33 -15
View File
@@ -2,26 +2,44 @@ import Foundation
import Testing
@testable import SstCore
struct GatedInserterTests {
@Test func insertsWhenAllowed() async throws {
let inner = FakeInserter()
try await GatedInserter(inner: inner, shouldInsert: { true }).insert("hallo")
#expect(inner.inserted == ["hallo"])
struct RoutingInserterTests {
@Test func sendsToTheSystemRoute() async throws {
let system = FakeInserter(), editor = FakeInserter()
try await RoutingInserter(system: system, editor: editor, route: { .system }).insert("hallo")
#expect(system.inserted == ["hallo"])
#expect(editor.inserted.isEmpty)
}
@Test func staysSilentWhenNotAllowed() async throws {
let inner = FakeInserter()
try await GatedInserter(inner: inner, shouldInsert: { false }).insert("hallo")
#expect(inner.inserted.isEmpty)
@Test func sendsToTheEditorRoute() async throws {
let system = FakeInserter(), editor = FakeInserter()
try await RoutingInserter(system: system, editor: editor, route: { .editor }).insert("hallo")
#expect(editor.inserted == ["hallo"])
#expect(system.inserted.isEmpty)
}
@Test func dropsTheTextOnNone() async throws {
let system = FakeInserter(), editor = FakeInserter()
try await RoutingInserter(system: system, editor: editor, route: { .none }).insert("hallo")
#expect(system.inserted.isEmpty)
#expect(editor.inserted.isEmpty)
}
@Test func askedAtInsertionTimeNotAtCreation() async throws {
let inner = FakeInserter()
var allowed = false
let gated = GatedInserter(inner: inner, shouldInsert: { allowed })
allowed = true
try await gated.insert("nu wel")
#expect(inner.inserted == ["nu wel"])
let system = FakeInserter(), editor = FakeInserter()
var current = InsertionRoute.none
let router = RoutingInserter(system: system, editor: editor, route: { current })
current = .editor
try await router.insert("nu wel")
#expect(editor.inserted == ["nu wel"])
}
@Test func propagatesInserterErrors() async {
struct Boom: Error {}
let system = FakeInserter()
system.error = Boom()
await #expect(throws: Boom.self) {
try await RoutingInserter(system: system, editor: FakeInserter(), route: { .system }).insert("x")
}
}
}