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

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

// TODO: fix confirmation view wrapping issue: https://github.com/jesseduffield/lazygit/issues/2872

var Undo = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Undo",
	ExtraCmdArgs: []string{},
	Skip:         false,
	IsDemo:       true,
	SetupConfig: func(config *config.AppConfig) {
		config.UserConfig.Gui.NerdFontsVersion = "3"
	},
	SetupRepo: func(shell *Shell) {
		shell.CreateNCommitsWithRandomMessages(30)
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.SetCaptionPrefix("Undo commands")
		t.Wait(1000)

		confirmCommitDrop := func() {
			t.ExpectPopup().Confirmation().
				Title(Equals("Delete commit")).
				Content(Equals("Are you sure you want to delete this commit?")).
				Wait(500).
				Confirm()
		}

		confirmUndo := func() {
			t.ExpectPopup().Confirmation().
				Title(Equals("Undo")).
				Content(MatchesRegexp(`Are you sure you want to hard reset to '.*'\? An auto-stash will be performed if necessary\.`)).
				Wait(500).
				Confirm()
		}

		confirmRedo := func() {
			t.ExpectPopup().Confirmation().
				Title(Equals("Redo")).
				Content(MatchesRegexp(`Are you sure you want to hard reset to '.*'\? An auto-stash will be performed if necessary\.`)).
				Wait(500).
				Confirm()
		}

		t.Views().Commits().Focus().
			SetCaptionPrefix("Drop two commits").
			Wait(1000).
			Press(keys.Universal.Remove).
			Tap(confirmCommitDrop).
			Press(keys.Universal.Remove).
			Tap(confirmCommitDrop).
			SetCaptionPrefix("Undo the drops").
			Wait(1000).
			Press(keys.Universal.Undo).
			Tap(confirmUndo).
			Press(keys.Universal.Undo).
			Tap(confirmUndo).
			SetCaptionPrefix("Redo the drops").
			Wait(1000).
			Press(keys.Universal.Redo).
			Tap(confirmRedo).
			Press(keys.Universal.Redo).
			Tap(confirmRedo)
	},
})