before the great git rework

This commit is contained in:
2026-10-30 11:27:44 +01:00
parent 9bdda896af
commit b9c03a7637
45 changed files with 70 additions and 562 deletions
@@ -1,99 +0,0 @@
import HelderUI
import Testing
@MainActor
@Suite struct NoteStoreTests {
@Test func loadsTheNoteThatIsAlreadyOnDisk() async {
let store = NoteStore(notes: FakeNotes("earlier thoughts\n"))
await store.load()
#expect(store.text == "earlier thoughts\n")
#expect(!store.isDirty)
}
@Test func nothingIsWrittenWhileTyping() async {
let notes = FakeNotes()
let store = NoteStore(notes: notes)
await store.load()
store.text = "buy milk"
#expect(notes.writes.isEmpty)
#expect(store.isDirty)
}
@Test func savingOnFocusLossWritesTheEditedText() async {
let notes = FakeNotes()
let store = NoteStore(notes: notes)
await store.load()
store.text = "buy milk"
await store.save()
#expect(notes.writes == ["buy milk"])
#expect(notes.onDisk == "buy milk")
#expect(!store.isDirty)
}
@Test func anUnchangedNoteIsNeverRewritten() async {
let notes = FakeNotes("unchanged")
let store = NoteStore(notes: notes)
await store.load()
await store.save()
await store.save()
#expect(notes.writes.isEmpty)
}
@Test func aFailedWriteLeavesTheNoteDirtyForTheNextTry() async {
let notes = FakeNotes()
notes.failWrites = true
let store = NoteStore(notes: notes)
store.text = "keep me"
await store.save()
#expect(store.isDirty)
}
@Test func passableTextIsTheTrimmedNote() {
let store = NoteStore(notes: FakeNotes())
store.text = " refactor the policy\n\n"
#expect(store.passableText == "refactor the policy")
}
@Test func anEmptyNoteHasNothingToPass() {
let store = NoteStore(notes: FakeNotes())
store.text = " \n "
#expect(store.passableText == nil)
}
@Test func aFailedWriteRaisesAToast() async {
let notes = FakeNotes()
notes.failWrites = true
let store = NoteStore(notes: notes)
var toasts: [String?] = []
store.notify = { title, detail in toasts.append(title + " " + (detail ?? "")) }
store.text = "keep me"
#expect(await store.save() == false)
#expect(toasts == ["Save failed .notes.txt"])
}
@Test func anOutsideEditReplacesACleanNote() async {
let notes = FakeNotes("old")
let store = NoteStore(notes: notes)
await store.load()
notes.setOnDisk("new from the agent")
await store.reloadIfClean()
#expect(store.text == "new from the agent")
#expect(!store.isDirty)
}
@Test func anOutsideEditNeverReplacesUnsavedTyping() async {
let notes = FakeNotes("old")
let store = NoteStore(notes: notes)
await store.load()
store.text = "typing"
notes.setOnDisk("new from the agent")
await store.reloadIfClean()
#expect(store.text == "typing")
}
@Test func theFooterCountsCharacters() {
let store = NoteStore(notes: FakeNotes())
store.text = "héllo"
#expect(store.characterCount == 5)
}
}
@@ -11,7 +11,7 @@ import Testing
@Test func everyShortcutTheAppHandlesIsListed() {
let listed = Set(ShortcutCatalog.groups.flatMap(\.rows).map { $0.keys.joined() })
let handled = ["⌘F", "⌘↑↓", "↵", "⌘←→", "↑↓", "⇧⌘O", "⌘O", "⌘→", "⌘N", "⌘P",
let handled = ["⌘F", "⌘↑↓", "↵", "⌘←→", "↑↓", "⇧⌘O", "⌘O", "⌘→", "⌘P",
"⌘C", "⌘↵", "⌘G", "⌘M", "⌘S", "⌘.", "⌘A", "⌘L", "Esc",
"⌘W", "⌘R", "⇧⌘N", "?", "⌘click", "⌘0", "⌘+", "⌘−"]
#expect(Set(handled).subtracting(listed).isEmpty)
@@ -35,11 +35,6 @@ import Testing
#expect(!row.label.isEmpty)
}
}
@Test func theNotePassOnSitsInTheAgentGroup() {
let agent = ShortcutCatalog.groups.first { $0.title == "Agent" }
#expect(agent?.rows.contains(ShortcutRow(keys: ["⌘", "P"], label: "Pass on the whole note")) == true)
}
}
@Suite struct ListCursorTests {