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:
@@ -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")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user