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
@@ -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()