add integration test for restoring a deleted branch

This commit is contained in:
Samuel Onoja 2026-08-03 12:05:25 +01:00
parent 7da8a04187
commit a133dc0dad
No known key found for this signature in database
2 changed files with 52 additions and 0 deletions

View file

@ -0,0 +1,51 @@
package branch
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var RestoreDeletedBranch = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Restore a deleted local branch from the reflog",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {
shell.
EmptyCommit("base commit").
NewBranch("feature").
EmptyCommit("on feature").
Checkout("master").
EmptyCommit("on master").
RunCommand([]string{"git", "branch", "-D", "feature"})
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Branches().
Focus().
Lines(
Contains("master").IsSelected(),
)
t.Views().Branches().
Press(keys.Branches.RestoreBranch).
Tap(func() {
t.ExpectPopup().
Menu().
Title(Equals("Deleted branches")).
ContainsLines(
Contains("feature"),
).
Select(Contains("feature")).
Confirm()
}).
Tap(func() {
t.ExpectToast(Contains("Restored branch 'feature'"))
})
t.Views().Branches().
Lines(
Contains("master").IsSelected(),
Contains("feature"),
)
},
})

View file

@ -80,6 +80,7 @@ var tests = []*components.IntegrationTest{
branch.ResetToDuplicateNamedTag,
branch.ResetToDuplicateNamedUpstream,
branch.ResetToUpstream,
branch.RestoreDeletedBranch,
branch.SelectCommitsOfCurrentBranch,
branch.SetUpstream,
branch.ShowDivergenceFromBaseBranch,