diff options
author | Stefan Haller <stefan@haller-berlin.de> | 2024-06-21 19:16:54 +0200 |
---|---|---|
committer | Stefan Haller <stefan@haller-berlin.de> | 2024-06-23 12:40:31 +0200 |
commit | 1a76a7da094c346ee47cba6c3acfbd0ed6f60484 (patch) | |
tree | 42d6a53330baf02126977b147fe532fc853a3f3a /pkg | |
parent | 8a16f24ecbfc424f2e43a05529c2652006322a22 (diff) |
Add test for moving a patch from an added file to an earlier commit
This currently works (albeit with a bit of manual work, as the user needs to
resolve conflicts), and we add this test just to make sure that we don't break
it with the following change.
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/integration/tests/patch_building/move_to_earlier_commit_from_added_file.go | 115 | ||||
-rw-r--r-- | pkg/integration/tests/test_list.go | 1 |
2 files changed, 116 insertions, 0 deletions
diff --git a/pkg/integration/tests/patch_building/move_to_earlier_commit_from_added_file.go b/pkg/integration/tests/patch_building/move_to_earlier_commit_from_added_file.go new file mode 100644 index 000000000..122be3884 --- /dev/null +++ b/pkg/integration/tests/patch_building/move_to_earlier_commit_from_added_file.go @@ -0,0 +1,115 @@ +package patch_building + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var MoveToEarlierCommitFromAddedFile = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Move a patch from a file that was added in a commit to an earlier commit", + ExtraCmdArgs: []string{}, + Skip: false, + SetupConfig: func(config *config.AppConfig) {}, + SetupRepo: func(shell *Shell) { + shell.EmptyCommit("first commit") + shell.EmptyCommit("destination commit") + shell.CreateFileAndAdd("file1", "1st line\n2nd line\n3rd line\n") + 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("destination commit"), + Contains("first commit"), + ). + PressEnter() + + t.Views().CommitFiles(). + IsFocused(). + Lines( + Contains("A file").IsSelected(), + ). + PressEnter() + + t.Views().PatchBuilding(). + IsFocused(). + SelectNextItem(). + PressPrimaryAction() + + t.Views().Information().Content(Contains("Building patch")) + + t.Views().Commits(). + Focus(). + SelectNextItem() + + t.Common().SelectPatchOption(Contains("Move patch to selected commit")) + + // This results in a conflict at the commit we're moving from, because + // it tries to add a file that already exists + t.Common().AcknowledgeConflicts() + + t.Views().Files(). + IsFocused(). + Lines( + Contains("AA").Contains("file"), + ). + PressEnter() + + t.Views().MergeConflicts(). + IsFocused(). + TopLines( + Contains("<<<<<<< HEAD"), + Contains("2nd line"), + Contains("======="), + Contains("1st line"), + Contains("2nd line"), + Contains("3rd line"), + Contains(">>>>>>>"), + ). + SelectNextItem(). + PressPrimaryAction() // choose the version with all three lines + + t.Common().ContinueOnConflictsResolved() + + t.Views().Commits(). + Focus(). + Lines( + Contains("commit to move from"), + Contains("destination commit").IsSelected(), + Contains("first commit"), + ). + PressEnter() + + t.Views().CommitFiles(). + IsFocused(). + Lines( + Contains("A file").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( + Contains("M file").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 4ec3c4c6a..e2ca3721f 100644 --- a/pkg/integration/tests/test_list.go +++ b/pkg/integration/tests/test_list.go @@ -229,6 +229,7 @@ var tests = []*components.IntegrationTest{ patch_building.ApplyInReverseWithConflict, patch_building.MoveRangeToIndex, patch_building.MoveToEarlierCommit, + patch_building.MoveToEarlierCommitFromAddedFile, patch_building.MoveToEarlierCommitNoKeepEmpty, patch_building.MoveToIndex, patch_building.MoveToIndexPartOfAdjacentAddedLines, |