mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-09-10 07:36:27 -04:00
Add test for how the selection advances after staging lines
This is currently working correctly, but will break with the next commit; we'll fix this again afterwards.
This commit is contained in:
parent
7929519ccf
commit
b8ed4faf9b
|
|
@ -0,0 +1,61 @@
|
|||
package staging
|
||||
|
||||
import (
|
||||
"github.com/jesseduffield/lazygit/pkg/config"
|
||||
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||
)
|
||||
|
||||
// Tests that after staging individual lines from a consecutive changes block,
|
||||
// the cursor advances to the correct next change. The file has two separate
|
||||
// hunks so that we can verify the cursor crosses hunk boundaries correctly.
|
||||
var SelectNextLineAfterStagingInTwoHunkDiff = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Description: "After staging lines from a two-hunk diff, the cursor advances correctly",
|
||||
ExtraCmdArgs: []string{},
|
||||
Skip: false,
|
||||
SetupConfig: func(config *config.AppConfig) {
|
||||
config.GetUserConfig().Gui.UseHunkModeInStagingView = false
|
||||
},
|
||||
SetupRepo: func(shell *Shell) {
|
||||
// Use 7 context lines between the two change blocks so that git creates
|
||||
// two separate hunks.
|
||||
shell.CreateFileAndAdd("file1", "1\n2\na\nb\nc\nd\ne\nf\ng\n3\n4\n")
|
||||
shell.Commit("one")
|
||||
|
||||
shell.UpdateFile("file1", "1b\n2b\na\nb\nc\nd\ne\nf\ng\n3b\n4b\n")
|
||||
},
|
||||
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.Views().Files().
|
||||
IsFocused().
|
||||
Lines(
|
||||
Contains("file1").IsSelected(),
|
||||
).
|
||||
PressEnter()
|
||||
|
||||
t.Views().Staging().
|
||||
IsFocused().
|
||||
ContainsLines(
|
||||
Contains("-1"),
|
||||
Contains("-2"),
|
||||
Contains("+1b"),
|
||||
Contains("+2b"),
|
||||
Contains(" a"),
|
||||
Contains(" b"),
|
||||
Contains(" c"),
|
||||
Contains("@@"),
|
||||
Contains(" e"),
|
||||
Contains(" f"),
|
||||
Contains(" g"),
|
||||
Contains("-3"),
|
||||
Contains("-4"),
|
||||
Contains("+3b"),
|
||||
Contains("+4b"),
|
||||
).
|
||||
NavigateToLine(Contains("-2")).
|
||||
PressPrimaryAction().
|
||||
SelectedLine(Contains("+1b")).
|
||||
PressPrimaryAction().
|
||||
SelectedLine(Contains("+2b")).
|
||||
PressPrimaryAction().
|
||||
SelectedLine(Contains("-3"))
|
||||
},
|
||||
})
|
||||
|
|
@ -377,6 +377,7 @@ var tests = []*components.IntegrationTest{
|
|||
staging.DiffContextChange,
|
||||
staging.DiscardAllChanges,
|
||||
staging.Search,
|
||||
staging.SelectNextLineAfterStagingInTwoHunkDiff,
|
||||
staging.SelectNextLineAfterStagingIsolatedAddedLine,
|
||||
staging.StageHunks,
|
||||
staging.StageLines,
|
||||
|
|
|
|||
Loading…
Reference in a new issue