toggling between views made possible

This commit is contained in:
2026-11-09 14:01:49 +01:00
parent cc6651c08a
commit 2887965a9e
18 changed files with 149 additions and 17 deletions
@@ -448,6 +448,18 @@ import Testing
#expect(harness.model.editor?.activePath == "a.php")
}
@Test func openDiffFromTheRowMenuClosesTheGitViewOnTheDiff() async {
let harness = WorkspaceHarness(git: snapshot([("a.php", .modified, false)]), contents: ["a.php": "<?php"])
await harness.start()
harness.model.perform(.toggleGit)
await harness.model.settle()
harness.model.perform(.showContextMenu(.gitRow(path: "a.php", isDeleted: false), anchor: CGPoint(x: 10, y: 20)))
await harness.perform(.context(.openDiff("a.php")))
#expect(!harness.model.layout.isGitViewOpen)
#expect(harness.model.editor?.activePath == "a.php")
#expect(harness.model.overlay.current == .diff(DiffOverlayRequest(path: "a.php", side: nil)))
}
@Test func thePassOnPromptInsertsIntoTheAgent() async {
let harness = WorkspaceHarness()
await harness.start()
@@ -686,6 +698,59 @@ import Testing
#expect(harness.model.overlay.current == .diff(DiffOverlayRequest(path: "a.php", side: nil, focusLine: 3)))
}
@Test func commandGOverTheSearchSwitchesToTheGitView() async {
let harness = WorkspaceHarness()
await harness.start()
harness.model.perform(.showSearch(seed: "x"))
await harness.perform(.toggleGit)
#expect(harness.model.overlay.current == .none)
#expect(harness.model.layout.isGitViewOpen)
}
@Test func commandGOverASearchAboveTheGitViewKeepsTheGitViewOpen() async {
let harness = WorkspaceHarness()
await harness.start()
await harness.perform(.toggleGit)
harness.model.perform(.showSearch(seed: "x"))
await harness.perform(.toggleGit)
#expect(harness.model.overlay.current == .none)
#expect(harness.model.layout.isGitViewOpen)
}
@Test func commandGOverTheDiffClosesItAndOpensTheGitView() async {
let harness = WorkspaceHarness(git: snapshot([("a.php", .modified, false)]), contents: ["a.php": "b"])
await harness.start()
let editor = harness.model.editor
harness.model.open("a.php")
editor?.setMode(.diff, for: "a.php")
#expect(harness.model.overlay.current == .diff(DiffOverlayRequest(path: "a.php", side: nil)))
await harness.perform(.toggleGit)
#expect(harness.model.overlay.current == .none)
#expect(editor?.mode(for: "a.php") != .diff)
#expect(harness.model.layout.isGitViewOpen)
}
@Test func commandDOverTheSearchSwitchesFromTheGitViewToTheSchemaView() async {
let harness = WorkspaceHarness()
await harness.start()
await harness.perform(.toggleGit)
harness.model.perform(.showSearch(seed: "x"))
await harness.perform(.toggleSchemaView)
#expect(harness.model.overlay.current == .none)
#expect(harness.model.layout.isSchemaViewOpen)
#expect(!harness.model.layout.isGitViewOpen)
}
@Test func commandDOverASearchAboveTheSchemaViewKeepsTheSchemaViewOpen() async {
let harness = WorkspaceHarness()
await harness.start()
await harness.perform(.toggleSchemaView)
harness.model.perform(.showSearch(seed: "x"))
await harness.perform(.toggleSchemaView)
#expect(harness.model.overlay.current == .none)
#expect(harness.model.layout.isSchemaViewOpen)
}
@Test func theRecentProjectListLeavesOutTheOpenProject() async {
let harness = WorkspaceHarness(recents: [RecentProject(path: "/elsewhere", name: "elsewhere")])
await harness.start()