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
@@ -92,10 +92,10 @@ import Testing
@Test func textWaitsForAnotherOverlayAndOnlyTheLatestShows() async {
let harness = await started()
await harness.perform(.showNote)
await harness.perform(.showShortcuts)
await agentWrites("one", harness)
await agentWrites("two", harness)
#expect(harness.model.overlay.current == .note)
#expect(harness.model.overlay.current == .shortcuts)
await harness.perform(.dismissOverlay)
#expect(await eventually { harness.model.overlay.current == .cleanCopy })
#expect(harness.model.cleanCopy?.text == "two")
@@ -6,8 +6,8 @@ import Testing
@Test func overlaysNeverStack() {
let store = OverlayStore()
store.present(.search(seed: "foo"))
store.present(.note)
#expect(store.current == .note)
store.present(.launcher)
#expect(store.current == .launcher)
store.dismiss()
#expect(store.current == .none)
#expect(!store.isPresented)
@@ -17,11 +17,11 @@ import Testing
let store = OverlayStore()
var changes: [(Overlay, Overlay)] = []
store.onChange = { changes.append(($0, $1)) }
store.present(.note)
store.present(.note)
store.present(.launcher)
store.present(.launcher)
store.present(.shortcuts)
store.dismiss()
#expect(changes.map(\.0) == [.none, .note, .shortcuts])
#expect(changes.map(\.1) == [.note, .shortcuts, .none])
#expect(changes.map(\.0) == [.none, .launcher, .shortcuts])
#expect(changes.map(\.1) == [.launcher, .shortcuts, .none])
}
}
@@ -27,10 +27,8 @@ import Testing
@Test func savingFromTheCloseQuestionWritesBeforeTheWindowGoes() async {
let harness = await dirtyHarness()
harness.system.unsavedCloseChoice = .save
harness.model.note?.text = "thought"
#expect(await harness.model.prepareToClose())
#expect(harness.files.current("a.php") == "<?php // unsaved")
#expect(harness.notes.writes == ["thought"])
#expect(harness.session.sessions["/fake/project"]?.active == "a.php")
}
@@ -68,25 +66,6 @@ import Testing
#expect(harness.model.editor !== oldEditor)
#expect(harness.model.editor?.states["a.php"] == nil)
}
@Test func aFailedNoteSaveSaysSo() async {
let harness = WorkspaceHarness()
await harness.start()
harness.notes.failWrites = true
harness.model.note?.text = "keep me"
harness.model.windowDidResignKey()
await harness.model.settle()
#expect(harness.toastTitles.contains("Save failed"))
}
@Test func anOutsideEditOfTheNoteIsPickedUp() async {
let harness = WorkspaceHarness(note: "before")
await harness.start()
harness.notes.setOnDisk("written by the agent")
await harness.model.handle(.project)
await harness.model.settle()
#expect(harness.model.note?.text == "written by the agent")
}
}
@MainActor
@@ -8,7 +8,7 @@ import Testing
@MainActor
@Suite struct WorkspaceModelLifecycleTests {
@Test func startingAProjectLoadsEverythingOnceAndWatchesIt() async {
let harness = WorkspaceHarness(note: "remember this", git: snapshot([("a.php", .modified, false)]))
let harness = WorkspaceHarness(git: snapshot([("a.php", .modified, false)]))
await harness.start()
#expect(harness.model.isReady)
#expect(harness.config.resolves == 1)
@@ -16,7 +16,6 @@ import Testing
#expect(harness.files.treeLoads == 1)
#expect(harness.model.sourceControl?.state.changes.map(\.path) == ["a.php"])
#expect(harness.model.explorer?.tree != nil)
#expect(harness.model.note?.text == "remember this")
#expect(harness.watchers.last?.root == harness.root)
#expect(harness.recents.projects.first?.path == harness.root.path)
#expect(harness.model.sourceControl?.isPolling == true)
@@ -96,17 +95,15 @@ import Testing
}
@Test func switchingProjectsEndsTheOldProjectCleanly() async {
let harness = WorkspaceHarness(note: "old", contents: ["a.php": "<?php"])
let harness = WorkspaceHarness(contents: ["a.php": "<?php"])
await harness.start()
harness.model.open("a.php")
await harness.model.settle()
harness.model.note?.text = "unsaved thought"
let firstWatcher = harness.watchers.last
await harness.model.openProject(URL(fileURLWithPath: "/fake/other"))
#expect(firstWatcher?.stopped == true)
#expect(harness.watchers.made.count == 2)
#expect(harness.agent.terminations == 1)
#expect(harness.notes.writes == ["unsaved thought"])
#expect(harness.session.sessions["/fake/project"]?.active == "a.php")
}
@@ -370,17 +367,6 @@ import Testing
#expect(harness.git.commits.isEmpty)
}
@Test func commandPPassesTheWholeNoteAndClosesIt() async {
let harness = WorkspaceHarness(note: " fix the tests ")
await harness.start()
harness.model.perform(.showNote)
await harness.perform(.passNote)
#expect(harness.agent.sent == [BracketedPaste.wrap("fix the tests", composerHasText: false)])
#expect(harness.model.overlay.current == .none)
#expect(harness.git.pushes == 0)
#expect(harness.toastTitles == ["Note passed to agent"])
}
@Test func thePassOnPromptInsertsIntoTheAgent() async {
let harness = WorkspaceHarness()
await harness.start()
@@ -550,8 +536,8 @@ import Testing
@Test func escClosesOnlyTheOneOpenOverlay() {
let harness = WorkspaceHarness()
harness.model.perform(.showShortcuts)
harness.model.perform(.showNote)
#expect(harness.model.overlay.current == .note)
harness.model.perform(.showSearch(seed: "x"))
#expect(harness.model.overlay.current == .search(seed: "x"))
harness.model.perform(.dismissOverlay)
#expect(harness.model.overlay.current == .none)
}
@@ -563,15 +549,6 @@ import Testing
#expect(harness.model.overlay.current == .passOn(PassOnRequest(reference: "src/a.php", anchor: CGPoint(x: 300, y: 120))))
}
@Test func closingTheNoteInAnyWaySavesIt() async {
let harness = WorkspaceHarness(note: "old")
await harness.start()
harness.model.note?.text = "new text"
harness.model.perform(.showNote)
await harness.perform(.showShortcuts)
#expect(harness.notes.writes == ["new text"])
}
@Test func theDiffOverlayGivesBackTheModeItCovered() async {
let harness = WorkspaceHarness(git: snapshot([("a.md", .modified, false)]), contents: ["a.md": "b"])
await harness.start()