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
@@ -137,6 +137,7 @@ import Testing
@Test func aGitRowOpensInTheEditorThenPassesOnItsPath() {
#expect(ContextActions.entries(for: .gitRow(path: "src/a.php", isDeleted: false)) == [
.action(.openFile("src/a.php"), label: "Open in editor"),
.action(.openDiff("src/a.php"), label: "Open diff"),
.separator,
.action(.passOnReference("src/a.php", code: nil), label: "Pass on reference"),
.action(.copyReference("src/a.php"), label: "Copy reference"),
@@ -146,6 +147,8 @@ import Testing
.action(.copyReference("gone.php"), label: "Copy reference"),
])
#expect(ContextAction.openFile("src/a.php").isEmphasized)
#expect(!ContextAction.openDiff("src/a.php").isEmphasized)
#expect(!ContextAction.openDiff("src/a.php").isDestructive)
}
@Test func aSelectionCanBeReadAloudAfterCopyReference() {
@@ -166,6 +166,21 @@ import Testing
#expect(route(KeyPress(.escape), context) == .perform(.dismissOverlay))
}
@Test func theSearchSwitchesToTheGitAndSchemaViewsAndOwnsEveryOtherKey() {
let search = KeyContext(overlay: .search, owner: .text(in: nil), schemaAvailable: true)
#expect(OverlayKind(.search(seed: "x")) == .search)
#expect(route(cmd("g"), search) == .perform(.toggleGit))
#expect(route(cmd("d"), search) == .perform(.toggleSchemaView))
#expect(route(cmd("d"), KeyContext(overlay: .search, owner: .text(in: nil))) == .pass)
#expect(route(cmd("f"), search) == .pass)
#expect(route(cmd("s"), search) == .pass)
#expect(route(cmd("g", shift: true), search) == .pass)
#expect(route(KeyPress(.character("g")), search) == .pass)
#expect(route(KeyPress(.down), search) == .pass)
#expect(route(KeyPress(.enter), search) == .pass)
#expect(route(KeyPress(.escape), search) == .perform(.dismissOverlay))
}
@Test func theWorkspaceShortcutsKeepWorkingOverTheDiff() {
let diff = KeyContext(overlay: .diff(busy: false), activePanel: .editor)
#expect(route(cmd("m"), diff) == .perform(.cycleMode))
@@ -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()