Repository: jesseduffield/lazygit
File: pkg/integration/tests/commit/add_co_author.go (Go)

Code before:
package commit

import (
	"github.com/jesseduffield/lazygit/pkg/config"
	. "github.com/jesseduffield/lazygit/pkg/integration/components"
)

var AddCoAuthor = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Add co-author on a commit",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupConfig:  func(config *config.AppConfig) {},
	SetupRepo: func(shell *Shell) {
		shell.NewBranch("original")

		shell.SetConfig("user.email", "Bill@example.com")
		shell.SetConfig("user.name", "Bill Smith")

		shell.EmptyCommit("one")

		shell.NewBranch("other")

		shell.SetConfig("user.email", "John@example.com")
		shell.SetConfig("user.name", "John Smith")

		shell.EmptyCommit("two")

		shell.Checkout("original")
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().Commits().
			Focus().
			Lines(
				Contains("BS").Contains("one").IsSelected(),
			)

		t.Views().Branches().
			Focus().

Review comment (security):
I'm happy to make this test much simpler given that other tests handle the suggestion logic. Feel free to use this:
```go
package commit

import (
	"github.com/jesseduffield/lazygit/pkg/config"
	. "github.com/jesseduffield/lazygit/pkg/integration/components"
)

var AddCoAuthor = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Add co-author on a commit",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupConfig:  func(config *config.AppConfig) {},
	SetupRepo: func(shell *Shell) {
		shell.EmptyCommit("initial commit")
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().Commits().
			Focus().
			Lines(
				Contains("initial commit").IsSelected(),
			).
			Press(keys.Commits.ResetCommitAuthor).
			Tap(func() {
				t.ExpectPopup().Menu().
					Title(Equals("Amend commit attribute")).
					Select(Contains("Add co-author")).
					Confirm()

				t.ExpectPopup().Prompt().
					Title(Contains("Add co-author")).
					Type("John Smith <jsmith@gmail.com>").
					Confirm()
			})

		t.Views().Main().ContainsLines(
			Contains("initial commit"),
			Contains("Co-authored-by: John Smith <jsmith@gmail.com>"),
		)
	},
})

```

Code after:
package commit

import (
	"github.com/jesseduffield/lazygit/pkg/config"
	. "github.com/jesseduffield/lazygit/pkg/integration/components"
)

var AddCoAuthor = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Add co-author on a commit",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupConfig:  func(config *config.AppConfig) {},
	SetupRepo: func(shell *Shell) {
		shell.EmptyCommit("initial commit")
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().Commits().
			Focus().
			Lines(
				Contains("initial commit").IsSelected(),
			).
			Press(keys.Commits.ResetCommitAuthor).
			Tap(func() {
				t.ExpectPopup().Menu().
					Title(Equals("Amend commit attribute")).
					Select(Contains("Add co-author")).
					Confirm()

				t.ExpectPopup().Prompt().
					Title(Contains("Add co-author")).
					Type("John Smith <jsmith@gmail.com>").
					Confirm()
			})

		t.Views().Main().ContainsLines(
			Contains("initial commit"),
			Contains("Co-authored-by: John Smith <jsmith@gmail.com>"),
		)