From bc936e8d1b1c6a03266c16b37a6126ba53e4c64b Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Sat, 19 Jul 2025 19:35:18 +0200 Subject: [PATCH] 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. --- .../keep_same_commit_selected_on_exit.go | 22 +++--------------- .../tests/filter_by_path/shared.go | 23 +++++++++++++++++++ 2 files changed, 26 insertions(+), 19 deletions(-) diff --git a/pkg/integration/tests/filter_by_path/keep_same_commit_selected_on_exit.go b/pkg/integration/tests/filter_by_path/keep_same_commit_selected_on_exit.go index 76f35650a..a657bdedb 100644 --- a/pkg/integration/tests/filter_by_path/keep_same_commit_selected_on_exit.go +++ b/pkg/integration/tests/filter_by_path/keep_same_commit_selected_on_exit.go @@ -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`), diff --git a/pkg/integration/tests/filter_by_path/shared.go b/pkg/integration/tests/filter_by_path/shared.go index dd2538a9c..015a11f97 100644 --- a/pkg/integration/tests/filter_by_path/shared.go +++ b/pkg/integration/tests/filter_by_path/shared.go @@ -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'"))