1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2024-12-14 11:23:09 +02:00
lazygit/pkg/integration/tests/diff/diff.go

58 lines
1.9 KiB
Go
Raw Normal View History

2022-12-21 13:52:23 +02:00
package diff
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var Diff = NewIntegrationTest(NewIntegrationTestArgs{
Description: "View the diff of two branches, then view the reverse diff",
ExtraCmdArgs: "",
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {
shell.NewBranch("branch-a")
shell.CreateFileAndAdd("file1", "first line")
shell.Commit("first commit")
shell.NewBranch("branch-b")
shell.UpdateFileAndAdd("file1", "first line\nsecond line")
shell.Commit("update")
shell.Checkout("branch-a")
},
Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
input.SwitchToBranchesWindow()
assert.CurrentViewName("localBranches")
assert.SelectedLine(Contains("branch-a"))
input.Press(keys.Universal.DiffingMenu)
input.Menu(Equals("Diffing"), Contains(`diff branch-a`))
2022-12-21 13:52:23 +02:00
assert.CurrentViewName("localBranches")
assert.ViewContent("information", Contains("showing output for: git diff branch-a branch-a"))
2022-12-21 13:52:23 +02:00
input.NextItem()
assert.ViewContent("information", Contains("showing output for: git diff branch-a branch-b"))
assert.MainViewContent(Contains("+second line"))
2022-12-21 13:52:23 +02:00
input.Enter()
assert.CurrentViewName("subCommits")
assert.MainViewContent(Contains("+second line"))
assert.SelectedLine(Contains("update"))
2022-12-21 13:52:23 +02:00
input.Enter()
assert.CurrentViewName("commitFiles")
assert.SelectedLine(Contains("file1"))
assert.MainViewContent(Contains("+second line"))
2022-12-21 13:52:23 +02:00
input.Press(keys.Universal.Return)
input.Press(keys.Universal.Return)
2022-12-21 13:52:23 +02:00
assert.CurrentViewName("localBranches")
input.Press(keys.Universal.DiffingMenu)
input.Menu(Equals("Diffing"), Contains("reverse diff direction"))
assert.ViewContent("information", Contains("showing output for: git diff branch-a branch-b -R"))
assert.MainViewContent(Contains("-second line"))
2022-12-21 13:52:23 +02:00
},
})