1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-01-04 03:48:07 +02:00
lazygit/pkg/integration/tests/branch/reset.go

52 lines
1.4 KiB
Go
Raw Normal View History

2022-12-19 13:38:32 +02: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-27 06:07:11 +02:00
assert.Views().ByName("commits").Lines(
2022-12-25 02:38:00 +02:00
Contains("current-branch commit"),
Contains("root commit"),
)
2022-12-26 07:49:54 +02:00
input.SwitchToBranchesView()
2022-12-19 13:38:32 +02:00
2022-12-27 06:07:11 +02:00
assert.Views().Current().Lines(
2022-12-25 02:38:00 +02:00
Contains("current-branch"),
Contains("other-branch"),
)
2022-12-19 13:38:32 +02:00
input.NextItem()
input.Press(keys.Commits.ViewResetOptions)
2022-12-19 13:38:32 +02:00
2022-12-27 02:34:41 +02:00
input.Menu().Title(Contains("reset to other-branch")).Select(Contains("hard reset")).Confirm()
2022-12-19 13:38:32 +02:00
// ensure that we've returned from the menu before continuing
2022-12-27 06:07:11 +02:00
assert.Views().Current().Name("localBranches")
2022-12-19 13:38:32 +02:00
// assert that we now have the expected commits in the commit panel
2022-12-26 07:49:54 +02:00
input.SwitchToCommitsView()
2022-12-27 06:07:11 +02:00
assert.Views().Current().Lines(
2022-12-25 02:38:00 +02:00
Contains("other-branch commit"),
Contains("root commit"),
)
2022-12-19 13:38:32 +02:00
},
})