diff options
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/integration/tests/patch_building/move_to_new_commit_from_deleted_file.go | 88 | ||||
-rw-r--r-- | pkg/integration/tests/test_list.go | 1 |
2 files changed, 89 insertions, 0 deletions
diff --git a/pkg/integration/tests/patch_building/move_to_new_commit_from_deleted_file.go b/pkg/integration/tests/patch_building/move_to_new_commit_from_deleted_file.go new file mode 100644 index 000000000..2c51acf85 --- /dev/null +++ b/pkg/integration/tests/patch_building/move_to_new_commit_from_deleted_file.go @@ -0,0 +1,88 @@ +package patch_building + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var MoveToNewCommitFromDeletedFile = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Move a patch from a file that was deleted in a commit to a new commit", + ExtraCmdArgs: []string{}, + Skip: false, + SetupConfig: func(config *config.AppConfig) {}, + SetupRepo: func(shell *Shell) { + shell.CreateFileAndAdd("file1", "1st line\n2nd line\n3rd line\n") + shell.Commit("first commit") + shell.DeleteFileAndAdd("file1") + shell.Commit("commit to move from") + }, + Run: func(t *TestDriver, keys config.KeybindingConfig) { + t.Views().Commits(). + Focus(). + Lines( + Contains("commit to move from").IsSelected(), + Contains("first commit"), + ). + PressEnter() + + t.Views().CommitFiles(). + IsFocused(). + Lines( + Contains("D file1").IsSelected(), + ). + PressEnter() + + t.Views().PatchBuilding(). + IsFocused(). + SelectNextItem(). + PressPrimaryAction() + + t.Views().Information().Content(Contains("Building patch")) + + t.Common().SelectPatchOption(Contains("Move patch into new commit")) + + t.ExpectPopup().CommitMessagePanel(). + InitialText(Equals("")). + Type("new commit").Confirm() + + t.Views().Commits(). + IsFocused(). + Lines( + Contains("new commit").IsSelected(), + Contains("commit to move from"), + Contains("first commit"), + ). + PressEnter() + + t.Views().CommitFiles(). + IsFocused(). + Lines( + Contains("D file1").IsSelected(), + ). + Tap(func() { + t.Views().Main().ContainsLines( + Equals("-2nd line"), + ) + }). + PressEscape() + + t.Views().Commits(). + IsFocused(). + NavigateToLine(Contains("commit to move from")). + PressEnter() + + t.Views().CommitFiles(). + IsFocused(). + Lines( + // In the original commit the file is no longer deleted, but modified + Contains("M file1").IsSelected(), + ). + Tap(func() { + t.Views().Main().ContainsLines( + Equals("-1st line"), + Equals(" 2nd line"), + Equals("-3rd line"), + ) + }) + }, +}) diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go index cc7fc6ca1..4ec3c4c6a 100644 --- a/pkg/integration/tests/test_list.go +++ b/pkg/integration/tests/test_list.go @@ -238,6 +238,7 @@ var tests = []*components.IntegrationTest{ patch_building.MoveToLaterCommit, patch_building.MoveToLaterCommitPartialHunk, patch_building.MoveToNewCommit, + patch_building.MoveToNewCommitFromDeletedFile, patch_building.MoveToNewCommitPartialHunk, patch_building.RemoveFromCommit, patch_building.ResetWithEscape, |