From 07fe828f60b2c091e038d76075ac7ed08588a9c2 Mon Sep 17 00:00:00 2001 From: Luke Swan Date: Wed, 10 Jul 2024 00:47:22 +0300 Subject: [PATCH] Add initial test for non-matching branch name --- .../commit_with_non_matching_branch_name.go | 38 +++++++++++++++++++ pkg/integration/tests/test_list.go | 1 + 2 files changed, 39 insertions(+) create mode 100644 pkg/integration/tests/commit/commit_with_non_matching_branch_name.go diff --git a/pkg/integration/tests/commit/commit_with_non_matching_branch_name.go b/pkg/integration/tests/commit/commit_with_non_matching_branch_name.go new file mode 100644 index 000000000..490bbf9f8 --- /dev/null +++ b/pkg/integration/tests/commit/commit_with_non_matching_branch_name.go @@ -0,0 +1,38 @@ +package commit + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var CommitWithNonMatchingBranchName = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Commit with defined config commitPrefixes", + ExtraCmdArgs: []string{}, + Skip: false, + SetupConfig: func(testConfig *config.AppConfig) { + testConfig.UserConfig.Git.CommitPrefix = &config.CommitPrefixConfig{ + Pattern: "^\\w+\\/(\\w+-\\w+).*", + Replace: "[$1]: ", + } + }, + SetupRepo: func(shell *Shell) { + shell.NewBranch("branchnomatch") + shell.CreateFile("test-commit-prefix", "This is foo bar") + }, + Run: func(t *TestDriver, keys config.KeybindingConfig) { + t.Views().Commits(). + IsEmpty() + + t.Views().Files(). + IsFocused(). + PressPrimaryAction(). + Press(keys.Files.CommitChanges) + + t.ExpectPopup().CommitMessagePanel(). + Title(Equals("Commit summary")). + /* EXPECTED: + InitialText(Equals("")) + ACTUAL: */ + InitialText(Equals("branchnomatch")) + }, +}) diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go index ec24b9f5a..fcc0b74bb 100644 --- a/pkg/integration/tests/test_list.go +++ b/pkg/integration/tests/test_list.go @@ -80,6 +80,7 @@ var tests = []*components.IntegrationTest{ commit.CommitSwitchToEditor, commit.CommitWipWithPrefix, commit.CommitWithGlobalPrefix, + commit.CommitWithNonMatchingBranchName, commit.CommitWithPrefix, commit.CreateAmendCommit, commit.CreateTag,