diff options
author | Stefan Haller <stefan@haller-berlin.de> | 2024-06-07 18:13:02 +0200 |
---|---|---|
committer | Stefan Haller <stefan@haller-berlin.de> | 2024-06-10 12:00:24 +0200 |
commit | f9ba2dac9d161d73b5c308a94aa1e03fb00df826 (patch) | |
tree | b8bda4fb1212ea984445ba949b980d23b73f029b /pkg | |
parent | 6cb2ac6fcce09830cd426e49a2c5f6b79db31a32 (diff) |
Add test demonstrating the desired behavior
It has two modified hunks, one for a master commit and one for a branch commit.
Currently we get an error mentioning those two commits, but we would like to
silently select the branch commit.
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/integration/tests/commit/find_base_commit_for_fixup_disregard_main_branch.go | 56 | ||||
-rw-r--r-- | pkg/integration/tests/test_list.go | 1 |
2 files changed, 57 insertions, 0 deletions
diff --git a/pkg/integration/tests/commit/find_base_commit_for_fixup_disregard_main_branch.go b/pkg/integration/tests/commit/find_base_commit_for_fixup_disregard_main_branch.go new file mode 100644 index 000000000..4b8937eb2 --- /dev/null +++ b/pkg/integration/tests/commit/find_base_commit_for_fixup_disregard_main_branch.go @@ -0,0 +1,56 @@ +package commit + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var FindBaseCommitForFixupDisregardMainBranch = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Finds the base commit to create a fixup for, disregarding changes to a commit that is already on master", + ExtraCmdArgs: []string{}, + Skip: false, + SetupConfig: func(config *config.AppConfig) {}, + SetupRepo: func(shell *Shell) { + shell. + EmptyCommit("1st commit"). + CreateFileAndAdd("file1", "file1 content\n"). + Commit("2nd commit"). + NewBranch("mybranch"). + CreateFileAndAdd("file2", "file2 content\n"). + Commit("3rd commit"). + EmptyCommit("4th commit"). + UpdateFile("file1", "file1 changed content"). + UpdateFile("file2", "file2 changed content") + }, + Run: func(t *TestDriver, keys config.KeybindingConfig) { + t.Views().Commits(). + Lines( + Contains("4th commit").IsSelected(), + Contains("3rd commit"), + Contains("2nd commit"), + Contains("1st commit"), + ) + + t.Views().Files(). + Focus(). + Press(keys.Files.FindBaseCommitForFixup) + + /* EXPECTED: + t.Views().Commits(). + IsFocused(). + Lines( + Contains("4th commit"), + Contains("3rd commit").IsSelected(), + Contains("2nd commit"), + Contains("1st commit"), + ) + */ + + // ACTUAL: + t.ExpectPopup().Alert().Title(Equals("Error")).Content( + Contains("Multiple base commits found."). + Contains("2nd commit"). + Contains("3rd commit"), + ).Confirm() + }, +}) diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go index 6386146ba..ea2b93f45 100644 --- a/pkg/integration/tests/test_list.go +++ b/pkg/integration/tests/test_list.go @@ -82,6 +82,7 @@ var tests = []*components.IntegrationTest{ commit.CreateTag, commit.DiscardOldFileChanges, commit.FindBaseCommitForFixup, + commit.FindBaseCommitForFixupDisregardMainBranch, commit.FindBaseCommitForFixupOnlyAddedLines, commit.FindBaseCommitForFixupWarningForAddedLines, commit.Highlight, |