Files
lazygit/pkg/gui/side_panels_test.go
Stefan HallerandClaude Opus 4.8 56f3049af4 Drive the side panel layout from gui.sidePanels
Replace the hard-coded side panel order, tab groupings, and window
assignments with values resolved from the gui.sidePanels config. The panel
order (SideWindows and the layout boxes), the tab strips (viewTabMap), the
per-context window names, each window's default view, and the jump-label
groups all now come from the config rather than from five separate
hard-coded lists.

A panel's window name is the name of its first tab, and panels not listed
in the config get their own window name so their views stay hidden instead
of overlapping a visible panel. Three small lookups translate config names
into views, tab titles, and contexts; a test keeps them in sync with the
set of valid names. The lookups are split this way (rather than one
resolver) because configureViewProperties runs before the context tree
exists, so the title/view lookups must not depend on it.

The config is applied to a repo's contexts via applySidePanelConfig on
every repo entry, including the cached-repo path: a repo's per-repo config
can differ from the previously visited one's, so each repo's contexts must
be (re)assigned from its own config rather than kept from when they were
first built.

With the default config this reproduces today's layout exactly.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-23 14:15:18 +02:00

31 lines
831 B
Go

package gui
import (
"sort"
"testing"
"github.com/jesseduffield/lazygit/pkg/config"
"github.com/samber/lo"
"github.com/stretchr/testify/assert"
)
func sortedKeys[V any](m map[string]V) []string {
keys := lo.Keys(m)
sort.Strings(keys)
return keys
}
// The three lookups that translate gui.sidePanels names into views, titles, and
// contexts must each cover exactly the set of valid names, or a config that uses
// a name missing from one of them would hit a nil lookup at runtime.
func TestSidePanelLookupsCoverAllValidTabs(t *testing.T) {
want := lo.Uniq(config.ValidSidePanelTabs)
sort.Strings(want)
gui := NewDummyGui()
assert.Equal(t, want, sortedKeys(sidePanelViewNames))
assert.Equal(t, want, sortedKeys(gui.sidePanelTabTitles()))
assert.Equal(t, want, sortedKeys(sidePanelContexts(gui.contextTree())))
}