From 935f8639305dd372399854c4fdc0e22544d1d89d Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Thu, 20 Aug 2026 18:31:29 +0200 Subject: [PATCH] Keep whole-file discard coverage on the surviving diff view Removing the staging panel must not lose the handoff that happens when a file's final change disappears. Drive that behavior through the focused main view so the test continues to require focus and selection to follow the files panel onto the next diff. Co-Authored-By: GitHub Copilot --- .../discard_all_changes.go | 27 +++++++++---------- pkg/integration/tests/test_list.go | 2 +- 2 files changed, 13 insertions(+), 16 deletions(-) rename pkg/integration/tests/{staging => main_view}/discard_all_changes.go (64%) diff --git a/pkg/integration/tests/staging/discard_all_changes.go b/pkg/integration/tests/main_view/discard_all_changes.go similarity index 64% rename from pkg/integration/tests/staging/discard_all_changes.go rename to pkg/integration/tests/main_view/discard_all_changes.go index 89725da78..c812fa133 100644 --- a/pkg/integration/tests/staging/discard_all_changes.go +++ b/pkg/integration/tests/main_view/discard_all_changes.go @@ -1,4 +1,4 @@ -package staging +package main_view import ( "github.com/jesseduffield/lazygit/pkg/config" @@ -6,10 +6,12 @@ import ( ) var DiscardAllChanges = NewIntegrationTest(NewIntegrationTestArgs{ - Description: "Discard all changes of a file in the staging panel, then assert we land in the staging panel of the next file", + Description: "Discard all changes of a file from the focused main view, then land on the next file's diff", ExtraCmdArgs: []string{}, Skip: false, - SetupConfig: func(config *config.AppConfig) {}, + SetupConfig: func(cfg *config.AppConfig) { + cfg.GetUserConfig().Gui.UseHunkModeInStagingView = false + }, SetupRepo: func(shell *Shell) { shell.CreateFileAndAdd("file1", "one\ntwo\n") shell.CreateFileAndAdd("file2", "1\n2\n") @@ -27,30 +29,25 @@ var DiscardAllChanges = NewIntegrationTest(NewIntegrationTestArgs{ Equals(" M file2"), ). SelectNextItem(). - PressEnter() + Press(keys.Universal.FocusMainView) - t.Views().Staging(). + t.Views().Main(). IsFocused(). - Press(keys.Main.ToggleSelectHunk). SelectedLines(Contains("+three")). - // discard the line Press(keys.Universal.Remove). Tap(func() { t.Common().ConfirmDiscardLines() }). SelectedLines(Contains("+four")). - // discard the other line Press(keys.Universal.Remove). Tap(func() { t.Common().ConfirmDiscardLines() + }) - // because there are no more changes in file1 we switch to file2 - t.Views().Files(). - Lines( - Equals(" M file2"), - ) - }). - // assert we are still in the staging panel, but now looking at the changes of the other file + t.Views().Files().Lines( + Equals(" M file2"), + ) + t.Views().Main(). IsFocused(). SelectedLines(Contains("+3")) }, diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go index ef3954418..870256b50 100644 --- a/pkg/integration/tests/test_list.go +++ b/pkg/integration/tests/test_list.go @@ -377,6 +377,7 @@ var tests = []*components.IntegrationTest{ main_view.CopySelectedDiffLines, main_view.CustomPatchGoesThroughTheDiffRenderer, main_view.CustomPatchIgnoresLineEndingConversion, + main_view.DiscardAllChanges, main_view.DiscardDiffLines, main_view.DiscardFromACommitOnlyWhereItCanBeRewritten, main_view.DiscardLinesFromACommit, @@ -516,7 +517,6 @@ var tests = []*components.IntegrationTest{ shell_commands.History, shell_commands.OmitFromHistory, staging.DiffChangeScreenMode, - staging.DiscardAllChanges, stash.Apply, stash.ApplyPatch, stash.CreateBranch,