From cff9850374097f60d8bf39290d1dcb2b51ec0c91 Mon Sep 17 00:00:00 2001 From: Gustavo Krieger Date: Sun, 2 Jul 2023 00:21:17 -0300 Subject: [PATCH] Add tests of interactive rebase with custom comment character --- .../drop_with_custom_comment_char.go | 42 +++++++++++++++++++ .../move_with_custom_comment_char.go | 36 ++++++++++++++++ pkg/integration/tests/test_list.go | 2 + 3 files changed, 80 insertions(+) create mode 100644 pkg/integration/tests/interactive_rebase/drop_with_custom_comment_char.go create mode 100644 pkg/integration/tests/interactive_rebase/move_with_custom_comment_char.go diff --git a/pkg/integration/tests/interactive_rebase/drop_with_custom_comment_char.go b/pkg/integration/tests/interactive_rebase/drop_with_custom_comment_char.go new file mode 100644 index 000000000..6e93b6faa --- /dev/null +++ b/pkg/integration/tests/interactive_rebase/drop_with_custom_comment_char.go @@ -0,0 +1,42 @@ +package interactive_rebase + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var DropWithCustomCommentChar = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Drops a commit with the 'core.commentChar' option set to a custom character", + ExtraCmdArgs: []string{}, + Skip: false, + SetupConfig: func(config *config.AppConfig) {}, + SetupRepo: func(shell *Shell) { + shell.SetConfig("core.commentChar", ";") + shell.CreateNCommits(2) + }, + Run: func(t *TestDriver, keys config.KeybindingConfig) { + t.Views().Commits().Focus(). + Lines( + Contains("commit 02").IsSelected(), + Contains("commit 01"), + ). + Press(keys.Universal.Remove). + Tap(func() { + t.ExpectPopup().Confirmation(). + Title(Equals("Delete commit")). + Content(Equals("Are you sure you want to delete this commit?")). + Confirm() + }). + // The following behavior requires correction: + Tap(func() { + t.ExpectPopup().Alert(). + Title(Equals("Error")). + Content(Contains("failed to parse line")). + Confirm() + }). + Lines( + Contains("commit 02").IsSelected(), + Contains("commit 01"), + ) + }, +}) diff --git a/pkg/integration/tests/interactive_rebase/move_with_custom_comment_char.go b/pkg/integration/tests/interactive_rebase/move_with_custom_comment_char.go new file mode 100644 index 000000000..0ff03169d --- /dev/null +++ b/pkg/integration/tests/interactive_rebase/move_with_custom_comment_char.go @@ -0,0 +1,36 @@ +package interactive_rebase + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var MoveWithCustomCommentChar = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Directly moves a commit down and back up with the 'core.commentChar' option set to a custom character", + ExtraCmdArgs: []string{}, + Skip: false, + SetupConfig: func(config *config.AppConfig) {}, + SetupRepo: func(shell *Shell) { + shell.SetConfig("core.commentChar", ";") + shell.CreateNCommits(2) + }, + Run: func(t *TestDriver, keys config.KeybindingConfig) { + t.Views().Commits().Focus(). + Lines( + Contains("commit 02").IsSelected(), + Contains("commit 01"), + ). + Press(keys.Commits.MoveDownCommit). + // The following behavior requires correction: + Tap(func() { + t.ExpectPopup().Alert(). + Title(Equals("Error")). + Content(Contains("failed to parse line")). + Confirm() + }). + Lines( + Contains("commit 02").IsSelected(), + Contains("commit 01"), + ) + }, +}) diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go index c1549df83..99b7f2bdc 100644 --- a/pkg/integration/tests/test_list.go +++ b/pkg/integration/tests/test_list.go @@ -103,6 +103,7 @@ var tests = []*components.IntegrationTest{ interactive_rebase.AmendNonHeadCommitDuringRebase, interactive_rebase.DropTodoCommitWithUpdateRef, interactive_rebase.DropTodoCommitWithUpdateRefShowBranchHeads, + interactive_rebase.DropWithCustomCommentChar, interactive_rebase.EditFirstCommit, interactive_rebase.EditNonTodoCommitDuringRebase, interactive_rebase.EditTheConflCommit, @@ -110,6 +111,7 @@ var tests = []*components.IntegrationTest{ interactive_rebase.FixupSecondCommit, interactive_rebase.Move, interactive_rebase.MoveInRebase, + interactive_rebase.MoveWithCustomCommentChar, interactive_rebase.PickRescheduled, interactive_rebase.Rebase, interactive_rebase.RewordCommitWithEditorAndFail,