diff options
author | Stefan Haller <stefan@haller-berlin.de> | 2024-06-22 10:01:29 +0200 |
---|---|---|
committer | Stefan Haller <stefan@haller-berlin.de> | 2024-06-23 12:40:31 +0200 |
commit | 8a16f24ecbfc424f2e43a05529c2652006322a22 (patch) | |
tree | 74f42500bb9feaa2ab71023ded853146ed9fe002 /pkg | |
parent | e2b4d9cff31de368ea88c131a8b7487de726c75a (diff) |
Add test for moving a patch from a deleted file to a new commit
This currently works, we add it as a regression test to make sure we don't break
it. It is an interesting test because it turns the deletion of the file in the
moved-from commit into a modification.
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, |