Support selecting file range in patch builder
test: add move_range_to_index test: add toggle_range
This commit is contained in:
committed by
Jesse Duffield
parent
9b2a5f636a
commit
510f9a1ae1
70
pkg/integration/tests/patch_building/move_range_to_index.go
Normal file
70
pkg/integration/tests/patch_building/move_range_to_index.go
Normal file
@@ -0,0 +1,70 @@
|
||||
package patch_building
|
||||
|
||||
import (
|
||||
"github.com/jesseduffield/lazygit/pkg/config"
|
||||
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||
)
|
||||
|
||||
var MoveRangeToIndex = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Description: "Apply a custom patch",
|
||||
ExtraCmdArgs: []string{},
|
||||
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.CreateFileAndAdd("file2", "file two content\n")
|
||||
shell.CreateFileAndAdd("file3", "file three content\n")
|
||||
shell.Commit("second commit")
|
||||
},
|
||||
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.Views().Commits().
|
||||
Focus().
|
||||
Lines(
|
||||
Contains("second commit").IsSelected(),
|
||||
Contains("first commit"),
|
||||
).
|
||||
PressEnter()
|
||||
|
||||
t.Views().CommitFiles().
|
||||
IsFocused().
|
||||
Lines(
|
||||
Contains("M file1").IsSelected(),
|
||||
Contains("A file2"),
|
||||
Contains("A file3"),
|
||||
).
|
||||
Press(keys.Universal.ToggleRangeSelect).
|
||||
NavigateToLine(Contains("file2")).
|
||||
PressPrimaryAction()
|
||||
|
||||
t.Views().Information().Content(Contains("Building patch"))
|
||||
|
||||
t.Views().PatchBuildingSecondary().Content(Contains("second line"))
|
||||
t.Views().PatchBuildingSecondary().Content(Contains("file two content"))
|
||||
|
||||
t.Common().SelectPatchOption(MatchesRegexp(`Move patch out into index$`))
|
||||
|
||||
t.Views().CommitFiles().
|
||||
IsFocused().
|
||||
Lines(
|
||||
Contains("file3").IsSelected(),
|
||||
).PressEscape()
|
||||
|
||||
t.Views().Files().
|
||||
Focus().
|
||||
Lines(
|
||||
Contains("file1").IsSelected(),
|
||||
Contains("file2"),
|
||||
)
|
||||
|
||||
t.Views().Main().
|
||||
Content(Contains("second line"))
|
||||
|
||||
t.Views().Files().Focus().NavigateToLine(Contains("file2"))
|
||||
|
||||
t.Views().Main().
|
||||
Content(Contains("file two content"))
|
||||
},
|
||||
})
|
||||
107
pkg/integration/tests/patch_building/toggle_range.go
Normal file
107
pkg/integration/tests/patch_building/toggle_range.go
Normal file
@@ -0,0 +1,107 @@
|
||||
package patch_building
|
||||
|
||||
import (
|
||||
"github.com/jesseduffield/lazygit/pkg/config"
|
||||
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||
)
|
||||
|
||||
var ToggleRange = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Description: "Check multi select toggle logic",
|
||||
ExtraCmdArgs: []string{},
|
||||
Skip: false,
|
||||
SetupConfig: func(config *config.AppConfig) {},
|
||||
SetupRepo: func(shell *Shell) {
|
||||
shell.CreateDir("dir1")
|
||||
shell.CreateFileAndAdd("dir1/file1-a", "d2f1 first line\nsecond line\nthird line\n")
|
||||
shell.CreateFileAndAdd("dir1/file2-a", "d1f2 first line\n")
|
||||
shell.CreateFileAndAdd("dir1/file3-a", "d1f3 first line\n")
|
||||
|
||||
shell.CreateDir("dir2")
|
||||
shell.CreateFileAndAdd("dir2/file1-b", "d2f1 first line\nsecond line\nthird line\n")
|
||||
shell.CreateFileAndAdd("dir2/file2-b", "d2f2 first line\n")
|
||||
shell.CreateFileAndAdd("dir2/file3-b", "d2f3 first line\nsecond line\n")
|
||||
|
||||
shell.Commit("first commit")
|
||||
},
|
||||
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.Views().Commits().
|
||||
Focus().
|
||||
Lines(
|
||||
Contains("first commit").IsSelected(),
|
||||
).
|
||||
PressEnter()
|
||||
|
||||
t.Views().CommitFiles().
|
||||
IsFocused().
|
||||
Lines(
|
||||
Contains("▼ dir1").IsSelected(),
|
||||
Contains(" A").Contains("file1-a"),
|
||||
Contains(" A").Contains("file2-a"),
|
||||
Contains(" A").Contains("file3-a"),
|
||||
Contains("▼ dir2"),
|
||||
Contains(" A").Contains("file1-b"),
|
||||
Contains(" A").Contains("file2-b"),
|
||||
Contains(" A").Contains("file3-b"),
|
||||
).
|
||||
NavigateToLine(Contains("file1-a")).
|
||||
Press(keys.Universal.ToggleRangeSelect).
|
||||
NavigateToLine(Contains("file3-a")).
|
||||
PressPrimaryAction().
|
||||
Lines(
|
||||
Contains("▼ dir1"),
|
||||
Contains(" ●").Contains("file1-a").IsSelected(),
|
||||
Contains(" ●").Contains("file2-a").IsSelected(),
|
||||
Contains(" ●").Contains("file3-a").IsSelected(),
|
||||
Contains("▼ dir2"),
|
||||
Contains(" A").Contains("file1-b"),
|
||||
Contains(" A").Contains("file2-b"),
|
||||
Contains(" A").Contains("file3-b"),
|
||||
).
|
||||
PressEscape().
|
||||
NavigateToLine(Contains("file3-b")).
|
||||
PressEnter()
|
||||
|
||||
t.Views().Main().IsFocused().
|
||||
NavigateToLine(Contains("second line")).
|
||||
PressPrimaryAction().
|
||||
PressEscape()
|
||||
|
||||
t.Views().CommitFiles().
|
||||
IsFocused().
|
||||
Lines(
|
||||
Contains("▼ dir1"),
|
||||
Contains(" ●").Contains("file1-a"),
|
||||
Contains(" ●").Contains("file2-a"),
|
||||
Contains(" ●").Contains("file3-a"),
|
||||
Contains("▼ dir2"),
|
||||
Contains(" A").Contains("file1-b"),
|
||||
Contains(" A").Contains("file2-b"),
|
||||
Contains(" ◐").Contains("file3-b").IsSelected(),
|
||||
).
|
||||
NavigateToLine(Contains("dir1")).
|
||||
Press(keys.Universal.ToggleRangeSelect).
|
||||
NavigateToLine(Contains("dir2")).
|
||||
PressPrimaryAction().
|
||||
Lines(
|
||||
Contains("▼ dir1").IsSelected(),
|
||||
Contains(" ●").Contains("file1-a").IsSelected(),
|
||||
Contains(" ●").Contains("file2-a").IsSelected(),
|
||||
Contains(" ●").Contains("file3-a").IsSelected(),
|
||||
Contains("▼ dir2").IsSelected(),
|
||||
Contains(" ●").Contains("file1-b"),
|
||||
Contains(" ●").Contains("file2-b"),
|
||||
Contains(" ●").Contains("file3-b"),
|
||||
).
|
||||
PressPrimaryAction().
|
||||
Lines(
|
||||
Contains("▼ dir1").IsSelected(),
|
||||
Contains(" A").Contains("file1-a").IsSelected(),
|
||||
Contains(" A").Contains("file2-a").IsSelected(),
|
||||
Contains(" A").Contains("file3-a").IsSelected(),
|
||||
Contains("▼ dir2").IsSelected(),
|
||||
Contains(" A").Contains("file1-b"),
|
||||
Contains(" A").Contains("file2-b"),
|
||||
Contains(" A").Contains("file3-b"),
|
||||
)
|
||||
},
|
||||
})
|
||||
@@ -194,6 +194,7 @@ var tests = []*components.IntegrationTest{
|
||||
patch_building.Apply,
|
||||
patch_building.ApplyInReverse,
|
||||
patch_building.ApplyInReverseWithConflict,
|
||||
patch_building.MoveRangeToIndex,
|
||||
patch_building.MoveToEarlierCommit,
|
||||
patch_building.MoveToEarlierCommitNoKeepEmpty,
|
||||
patch_building.MoveToIndex,
|
||||
@@ -209,6 +210,7 @@ var tests = []*components.IntegrationTest{
|
||||
patch_building.SelectAllFiles,
|
||||
patch_building.SpecificSelection,
|
||||
patch_building.StartNewPatch,
|
||||
patch_building.ToggleRange,
|
||||
reflog.Checkout,
|
||||
reflog.CherryPick,
|
||||
reflog.DoNotShowBranchMarkersInReflogSubcommits,
|
||||
|
||||
Reference in New Issue
Block a user