1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-07-31 14:24:25 +03:00

migrate filter path tests

This commit is contained in:
Jesse Duffield
2022-12-28 18:17:28 +11:00
parent 6f709456fe
commit 89ba3a38b4
107 changed files with 135 additions and 243 deletions

View File

@ -0,0 +1,20 @@
package filter_by_path
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var CliArg = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Filter commits by file path, using CLI arg",
ExtraCmdArgs: "-f filterFile",
Skip: false,
SetupConfig: func(config *config.AppConfig) {
},
SetupRepo: func(shell *Shell) {
commonSetup(shell)
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
postFilterTest(t, keys)
},
})

View File

@ -0,0 +1,76 @@
package filter_by_path
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var SelectFile = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Filter commits by file path, by finding file in UI and filtering on it",
ExtraCmdArgs: "",
Skip: false,
SetupConfig: func(config *config.AppConfig) {
},
SetupRepo: func(shell *Shell) {
commonSetup(shell)
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Commits().
Focus().
Lines(
Contains(`only filterFile`).IsSelected(),
Contains(`only otherFile`),
Contains(`both files`),
).
PressEnter()
// when you click into the commit itself, you see all files from that commit
t.Views().CommitFiles().
IsFocused().
Lines(
Contains(`filterFile`).IsSelected(),
).
Press(keys.Universal.FilteringMenu)
t.ExpectPopup().Menu().Title(Equals("Filtering")).Select(Contains("filter by 'filterFile'")).Confirm()
postFilterTest(t, keys)
},
})
func commonSetup(shell *Shell) {
shell.CreateFileAndAdd("filterFile", "original filterFile content")
shell.CreateFileAndAdd("otherFile", "original otherFile content")
shell.Commit("both files")
shell.UpdateFileAndAdd("otherFile", "new otherFile content")
shell.Commit("only otherFile")
shell.UpdateFileAndAdd("filterFile", "new filterFile content")
shell.Commit("only filterFile")
}
func postFilterTest(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Information().Content(Contains("filtering by 'filterFile'"))
t.Views().Commits().
IsFocused().
Lines(
Contains(`only filterFile`).IsSelected(),
Contains(`both files`),
).
SelectNextItem().
PressEnter()
// we only show the filtered file's changes in the main view
t.Views().Main().
Content(Contains("filterFile").DoesNotContain("otherFile"))
// when you click into the commit itself, you see all files from that commit
t.Views().CommitFiles().
IsFocused().
Lines(
Contains(`filterFile`),
Contains(`otherFile`),
)
}

View File

@ -0,0 +1,35 @@
package filter_by_path
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var TypeFile = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Filter commits by file path, by finding file in UI and filtering on it",
ExtraCmdArgs: "",
Skip: false,
SetupConfig: func(config *config.AppConfig) {
},
SetupRepo: func(shell *Shell) {
commonSetup(shell)
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Files().
IsFocused().
Press(keys.Universal.FilteringMenu)
t.ExpectPopup().Menu().
Title(Equals("Filtering")).
Select(Contains("enter path to filter by")).
Confirm()
t.ExpectPopup().Prompt().
Title(Equals("Enter path:")).
Type("filterF").
SuggestionLines(Equals("filterFile")).
ConfirmFirstSuggestion()
postFilterTest(t, keys)
},
})

View File

@ -18,6 +18,7 @@ import (
"github.com/jesseduffield/lazygit/pkg/integration/tests/custom_commands"
"github.com/jesseduffield/lazygit/pkg/integration/tests/diff"
"github.com/jesseduffield/lazygit/pkg/integration/tests/file"
"github.com/jesseduffield/lazygit/pkg/integration/tests/filter_by_path"
"github.com/jesseduffield/lazygit/pkg/integration/tests/interactive_rebase"
"github.com/jesseduffield/lazygit/pkg/integration/tests/misc"
"github.com/jesseduffield/lazygit/pkg/integration/tests/stash"
@ -67,6 +68,9 @@ var tests = []*components.IntegrationTest{
diff.DiffCommits,
sync.FetchPrune,
sync.RenameBranchAndPull,
filter_by_path.CliArg,
filter_by_path.SelectFile,
filter_by_path.TypeFile,
}
func GetTests() []*components.IntegrationTest {