1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-06-21 00:30:00 +02:00
Files
.devcontainer
.github
.vscode
cmd
demo
docs
pkg
app
cheatsheet
commands
common
config
constants
env
fakes
gui
i18n
integration
clients
components
tests
bisect
branch
cherry_pick
commit
config
conflicts
custom_commands
demo
diff
file
filter_and_search
filter_by_author
filter_by_path
interactive_rebase
misc
patch_building
reflog
shared
shell_commands
staging
stash
status
submodule
sync
tag
ui
undo
worktree
add_from_branch.go
add_from_branch_detached.go
add_from_commit.go
associate_branch_bisect.go
associate_branch_rebase.go
bare_repo.go
bare_repo_worktree_config.go
crud.go
custom_command.go
detach_worktree_from_branch.go
dotfile_bare_repo.go
double_nested_linked_submodule.go
exclude_file_in_worktree.go
fast_forward_worktree_branch.go
fast_forward_worktree_branch_should_not_pollute_current_worktree.go
force_remove_worktree.go
remove_worktree_from_branch.go
reset_window_tabs.go
symlink_into_repo_subdir.go
worktree_in_repo.go
test_list.go
test_list_generator.go
tests.go
types
README.md
jsonschema
logs
snake
tasks
theme
updates
utils
schema
scripts
test
vendor
.codespellrc
.editorconfig
.gitattributes
.gitignore
.golangci.yml
.goreleaser.yml
CODE-OF-CONDUCT.md
CONTRIBUTING.md
Dockerfile
LICENSE
Makefile
README.md
VISION.md
go.mod
go.sum
main.go
lazygit/pkg/integration/tests/worktree/add_from_branch.go
Jesse Duffield a1fae41051 Fix bug where worktree view would take over window upon switching branches
When switching worktrees (which we can now do via the branch view) we re-layout the windows and their views.
We had the worktree view ahead of the file view based on the Flatten() method in context.go, because it used
to be associated with the branches panel.
2023-07-30 18:35:24 +10:00

66 lines
1.8 KiB
Go

package worktree
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var AddFromBranch = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Add a worktree via the branches view, then switch back to the main worktree via the branches view",
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")
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Branches().
Focus().
Lines(
Contains("mybranch"),
).
Press(keys.Worktrees.ViewWorktreeOptions).
Tap(func() {
t.ExpectPopup().Menu().
Title(Equals("Worktree")).
Select(Contains(`Create worktree from mybranch`).DoesNotContain("detached")).
Confirm()
t.ExpectPopup().Prompt().
Title(Equals("New worktree path")).
Type("../linked-worktree").
Confirm()
t.ExpectPopup().Prompt().
Title(Equals("New branch name")).
Type("newbranch").
Confirm()
}).
// confirm we're still focused on the branches view
IsFocused().
Lines(
Contains("newbranch").IsSelected(),
Contains("mybranch (worktree)"),
).
NavigateToLine(Contains("mybranch")).
Press(keys.Universal.Select).
Tap(func() {
t.ExpectPopup().Confirmation().
Title(Equals("Switch to worktree")).
Content(Equals("This branch is checked out by worktree repo. Do you want to switch to that worktree?")).
Confirm()
}).
Lines(
Contains("mybranch").IsSelected(),
Contains("newbranch (worktree)"),
).
// Confirm the files view is still showing in the files window
Press(keys.Universal.PrevBlock)
t.Views().Files().
IsFocused()
},
})