diff --git a/pkg/integration/tests/main_view/show_the_tab_switched_to_last.go b/pkg/integration/tests/main_view/show_the_tab_switched_to_last.go new file mode 100644 index 000000000..df33d3b72 --- /dev/null +++ b/pkg/integration/tests/main_view/show_the_tab_switched_to_last.go @@ -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")) + }, +}) diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go index 264a4bc95..f836f944e 100644 --- a/pkg/integration/tests/test_list.go +++ b/pkg/integration/tests/test_list.go @@ -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,