1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-08-06 22:33:07 +02:00

Extract helper function for integration test

We are going to reuse it in two other tests that we are going to add in the next
commit.
This commit is contained in:
Stefan Haller
2025-07-19 19:35:18 +02:00
parent 6976d38586
commit bc936e8d1b
2 changed files with 26 additions and 19 deletions

View File

@ -15,26 +15,10 @@ var KeepSameCommitSelectedOnExit = NewIntegrationTest(NewIntegrationTestArgs{
commonSetup(shell)
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Commits().
Focus().
Lines(
Contains(`none of the two`).IsSelected(),
Contains(`both files`),
Contains(`only otherFile`),
Contains(`only filterFile`),
).Press(keys.Universal.FilteringMenu).
Tap(func() {
t.ExpectPopup().Menu().
Title(Equals("Filtering")).
Select(Contains("Enter path to filter by")).
Confirm()
filterByFilterFile(t, keys)
t.ExpectPopup().Prompt().
Title(Equals("Enter path:")).
Type("filterF").
SuggestionLines(Equals("filterFile")).
ConfirmFirstSuggestion()
}).
t.Views().Commits().
IsFocused().
Lines(
Contains(`both files`).IsSelected(),
Contains(`only filterFile`),

View File

@ -1,6 +1,7 @@
package filter_by_path
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
@ -17,6 +18,28 @@ func commonSetup(shell *Shell) {
shell.EmptyCommit("none of the two")
}
func filterByFilterFile(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Commits().
Focus().
Lines(
Contains(`none of the two`).IsSelected(),
Contains(`both files`),
Contains(`only otherFile`),
Contains(`only filterFile`),
).
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()
}
func postFilterTest(t *TestDriver) {
t.Views().Information().Content(Contains("Filtering by 'filterFile'"))