mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-08-06 22:33:07 +02:00
Add test for moving patch to index when there's a modified file
This is functionality that works already, we only add the test for more complete test coverage. However, there's a detail problem, and the test demonstrates this: we keep the stash even if there was no conflict. We'll fix this next.
This commit is contained in:
@ -0,0 +1,64 @@
|
||||
package patch_building
|
||||
|
||||
import (
|
||||
"github.com/jesseduffield/lazygit/pkg/config"
|
||||
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||
)
|
||||
|
||||
var MoveToIndexWithModifiedFile = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Description: "Move a patch from a commit to the index, with a modified file in the working tree that conflicts with the patch",
|
||||
ExtraCmdArgs: []string{},
|
||||
Skip: false,
|
||||
SetupConfig: func(config *config.AppConfig) {},
|
||||
SetupRepo: func(shell *Shell) {
|
||||
shell.CreateFileAndAdd("file1", "1\n2\n3\n4\n")
|
||||
shell.Commit("first commit")
|
||||
shell.UpdateFileAndAdd("file1", "11\n2\n3\n4\n")
|
||||
shell.Commit("second commit")
|
||||
shell.UpdateFile("file1", "111\n2\n3\n4\n")
|
||||
},
|
||||
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.Views().Commits().
|
||||
Focus().
|
||||
Lines(
|
||||
Contains("second commit").IsSelected(),
|
||||
Contains("first commit"),
|
||||
).
|
||||
PressEnter()
|
||||
|
||||
t.Views().CommitFiles().
|
||||
IsFocused().
|
||||
Lines(
|
||||
Equals("M file1"),
|
||||
).
|
||||
PressPrimaryAction()
|
||||
|
||||
t.Views().Information().Content(Contains("Building patch"))
|
||||
|
||||
t.Views().Secondary().Content(Contains("-1\n+11"))
|
||||
|
||||
t.Common().SelectPatchOption(Contains("Move patch out into index"))
|
||||
|
||||
t.ExpectPopup().Confirmation().Title(Equals("Must stash")).
|
||||
Content(Contains("Pulling a patch out into the index requires stashing and unstashing your changes.")).
|
||||
Confirm()
|
||||
|
||||
t.Views().Files().
|
||||
Focus().
|
||||
Lines(
|
||||
Equals("MM file1"),
|
||||
)
|
||||
|
||||
t.Views().Main().
|
||||
Content(Contains("-11\n+111\n"))
|
||||
t.Views().Secondary().
|
||||
Content(Contains("-1\n+11\n"))
|
||||
|
||||
/* EXPECTED:
|
||||
t.Views().Stash().IsEmpty()
|
||||
ACTUAL: */
|
||||
t.Views().Stash().Lines(
|
||||
Contains("Auto-stashing changes"),
|
||||
)
|
||||
},
|
||||
})
|
@ -310,6 +310,7 @@ var tests = []*components.IntegrationTest{
|
||||
patch_building.MoveToIndexPartOfAdjacentAddedLines,
|
||||
patch_building.MoveToIndexPartial,
|
||||
patch_building.MoveToIndexWithConflict,
|
||||
patch_building.MoveToIndexWithModifiedFile,
|
||||
patch_building.MoveToIndexWorksEvenIfNoprefixIsSet,
|
||||
patch_building.MoveToLaterCommit,
|
||||
patch_building.MoveToLaterCommitPartialHunk,
|
||||
|
Reference in New Issue
Block a user