mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-17 22:32:58 +02:00
Assert the entire lines using Equals instead of Contains. This makes the tests a bit easier to read, and it makes it much easier to decide how they need to be changed when we change the layout (like we do in the last commit of this branch). It is true that this requires changing all these tests for any future UI changes, but I think this is a good price to pay; those adaptions are trivial and can be done without thinking.
71 lines
1.8 KiB
Go
71 lines
1.8 KiB
Go
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(
|
|
Equals("M file1").IsSelected(),
|
|
Equals("A file2"),
|
|
Equals("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(
|
|
Equals("M file1").IsSelected(),
|
|
Equals("A file2"),
|
|
)
|
|
|
|
t.Views().Main().
|
|
Content(Contains("second line"))
|
|
|
|
t.Views().Files().Focus().NavigateToLine(Contains("file2"))
|
|
|
|
t.Views().Main().
|
|
Content(Contains("file two content"))
|
|
},
|
|
})
|