summaryrefslogtreecommitdiffstats
path: root/pkg/integration/tests/demo/amend_old_commit.go
blob: ac91a34e7535cfcf7e1b2e0a8ddc1cfce459f068 (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
package demo

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

var AmendOldCommit = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Amend old commit",
	ExtraCmdArgs: []string{},
	Skip:         false,
	IsDemo:       true,
	SetupConfig: func(config *config.AppConfig) {
		setDefaultDemoConfig(config)
		config.UserConfig.Gui.ShowFileTree = false
	},
	SetupRepo: func(shell *Shell) {
		shell.CreateNCommitsWithRandomMessages(60)
		shell.NewBranch("feature/demo")

		shell.CloneIntoRemote("origin")

		shell.SetBranchUpstream("feature/demo", "origin/feature/demo")

		shell.UpdateFile("navigation/site_navigation.go", "package navigation\n\nfunc Navigate() {\n\tpanic(\"unimplemented\")\n}")
		shell.CreateFile("docs/README.md", "my readme content")
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.SetCaptionPrefix("Amend an old commit")
		t.Wait(1000)

		t.Views().Files().
			IsFocused().
			SelectedLine(Contains("site_navigation.go")).
			PressPrimaryAction()

		t.Views().Commits().
			Focus().
			NavigateToLine(Contains("Improve accessibility of site navigation")).
			Wait(500).
			Press(keys.Commits.AmendToCommit).
			Tap(func() {
				t.ExpectPopup().Confirmation().
					Title(Equals("Amend commit")).
					Wait(1000).
					Content(AnyString()).
					Confirm()

				t.Wait(1000)
			}).
			Press(keys.Universal.Push).
			Tap(func() {
				t.ExpectPopup().Confirmation().
					Title(Equals("Force push")).
					Content(AnyString()).
					Wait(1000).
					Confirm()
			})
	},
})