From 8cc49e3be539b5f5f146830e81b36f7ec67f1fdb Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Mon, 28 Jul 2025 14:02:57 +0200 Subject: [PATCH] Add test demonstrating the problem When filtering to show only tracked files, pressing `a` would also stage untracked files, which is confusing and undesired. --- ...ly_tracked_files_in_tracked_only_filter.go | 57 +++++++++++++++++++ pkg/integration/tests/test_list.go | 1 + 2 files changed, 58 insertions(+) create mode 100644 pkg/integration/tests/filter_and_search/stage_all_stages_only_tracked_files_in_tracked_only_filter.go diff --git a/pkg/integration/tests/filter_and_search/stage_all_stages_only_tracked_files_in_tracked_only_filter.go b/pkg/integration/tests/filter_and_search/stage_all_stages_only_tracked_files_in_tracked_only_filter.go new file mode 100644 index 000000000..aa812c50e --- /dev/null +++ b/pkg/integration/tests/filter_and_search/stage_all_stages_only_tracked_files_in_tracked_only_filter.go @@ -0,0 +1,57 @@ +package filter_and_search + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var StageAllStagesOnlyTrackedFilesInTrackedOnlyFilter = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Staging all files in tracked only view should stage only tracked files", + ExtraCmdArgs: []string{}, + Skip: false, + SetupConfig: func(config *config.AppConfig) { + }, + SetupRepo: func(shell *Shell) { + shell.CreateFileAndAdd("file-tracked", "foo") + + shell.Commit("first commit") + + shell.CreateFile("file-untracked", "bar") + shell.UpdateFile("file-tracked", "baz") + }, + Run: func(t *TestDriver, keys config.KeybindingConfig) { + t.Views().Files(). + Focus(). + Lines( + Equals("▼ /").IsSelected(), + Equals(" M file-tracked"), + Equals(" ?? file-untracked"), + ). + Press(keys.Files.OpenStatusFilter). + Tap(func() { + t.ExpectPopup().Menu(). + Title(Equals("Filtering")). + Select(Contains("Show only tracked files")). + Confirm() + }). + Lines( + Equals(" M file-tracked"), + ). + Press(keys.Files.ToggleStagedAll). + Press(keys.Files.OpenStatusFilter). + Tap(func() { + t.ExpectPopup().Menu(). + Title(Equals("Filtering")). + Select(Contains("No filter")). + Confirm() + }). + Lines( + Equals("▼ /").IsSelected(), + Equals(" M file-tracked"), // 'M' is now in the left column, so file is staged + /* EXPECTED: + Equals(" ?? file-untracked"), + ACTUAL: */ + Equals(" A file-untracked"), + ) + }, +}) diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go index 32fab95ab..57d7a05d0 100644 --- a/pkg/integration/tests/test_list.go +++ b/pkg/integration/tests/test_list.go @@ -229,6 +229,7 @@ var tests = []*components.IntegrationTest{ filter_and_search.NestedFilter, filter_and_search.NestedFilterTransient, filter_and_search.NewSearch, + filter_and_search.StageAllStagesOnlyTrackedFilesInTrackedOnlyFilter, filter_and_search.StagingFolderStagesOnlyTrackedFilesInTrackedOnlyFilter, filter_by_author.SelectAuthor, filter_by_author.TypeAuthor,