1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2024-12-12 11:15:00 +02:00
lazygit/pkg/integration/tests/branch/reset.go

51 lines
1.2 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")
},
2022-12-27 12:47:37 +02:00
Run: func(t *TestDriver, keys config.KeybindingConfig) {
2022-12-27 12:35:36 +02:00
t.Views().Commits().Lines(
2022-12-25 02:38:00 +02:00
Contains("current-branch commit"),
Contains("root commit"),
)
2022-12-27 12:35:36 +02:00
t.Views().Branches().
Focus().
Lines(
2022-12-28 01:23:54 +02:00
Contains("current-branch").IsSelected(),
Contains("other-branch"),
).
SelectNextItem().
Press(keys.Commits.ViewResetOptions)
2022-12-19 13:38:32 +02:00
2022-12-28 01:23:54 +02:00
t.ExpectMenu().
Title(Contains("reset to other-branch")).
Select(Contains("hard reset")).
Confirm()
2022-12-19 13:38:32 +02:00
// assert that we now have the expected commits in the commit panel
2022-12-27 12:35:36 +02:00
t.Views().Commits().
Lines(
Contains("other-branch commit"),
Contains("root commit"),
)
2022-12-19 13:38:32 +02:00
},
})