diff options
Diffstat (limited to 'pkg/integration')
4 files changed, 65 insertions, 4 deletions
diff --git a/pkg/integration/tests/commit/create_amend_commit.go b/pkg/integration/tests/commit/create_amend_commit.go new file mode 100644 index 000000000..5777b2abb --- /dev/null +++ b/pkg/integration/tests/commit/create_amend_commit.go @@ -0,0 +1,60 @@ +package commit + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var CreateAmendCommit = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Create an amend commit for an existing commit", + ExtraCmdArgs: []string{}, + Skip: false, + SetupConfig: func(config *config.AppConfig) {}, + SetupRepo: func(shell *Shell) { + shell. + CreateNCommits(3). + CreateFileAndAdd("fixup-file", "fixup content") + }, + Run: func(t *TestDriver, keys config.KeybindingConfig) { + t.Views().Commits(). + Focus(). + Lines( + Contains("commit 03"), + Contains("commit 02"), + Contains("commit 01"), + ). + NavigateToLine(Contains("commit 02")). + Press(keys.Commits.CreateFixupCommit). + Tap(func() { + t.ExpectPopup().Menu(). + Title(Equals("Create fixup commit")). + Select(Contains("amend! commit with changes")). + Confirm() + t.ExpectPopup().CommitMessagePanel(). + Content(Equals("commit 02")). + Type(" amended").Confirm() + }). + Lines( + Contains("amend! commit 02"), + Contains("commit 03"), + Contains("commit 02").IsSelected(), + Contains("commit 01"), + ) + + if t.Git().Version().IsAtLeast(2, 32, 0) { // Support for auto-squashing "amend!" commits was added in git 2.32.0 + t.Views().Commits(). + Press(keys.Commits.SquashAboveCommits). + Tap(func() { + t.ExpectPopup().Menu(). + Title(Equals("Apply fixup commits")). + Select(Contains("Above the selected commit")). + Confirm() + }). + Lines( + Contains("commit 03"), + Contains("commit 02 amended").IsSelected(), + Contains("commit 01"), + ) + } + }, +}) diff --git a/pkg/integration/tests/interactive_rebase/squash_fixups_above.go b/pkg/integration/tests/interactive_rebase/squash_fixups_above.go index e87addce0..467a66154 100644 --- a/pkg/integration/tests/interactive_rebase/squash_fixups_above.go +++ b/pkg/integration/tests/interactive_rebase/squash_fixups_above.go @@ -26,9 +26,9 @@ var SquashFixupsAbove = NewIntegrationTest(NewIntegrationTestArgs{ NavigateToLine(Contains("commit 02")). Press(keys.Commits.CreateFixupCommit). Tap(func() { - t.ExpectPopup().Confirmation(). + t.ExpectPopup().Menu(). Title(Equals("Create fixup commit")). - Content(Contains("Are you sure you want to create a fixup! commit for commit")). + Select(Contains("fixup! commit")). Confirm() }). Lines( diff --git a/pkg/integration/tests/interactive_rebase/squash_fixups_above_first_commit.go b/pkg/integration/tests/interactive_rebase/squash_fixups_above_first_commit.go index 9445dcf58..2d71093ba 100644 --- a/pkg/integration/tests/interactive_rebase/squash_fixups_above_first_commit.go +++ b/pkg/integration/tests/interactive_rebase/squash_fixups_above_first_commit.go @@ -25,9 +25,9 @@ var SquashFixupsAboveFirstCommit = NewIntegrationTest(NewIntegrationTestArgs{ NavigateToLine(Contains("commit 01")). Press(keys.Commits.CreateFixupCommit). Tap(func() { - t.ExpectPopup().Confirmation(). + t.ExpectPopup().Menu(). Title(Equals("Create fixup commit")). - Content(Contains("Are you sure you want to create a fixup! commit for commit")). + Select(Contains("fixup! commit")). Confirm() }). NavigateToLine(Contains("commit 01").DoesNotContain("fixup!")). diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go index 0a78d0193..1dbfe95fb 100644 --- a/pkg/integration/tests/test_list.go +++ b/pkg/integration/tests/test_list.go @@ -72,6 +72,7 @@ var tests = []*components.IntegrationTest{ commit.CommitSwitchToEditor, commit.CommitWipWithPrefix, commit.CommitWithPrefix, + commit.CreateAmendCommit, commit.CreateTag, commit.DiscardOldFileChanges, commit.FindBaseCommitForFixup, |