diff options
author | Stefan Haller <stefan@haller-berlin.de> | 2023-08-22 16:59:09 +0200 |
---|---|---|
committer | Stefan Haller <stefan@haller-berlin.de> | 2024-03-09 07:55:22 +0100 |
commit | 314efe25394349c3aeb602b826bcbe9560599660 (patch) | |
tree | de0e504d9bb4a0445ce034299481cfb5114c7a18 | |
parent | bbc680266b37d32ebb84d9357ef7aaf6e13559b5 (diff) |
Add test for creating a fixup commit and squashing fixups
We have such a test already (squash_fixups_above_first_commit.go), but it can't
be used for what we want to check here, because it uses the first commit, and we
can't move down from there. So create a new one that basically does the same
thing, but for a commit in the middle. The focus of this new test is to check
how the selection behaves; as you can see, there is a problem both when creating
a fixup and when squashing fixups. We'll address these separately in the next
commits.
-rw-r--r-- | pkg/integration/tests/interactive_rebase/squash_fixups_above.go | 58 | ||||
-rw-r--r-- | pkg/integration/tests/test_list.go | 1 |
2 files changed, 59 insertions, 0 deletions
diff --git a/pkg/integration/tests/interactive_rebase/squash_fixups_above.go b/pkg/integration/tests/interactive_rebase/squash_fixups_above.go new file mode 100644 index 000000000..9af6594ef --- /dev/null +++ b/pkg/integration/tests/interactive_rebase/squash_fixups_above.go @@ -0,0 +1,58 @@ +package interactive_rebase + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var SquashFixupsAbove = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Squashes all fixups above a commit and checks that the selected line stays correct.", + 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().Confirmation(). + Title(Equals("Create fixup commit")). + Content(Contains("Are you sure you want to create a fixup! commit for commit")). + Confirm() + }). + Lines( + Contains("fixup! commit 02"), + Contains("commit 03").IsSelected(), // wrong, we want the next line + Contains("commit 02"), + Contains("commit 01"), + ). + SelectNextItem(). + 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"), + Contains("commit 01").IsSelected(), // wrong, we want the previous line + ). + SelectPreviousItem() + + t.Views().Main(). + Content(Contains("fixup content")) + }, +}) diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go index d0525fa59..402a40acf 100644 --- a/pkg/integration/tests/test_list.go +++ b/pkg/integration/tests/test_list.go @@ -188,6 +188,7 @@ var tests = []*components.IntegrationTest{ interactive_rebase.RewordYouAreHereCommitWithEditor, interactive_rebase.SquashDownFirstCommit, interactive_rebase.SquashDownSecondCommit, + interactive_rebase.SquashFixupsAbove, interactive_rebase.SquashFixupsAboveFirstCommit, interactive_rebase.SquashFixupsInCurrentBranch, interactive_rebase.SwapInRebaseWithConflict, |