1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-01-22 05:29:44 +02:00

52 lines
1.3 KiB
Go
Raw Normal View History

2022-12-19 22:38:32 +11:00
package branch
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var Reset = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Hard reset to another branch",
ExtraCmdArgs: "",
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {
shell.NewBranch("current-branch")
shell.EmptyCommit("root commit")
shell.NewBranch("other-branch")
shell.EmptyCommit("other-branch commit")
shell.Checkout("current-branch")
shell.EmptyCommit("current-branch commit")
},
Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
2022-12-26 11:12:56 +11:00
assert.View("commits").Lines(
2022-12-25 11:38:00 +11:00
Contains("current-branch commit"),
Contains("root commit"),
)
2022-12-26 16:49:54 +11:00
input.SwitchToBranchesView()
2022-12-19 22:38:32 +11:00
2022-12-26 16:49:54 +11:00
assert.CurrentView().Lines(
2022-12-25 11:38:00 +11:00
Contains("current-branch"),
Contains("other-branch"),
)
2022-12-19 22:38:32 +11:00
input.NextItem()
input.Press(keys.Commits.ViewResetOptions)
2022-12-19 22:38:32 +11:00
input.Menu(Contains("reset to other-branch"), Contains("hard reset"))
2022-12-19 22:38:32 +11:00
// ensure that we've returned from the menu before continuing
2022-12-26 11:12:56 +11:00
assert.CurrentView().Name("localBranches")
2022-12-19 22:38:32 +11:00
// assert that we now have the expected commits in the commit panel
2022-12-26 16:49:54 +11:00
input.SwitchToCommitsView()
assert.CurrentView().Lines(
2022-12-25 11:38:00 +11:00
Contains("other-branch commit"),
Contains("root commit"),
)
2022-12-19 22:38:32 +11:00
},
})