1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-03-23 21:51:07 +02:00

56 lines
1.7 KiB
Go
Raw Normal View History

2022-12-21 22:52:23 +11:00
package diff
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var DiffCommits = NewIntegrationTest(NewIntegrationTestArgs{
Description: "View the diff between two commits",
ExtraCmdArgs: []string{},
2022-12-21 22:52:23 +11:00
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {
shell.CreateFileAndAdd("file1", "first line\n")
shell.Commit("first commit")
shell.UpdateFileAndAdd("file1", "first line\nsecond line\n")
shell.Commit("second commit")
shell.UpdateFileAndAdd("file1", "first line\nsecond line\nthird line\n")
shell.Commit("third commit")
},
2022-12-27 21:47:37 +11:00
Run: func(t *TestDriver, keys config.KeybindingConfig) {
2022-12-27 21:35:36 +11:00
t.Views().Commits().
Focus().
Lines(
2022-12-27 21:25:11 +11:00
Contains("third commit").IsSelected(),
Contains("second commit"),
Contains("first commit"),
).
2022-12-27 21:25:11 +11:00
Press(keys.Universal.DiffingMenu).
Tap(func() {
t.ExpectPopup().Menu().Title(Equals("Diffing")).Select(MatchesRegexp(`Diff \w+`)).Confirm()
2022-12-21 22:52:23 +11:00
t.Views().Information().Content(Contains("Showing output for: git diff"))
2022-12-27 21:25:11 +11:00
}).
SelectNextItem().
SelectNextItem().
2022-12-27 21:25:11 +11:00
SelectedLine(Contains("first commit")).
Tap(func() {
2022-12-27 21:35:36 +11:00
t.Views().Main().Content(Contains("-second line\n-third line"))
2022-12-27 21:25:11 +11:00
}).
Press(keys.Universal.DiffingMenu).
Tap(func() {
t.ExpectPopup().Menu().Title(Equals("Diffing")).Select(Contains("Reverse diff direction")).Confirm()
2022-12-27 21:25:11 +11:00
2022-12-27 21:35:36 +11:00
t.Views().Main().Content(Contains("+second line\n+third line"))
2022-12-27 21:25:11 +11:00
}).
PressEnter()
2022-12-21 22:52:23 +11:00
2022-12-27 21:35:36 +11:00
t.Views().CommitFiles().
IsFocused().
SelectedLine(Contains("file1"))
2022-12-27 21:35:36 +11:00
t.Views().Main().Content(Contains("+second line\n+third line"))
2022-12-21 22:52:23 +11:00
},
})