adds nice git interface
This commit is contained in:
@@ -61,13 +61,13 @@ import Testing
|
||||
await harness.start()
|
||||
var changed = HelderConfig.defaults
|
||||
changed.ai.command = "other-agent"
|
||||
changed.git.confirmStage = true
|
||||
changed.git.confirmDiscard = false
|
||||
changed.editor.tabSize = 8
|
||||
harness.config.set(changed)
|
||||
await harness.model.handle(.config)
|
||||
#expect(harness.model.config.ai.command == "other-agent")
|
||||
#expect(harness.model.terminal.config.ai.command == "other-agent")
|
||||
#expect(harness.model.sourceControl?.config.confirmStage == true)
|
||||
#expect(harness.model.sourceControl?.config.confirmDiscard == false)
|
||||
#expect(harness.model.editor?.editorConfig.tabSize == 8)
|
||||
}
|
||||
|
||||
@@ -204,11 +204,11 @@ import Testing
|
||||
#expect(harness.files.treeLoads == 2)
|
||||
}
|
||||
|
||||
@Test func focusingSourceControlRefreshesGitOnce() async {
|
||||
@Test func openingTheGitViewRefreshesGitOnce() async {
|
||||
let harness = WorkspaceHarness()
|
||||
await harness.start()
|
||||
harness.model.pointerFocused(.sourceControl)
|
||||
harness.model.pointerFocused(.sourceControl)
|
||||
harness.model.perform(.toggleGit)
|
||||
harness.model.perform(.focusCommitMessage)
|
||||
await harness.model.settle()
|
||||
#expect(harness.git.loads == 2)
|
||||
}
|
||||
@@ -277,36 +277,29 @@ import Testing
|
||||
}
|
||||
|
||||
@Test func discardAsksUnderTheConfigThenReloadsTheFile() async {
|
||||
let harness = WorkspaceHarness(contents: ["a.php": "edited"])
|
||||
let harness = WorkspaceHarness(git: snapshot([("a.php", .modified, false)]), contents: ["a.php": "edited"])
|
||||
await harness.start()
|
||||
harness.model.open("a.php")
|
||||
await harness.model.settle()
|
||||
await harness.perform(.context(.discard("a.php")))
|
||||
await harness.perform(.context(.gitDiscard(["a.php"])))
|
||||
guard case let .confirm(request) = harness.model.overlay.current else {
|
||||
Issue.record("expected a confirm overlay")
|
||||
return
|
||||
}
|
||||
#expect(request.confirmLabel == "Discard")
|
||||
#expect(harness.git.executed.isEmpty)
|
||||
harness.files.set("a.php", "committed")
|
||||
await harness.perform(.confirmPending)
|
||||
#expect(harness.git.discarded == [["a.php"]])
|
||||
#expect(harness.git.executed == [["restore", "--", "a.php"]])
|
||||
#expect(harness.model.editor?.text(for: "a.php") == "committed")
|
||||
#expect(harness.toastTitles == ["Discarded changes"])
|
||||
}
|
||||
|
||||
@Test func stagingRunsStraightAwayUnlessTheConfigAsks() async {
|
||||
let harness = WorkspaceHarness()
|
||||
@Test func stagingRunsGitStraightAway() async {
|
||||
let harness = WorkspaceHarness(git: snapshot([("a.php", .modified, false), ("b.php", .modified, false)]))
|
||||
await harness.start()
|
||||
await harness.perform(.context(.stage("a.php")))
|
||||
#expect(harness.git.staged == [["a.php"]])
|
||||
|
||||
var config = HelderConfig.defaults
|
||||
config.git.confirmStage = true
|
||||
let asking = WorkspaceHarness(config: config)
|
||||
await asking.start()
|
||||
await asking.perform(.context(.stage("a.php")))
|
||||
#expect(asking.git.staged.isEmpty)
|
||||
#expect(asking.model.overlay.current != .none)
|
||||
await harness.perform(.stage(["a.php"]))
|
||||
#expect(harness.git.executed == [["add", "--", "a.php"]])
|
||||
#expect(harness.model.overlay.current == .none)
|
||||
}
|
||||
|
||||
@Test func revealInFinderResolvesAgainstTheProject() async {
|
||||
@@ -354,17 +347,32 @@ import Testing
|
||||
await harness.start()
|
||||
harness.model.sourceControl?.setCommitMessage("fix it")
|
||||
await harness.perform(.commit)
|
||||
#expect(harness.git.commits == ["fix it"])
|
||||
#expect(harness.git.executed == [["commit", "-m", "fix it"]])
|
||||
await harness.perform(.push)
|
||||
#expect(harness.git.pushes == 1)
|
||||
#expect(harness.toastTitles == ["Committed 1 file", "Pushing…", "Pushed"])
|
||||
#expect(harness.git.executed.last == ["push"])
|
||||
#expect(harness.toastTitles == ["Committed 1 file", "Pushed to origin/main"])
|
||||
}
|
||||
|
||||
@Test func commitWithoutAMessageDoesNothing() async {
|
||||
@Test func commitWithoutAMessageStillAsksGitThenFocusesTheMessage() async {
|
||||
let harness = WorkspaceHarness(git: snapshot([("a.php", .modified, true)]))
|
||||
await harness.start()
|
||||
harness.git.setRun(FakeGitRun(exitCode: 1, lines: [("Aborting commit due to empty commit message.", true)]), forCommand: "commit")
|
||||
await harness.perform(.commit)
|
||||
#expect(harness.git.commits.isEmpty)
|
||||
#expect(harness.git.executed == [["commit", "-m", ""]])
|
||||
#expect(harness.model.focusRequest?.target == .commitMessage)
|
||||
#expect(harness.toastTitles == ["Commit failed"])
|
||||
}
|
||||
|
||||
@Test func theRowMenuOpensTheFileAndClosesTheGitView() 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(.openFile("a.php")))
|
||||
#expect(!harness.model.layout.isGitViewOpen)
|
||||
#expect(harness.model.overlay.current == .none)
|
||||
#expect(harness.model.editor?.activePath == "a.php")
|
||||
}
|
||||
|
||||
@Test func thePassOnPromptInsertsIntoTheAgent() async {
|
||||
@@ -466,14 +474,49 @@ import Testing
|
||||
#expect(harness.model.focusRequest?.target == .panel(.editor))
|
||||
}
|
||||
|
||||
@Test func commandCShowsAHiddenGitColumnAndFocusesTheCommitBox() async {
|
||||
@Test func commandCOpensTheGitViewOnItsMessageField() async {
|
||||
let harness = WorkspaceHarness()
|
||||
await harness.start()
|
||||
harness.model.perform(.focusCommitMessage)
|
||||
#expect(harness.model.layout.isGitViewOpen)
|
||||
#expect(harness.model.focusRequest?.target == .commitMessage)
|
||||
harness.model.focusTaken(.commitMessage)
|
||||
harness.model.perform(.focusCommitMessage)
|
||||
#expect(harness.model.layout.isGitViewOpen)
|
||||
#expect(harness.model.focusRequest?.target == .commitMessage)
|
||||
}
|
||||
|
||||
@Test func commandGTogglesTheGitViewAndClosingGivesTheKeyboardBack() async {
|
||||
let harness = WorkspaceHarness()
|
||||
await harness.start()
|
||||
harness.model.perform(.focus(.terminal))
|
||||
harness.model.perform(.toggleGit)
|
||||
#expect(harness.model.layout.isGitViewOpen)
|
||||
#expect(harness.model.focusRequest?.target == .commitMessage)
|
||||
#expect(harness.model.layout.visibility == .all)
|
||||
harness.model.perform(.toggleGit)
|
||||
#expect(!harness.model.layout.isGitViewOpen)
|
||||
#expect(harness.model.focusRequest?.target == .panel(.terminal))
|
||||
}
|
||||
|
||||
@Test func closingTheGitViewWithNoActiveColumnDropsTheFieldRequest() async {
|
||||
let harness = WorkspaceHarness()
|
||||
await harness.start()
|
||||
harness.model.perform(.toggleGit)
|
||||
#expect(!harness.model.layout.isVisible(.sourceControl))
|
||||
harness.model.perform(.focusCommitMessage)
|
||||
#expect(harness.model.layout.isVisible(.sourceControl))
|
||||
#expect(harness.model.focusRequest?.target == .commitMessage)
|
||||
harness.model.perform(.closeGitView)
|
||||
#expect(!harness.model.layout.isGitViewOpen)
|
||||
#expect(harness.model.focusRequest == nil)
|
||||
harness.model.perform(.closeGitView)
|
||||
#expect(!harness.model.layout.isGitViewOpen)
|
||||
}
|
||||
|
||||
@Test func paneTogglesLeaveTheGitViewAlone() async {
|
||||
let harness = WorkspaceHarness()
|
||||
await harness.start()
|
||||
harness.model.perform(.toggleGit)
|
||||
harness.model.perform(.togglePane(.explorer))
|
||||
#expect(!harness.model.layout.isVisible(.explorer))
|
||||
#expect(harness.model.layout.isGitViewOpen)
|
||||
}
|
||||
|
||||
@Test func aPaneToggleHidesItsColumnAndAHiddenColumnTakesNoFocus() async {
|
||||
@@ -491,18 +534,19 @@ import Testing
|
||||
#expect(harness.model.layout.isVisible(.terminal))
|
||||
}
|
||||
|
||||
@Test func rowCursorKeysDriveTheFocusedList() async {
|
||||
let harness = WorkspaceHarness(git: snapshot([("a.php", .modified, false), ("b.php", .added, true)]),
|
||||
contents: ["a.php": "", "b.php": ""])
|
||||
@Test func rowCursorKeysDriveOnlyTheExplorer() async {
|
||||
let harness = WorkspaceHarness(contents: ["README.md": "# hi"])
|
||||
await harness.start()
|
||||
harness.model.perform(.focus(.sourceControl))
|
||||
let before = harness.model.explorer?.selectedPath
|
||||
harness.model.perform(.focus(.editor))
|
||||
harness.model.perform(.moveRowCursor(1))
|
||||
#expect(harness.model.sourceControl?.selectedRow?.path == "b.php")
|
||||
harness.model.perform(.moveRowCursor(1))
|
||||
#expect(harness.model.sourceControl?.selectedRow?.path == "a.php")
|
||||
#expect(harness.model.explorer?.selectedPath == before)
|
||||
harness.model.perform(.focus(.explorer))
|
||||
harness.model.perform(.moveRowCursor(10))
|
||||
harness.model.perform(.moveRowCursor(10))
|
||||
#expect(harness.model.explorer?.selectedPath == "README.md")
|
||||
await harness.perform(.openSelectedRow)
|
||||
#expect(harness.model.editor?.activePath == "a.php")
|
||||
#expect(harness.model.editor?.sides["a.php"] == .unstaged)
|
||||
#expect(harness.model.editor?.activePath == "README.md")
|
||||
}
|
||||
|
||||
@Test func commandRightOnARowOpensItsMenuBesideTheColumn() async {
|
||||
|
||||
Reference in New Issue
Block a user