Add a test for jumping to a file of a stash with diff.noprefix set

If diff.noprefix is set, the menu for jumping to a file of a stash
entry's diff leaves out the directory of a file under a top-level
directory named a or b.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
Stefan Haller
2026-10-07 13:50:30 +02:00
co-authored by Claude Opus 5.5
parent 621d7993b2
commit 8d3cfac12d
2 changed files with 51 additions and 0 deletions
@@ -0,0 +1,50 @@
package main_view
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var JumpToAFileOfAStashWithNoPrefixes = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Jump to a file in a directory named b of a stash entry's diff when diff.noprefix is set",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {
shell.CreateFileAndAdd("b/file1", "one\n")
shell.CreateFileAndAdd("file2", "one\n")
shell.Commit("one")
shell.UpdateFile("b/file1", "two\n")
shell.UpdateFile("file2", "two\n")
shell.Stash("stash one")
// git then leaves out the a/ and b/ in front of the paths of a diff. The b/
// that the paths of file1 start with is its directory.
shell.SetConfig("diff.noprefix", "true")
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Stash().
Focus().
Lines(
Contains("stash one").IsSelected(),
).
Press(keys.Universal.FocusMainView)
t.Views().Main().
IsFocused().
SelectionIsActive().
Press(keys.Universal.JumpToFile)
t.ExpectPopup().Menu().
Title(Equals("Jump to file")).
Lines(
/* EXPECTED:
Equals("b/file1"),
ACTUAL: */
Equals("file1"),
Equals("file2"),
Equals("Cancel"),
)
},
})
+1
View File
@@ -409,6 +409,7 @@ var tests = []*components.IntegrationTest{
main_view.FocusLeavesAnAlwaysSplitEmptyPane,
main_view.FocusReturnsWhenSplitCollapses,
main_view.HideSelectionWhenChangesVanish,
main_view.JumpToAFileOfAStashWithNoPrefixes,
main_view.JumpToAFileOfTheDiff,
main_view.JumpToAFileOnlyOverADiff,
main_view.KeepAWrappedLineCoveredAcrossARerender,