toggling between views made possible
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user