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
|
package branch
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var CheckoutByNameRemote = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Checkout a remote branch by name, both using the full name and the local name.",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {
shell.EmptyCommit("initial commit")
// create an origin/foo remote branch
shell.CloneIntoRemote("origin")
shell.NewBranch("foo")
shell.PushBranch("origin", "foo")
// delete the local version of the branch because we need to test checking it out from scratch
shell.Checkout("master")
shell.DeleteBranch("foo")
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Branches().
Focus().
Lines(
Contains("master").IsSelected(),
).
// maximising window so that we can see the tracked branch
Press(keys.Universal.NextScreenMode).
Press(keys.Branches.CheckoutBranchByName).
Tap(func() {
t.ExpectPopup().Prompt().
Title(Equals("Branch name:")).
Type("foo").
SuggestionLines(
Contains("foo"),
Contains("origin/foo"),
).
ConfirmFirstSuggestion()
}).
Lines(
Contains("foo").
// we have not checked out origin/foo...
DoesNotContain("origin/foo").
// ... but we are tracking it (formatted as '<remote> <branch>')
Contains("origin foo"),
Contains("master"),
).
Press(keys.Branches.CheckoutBranchByName).
Tap(func() {
t.ExpectPopup().Prompt().
Title(Equals("Branch name:")).
Type("origin/foo").
SuggestionLines(
Contains("origin/foo"),
).
ConfirmFirstSuggestion()
}).
Lines(
Contains("HEAD detached at origin/foo"),
Contains("foo"),
Contains("master"),
)
},
})
|