blob: 559231f532d5da0884a0f783b99b0454683004fa (
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
|
package commit
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var Staged = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Staging a couple files, going in the staged files menu, unstaging a line then committing",
ExtraCmdArgs: "",
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {
shell.
CreateFile("myfile", "myfile content\nwith a second line").
CreateFile("myfile2", "myfile2 content")
},
Run: func(shell *Shell, t *TestDriver, keys config.KeybindingConfig) {
t.Model().CommitCount(0)
t.Views().Files().
IsFocused().
SelectedLine(Contains("myfile")).
PressPrimaryAction(). // stage the file
PressEnter()
t.Views().StagingSecondary().
IsFocused().
Tap(func() {
// we start with both lines having been staged
t.Views().StagingSecondary().Content(Contains("+myfile content"))
t.Views().StagingSecondary().Content(Contains("+with a second line"))
t.Views().Staging().Content(DoesNotContain("+myfile content"))
t.Views().Staging().Content(DoesNotContain("+with a second line"))
}).
// unstage the selected line
PressPrimaryAction().
Tap(func() {
// the line should have been moved to the main view
t.Views().StagingSecondary().Content(DoesNotContain("+myfile content"))
t.Views().StagingSecondary().Content(Contains("+with a second line"))
t.Views().Staging().Content(Contains("+myfile content"))
t.Views().Staging().Content(DoesNotContain("+with a second line"))
}).
Press(keys.Files.CommitChanges)
commitMessage := "my commit message"
t.ExpectCommitMessagePanel().Type(commitMessage).Confirm()
t.Model().CommitCount(1)
t.Model().HeadCommitMessage(Equals(commitMessage))
t.Views().StagingSecondary().IsFocused()
// TODO: assert that the staging panel has been refreshed (it currently does not get correctly refreshed)
},
})
|