diff --git a/pkg/integration/tests/commit/checkout_file_from_range_selection_of_commits.go b/pkg/integration/tests/commit/checkout_file_from_range_selection_of_commits.go new file mode 100644 index 000000000..899458da1 --- /dev/null +++ b/pkg/integration/tests/commit/checkout_file_from_range_selection_of_commits.go @@ -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")) + }, +}) diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go index c65063901..b7e204fd2 100644 --- a/pkg/integration/tests/test_list.go +++ b/pkg/integration/tests/test_list.go @@ -90,6 +90,7 @@ var tests = []*components.IntegrationTest{ commit.AutoWrapMessage, commit.Checkout, commit.CheckoutFileFromCommit, + commit.CheckoutFileFromRangeSelectionOfCommits, commit.Commit, commit.CommitMultiline, commit.CommitSkipHooks,