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

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

var WorktreeCreateFromBranches = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Create a worktree from the branches view",
	ExtraCmdArgs: []string{},
	Skip:         false,
	IsDemo:       true,
	SetupConfig: func(cfg *config.AppConfig) {
		setDefaultDemoConfig(cfg)
	},
	SetupRepo: func(shell *Shell) {
		shell.CreateNCommitsWithRandomMessages(30)
		shell.NewBranch("feature/user-authentication")
		shell.EmptyCommit("Add user authentication feature")
		shell.EmptyCommit("Fix local session storage")
		shell.CreateFile("src/authentication.go", "package main")
		shell.CreateFile("src/shims.go", "package main")
		shell.CreateFile("src/session.go", "package main")
		shell.EmptyCommit("Stop using shims")
		shell.UpdateFile("src/authentication.go", "package authentication")
		shell.UpdateFileAndAdd("src/shims.go", "// removing for now")
		shell.UpdateFile("src/session.go", "package session")
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.SetCaptionPrefix("Create a worktree from a branch")
		t.Wait(1000)

		t.Views().Branches().
			Focus().
			NavigateToLine(Contains("master")).
			Wait(500).
			Press(keys.Worktrees.ViewWorktreeOptions).
			Tap(func() {
				t.Wait(500)

				t.ExpectPopup().Menu().
					Title(Equals("Worktree")).
					Select(Contains("Create worktree from master").DoesNotContain("detached")).
					Confirm()

				t.ExpectPopup().Prompt().
					Title(Equals("New worktree path")).
					Type("../hotfix").
					Confirm()

				t.ExpectPopup().Prompt().
					Title(Contains("New branch name")).
					Type("hotfix/db-on-fire").
					Confirm()
			})
	},
})