Add a test for switching tabs twice in rapid succession

If two tab switches are handled before the next layout, and the first
tab shows a diff in the main view while the second one shows a message,
the main view ends up showing the diff.

A diff's task is only created after the layout, since the layout
settles the width that the diff is laid out to. A message's task is
created right away. So the diff's task is created after the message's,
and replaces it.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Stefan Haller
2026-10-05 14:55:13 +02:00
co-authored by Claude Opus 5.5
parent 4ac61d6c21
commit 4d55e67e2e
2 changed files with 43 additions and 0 deletions
@@ -0,0 +1,42 @@
package main_view
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
// Both tab switches are handled before the next layout. Switching to the Files tab
// asks for the file's diff, whose task is only created after the layout; switching
// back to the Worktrees tab asks for the worktree's details, whose task is created
// right away. The main view has to show what was asked for last.
var ShowTheTabSwitchedToLast = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Switching tabs twice in rapid succession leaves the main view showing the second tab's content",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {
shell.CreateFileAndAdd("file1", "one\n")
shell.Commit("one")
shell.UpdateFile("file1", "ONE\n")
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Worktrees().
Focus().
Lines(
Contains("(main worktree)").IsSelected(),
)
t.Views().Main().
Content(Contains("Path:"))
t.Views().Worktrees().
PressRapidly(keys.Universal.PrevTab, keys.Universal.NextTab).
IsFocused()
t.Views().Main().
/* EXPECTED:
Content(Contains("Path:"))
ACTUAL: */
Content(Contains("diff --git a/file1 b/file1"))
},
})
+1
View File
@@ -480,6 +480,7 @@ var tests = []*components.IntegrationTest{
main_view.SelectionCommandTooltipsFollowTheDiff,
main_view.SelectionCommandsOnlyWhereTheyApply,
main_view.SelectionOverTheCustomPatch,
main_view.ShowTheTabSwitchedToLast,
main_view.StageDeletedFile,
main_view.StageDiffLines,
main_view.StageDiffLinesOfAPathWithASpace,