summaryrefslogtreecommitdiffstats
path: root/pkg/integration/tests/commit/create_tag.go
blob: 4b749b235b1933f7a28cb30a8e75dc6c1ff1e222 (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
package commit

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

var CreateTag = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Create a new tag on a commit",
	ExtraCmdArgs: "",
	Skip:         false,
	SetupConfig:  func(config *config.AppConfig) {},
	SetupRepo: func(shell *Shell) {
		shell.EmptyCommit("one")
		shell.EmptyCommit("two")
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().Commits().
			Focus().
			Lines(
				Contains("two").IsSelected(),
				Contains("one"),
			).
			Press(keys.Commits.CreateTag)

		t.ExpectPopup().Menu().
			Title(Equals("Create tag")).
			Select(Contains("lightweight")).
			Confirm()

		t.ExpectPopup().Prompt().
			Title(Equals("Tag name:")).
			Type("new-tag").
			Confirm()

		t.Views().Commits().
			Lines(
				MatchesRegexp(`new-tag.*two`).IsSelected(),
				MatchesRegexp(`one`),
			)

		t.Views().Tags().
			Focus().
			Lines(
				MatchesRegexp(`new-tag.*two`).IsSelected(),
			)

		t.Git().
			TagNamesAt("HEAD", []string{"new-tag"})
	},
})