mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-08-06 22:33:07 +02:00
Add new command "Checkout previous branch"
This commit is contained in:
51
pkg/integration/tests/branch/checkout_previous_branch.go
Normal file
51
pkg/integration/tests/branch/checkout_previous_branch.go
Normal file
@ -0,0 +1,51 @@
|
||||
package branch
|
||||
|
||||
import (
|
||||
"github.com/jesseduffield/lazygit/pkg/config"
|
||||
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||
)
|
||||
|
||||
var CheckoutPreviousBranch = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Description: "Checkout to the previous branch using the checkout previous branch functionality",
|
||||
ExtraCmdArgs: []string{},
|
||||
Skip: false,
|
||||
SetupConfig: func(config *config.AppConfig) {},
|
||||
SetupRepo: func(shell *Shell) {
|
||||
shell.
|
||||
CreateNCommits(3).
|
||||
NewBranch("previous-branch").
|
||||
EmptyCommit("previous commit").
|
||||
Checkout("master").
|
||||
EmptyCommit("master commit")
|
||||
},
|
||||
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.Views().Branches().
|
||||
Focus().
|
||||
Lines(
|
||||
Contains("master").IsSelected(),
|
||||
Contains("previous-branch"),
|
||||
)
|
||||
|
||||
// Press the checkout previous branch key (should checkout previous-branch)
|
||||
t.Views().Branches().
|
||||
Press(keys.Branches.CheckoutPreviousBranch).
|
||||
Lines(
|
||||
Contains("previous-branch").IsSelected(),
|
||||
Contains("master"),
|
||||
)
|
||||
|
||||
// Verify we're on previous-branch
|
||||
t.Git().CurrentBranchName("previous-branch")
|
||||
|
||||
// Press again to go back to master
|
||||
t.Views().Branches().
|
||||
Press(keys.Branches.CheckoutPreviousBranch).
|
||||
Lines(
|
||||
Contains("master").IsSelected(),
|
||||
Contains("previous-branch"),
|
||||
)
|
||||
|
||||
// Verify we're back on master
|
||||
t.Git().CurrentBranchName("master")
|
||||
},
|
||||
})
|
@ -40,6 +40,7 @@ var tests = []*components.IntegrationTest{
|
||||
bisect.Skip,
|
||||
branch.CheckoutAutostash,
|
||||
branch.CheckoutByName,
|
||||
branch.CheckoutPreviousBranch,
|
||||
branch.CreateTag,
|
||||
branch.Delete,
|
||||
branch.DeleteMultiple,
|
||||
|
Reference in New Issue
Block a user