mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-11 12:25:47 +02:00
Add test for checking out a file from a range selection of commits
The test shows a misbehavior: even though the diff shows "-one" and "+three", meaning that "three" is the state we want to check out, we get "one". The reason is that the checkout file command doesn't pay attention to range selections, it only looks at the "moving end" of the range. Had we created the range by selecting "two" and then pressed shift-up to "three", we would have gotten the expected result.
This commit is contained in:
parent
ac7d8ad025
commit
61c56c7822
2 changed files with 60 additions and 0 deletions
|
@ -0,0 +1,59 @@
|
|||
package commit
|
||||
|
||||
import (
|
||||
"github.com/jesseduffield/lazygit/pkg/config"
|
||||
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||
)
|
||||
|
||||
var CheckoutFileFromRangeSelectionOfCommits = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Description: "Checkout a file from a range selection of commits",
|
||||
ExtraCmdArgs: []string{},
|
||||
Skip: false,
|
||||
SetupConfig: func(config *config.AppConfig) {},
|
||||
SetupRepo: func(shell *Shell) {
|
||||
shell.CreateFileAndAdd("file.txt", "one\n")
|
||||
shell.Commit("one")
|
||||
shell.CreateFileAndAdd("file.txt", "two\n")
|
||||
shell.Commit("two")
|
||||
shell.CreateFileAndAdd("file.txt", "three\n")
|
||||
shell.Commit("three")
|
||||
shell.CreateFileAndAdd("file.txt", "four\n")
|
||||
shell.Commit("four")
|
||||
},
|
||||
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.Views().Commits().
|
||||
Focus().
|
||||
Lines(
|
||||
Contains("four").IsSelected(),
|
||||
Contains("three"),
|
||||
Contains("two"),
|
||||
Contains("one"),
|
||||
).
|
||||
NavigateToLine(Contains("three")).
|
||||
Press(keys.Universal.RangeSelectDown).
|
||||
Tap(func() {
|
||||
t.Views().Main().ContainsLines(
|
||||
Contains("-one"),
|
||||
Contains("+three"),
|
||||
)
|
||||
}).
|
||||
PressEnter()
|
||||
|
||||
t.Views().CommitFiles().
|
||||
IsFocused().
|
||||
Lines(
|
||||
Equals("M file.txt"),
|
||||
).
|
||||
Press(keys.CommitFiles.CheckoutCommitFile)
|
||||
|
||||
t.Views().Files().
|
||||
Lines(
|
||||
Equals("M file.txt"),
|
||||
)
|
||||
|
||||
/* EXPECTED:
|
||||
t.FileSystem().FileContent("file.txt", Equals("three\n"))
|
||||
ACTUAL: */
|
||||
t.FileSystem().FileContent("file.txt", Equals("two\n"))
|
||||
},
|
||||
})
|
|
@ -90,6 +90,7 @@ var tests = []*components.IntegrationTest{
|
|||
commit.AutoWrapMessage,
|
||||
commit.Checkout,
|
||||
commit.CheckoutFileFromCommit,
|
||||
commit.CheckoutFileFromRangeSelectionOfCommits,
|
||||
commit.Commit,
|
||||
commit.CommitMultiline,
|
||||
commit.CommitSkipHooks,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue