summaryrefslogtreecommitdiffstats
path: root/pkg/integration/tests/commit/set_author.go
blob: e0cd722daeac81601e58b06122dad4bccf523b24 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package commit

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

// Originally we only suggested authors present in the current branch, but now
// we include authors from other branches whose commits you've looked at in the
// lazygit session.

var SetAuthor = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Set 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().
			Lines(
				Contains("original").IsSelected(),
				Contains("other"),
			).
			NavigateToLine(Contains("other")).
			PressEnter()

		// ensuring we get these commit authors as suggestions
		t.Views().SubCommits().
			IsFocused().
			Lines(
				Contains("JS").Contains("two").IsSelected(),
				Contains("BS").Contains("one"),
			)

		t.Views().Commits().
			Focus().
			Press(keys.Commits.ResetCommitAuthor).
			Tap(func() {
				t.ExpectPopup().Menu().
					Title(Equals("Amend commit attribute")).
					Select(Contains(" Set author")). // adding space at start to distinguish from 'reset author'
					Confirm()

				t.ExpectPopup().Prompt().
					Title(Contains("Set author")).
					SuggestionLines(
						Contains("Bill Smith"),
						Contains("John Smith"),
					).
					ConfirmSuggestion(Contains("John Smith"))
			}).
			Lines(
				Contains("JS").Contains("one").IsSelected(),
			)
	},
})