jesseduffield.lazygit/pkg/integration/tests/worktree/add_from_stash.go
Stefan Haller 737fb98967 Move the new-worktree keybinding from worktrees to universal
The command was renamed from "View worktree options" to "New worktree",
but its keybinding config key was still 'worktrees.viewWorktreeOptions'.
That name no longer matches the command, and the 'worktrees' section made
little sense: it held a single binding that isn't even used in the
worktrees panel (that panel uses universal.new), only in the branches,
remotes, tags, commits, and stash panels. Other keybinding sections are
named after the panel they're local to; this one wasn't local to any.

Move it to universal.newWorktree, which describes the action and drops the
spurious section, and migrate existing configs automatically.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-03 18:53:05 +02:00

52 lines
1.3 KiB
Go

package worktree
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var AddFromStash = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Create a new branch and worktree from a stash entry",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {
shell.NewBranch("mybranch")
shell.CreateFileAndAdd("README.md", "hello world")
shell.Commit("initial commit")
shell.UpdateFile("README.md", "work in progress")
shell.Stash("my stash")
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Stash().
Focus().
Lines(
Contains("my stash").IsSelected(),
).
Press(keys.Universal.NewWorktree).
Tap(func() {
t.ExpectPopup().Menu().
Title(Equals("New worktree")).
Select(Contains("New branch and worktree from 'stash@{0}'")).
Confirm()
t.ExpectPopup().Prompt().
Title(Equals("New branch and worktree name")).
Type("from-stash").
Confirm()
t.ExpectPopup().Menu().
Title(Equals("Worktree location")).
Confirm()
})
// we've switched into the new worktree, on the new branch
t.Views().Branches().
IsFocused().
Lines(
Contains("from-stash").IsSelected(),
Contains("mybranch (worktree repo)"),
)
},
})