diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2022-12-19 22:38:32 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2022-12-19 22:38:32 +1100 |
commit | b13cfdfea068919ed120c454368c3ce18b21eda9 (patch) | |
tree | f5eaff5da52e4cb023f1d0644f32a1c0f9a557a2 /pkg/integration/tests/branch/reset.go | |
parent | b6472415210a9cc74024d82c10e928ea153f3ad9 (diff) |
migrate branch reset integration test
Diffstat (limited to 'pkg/integration/tests/branch/reset.go')
-rw-r--r-- | pkg/integration/tests/branch/reset.go | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/pkg/integration/tests/branch/reset.go b/pkg/integration/tests/branch/reset.go new file mode 100644 index 000000000..344c1b821 --- /dev/null +++ b/pkg/integration/tests/branch/reset.go @@ -0,0 +1,54 @@ +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) { + input.SwitchToBranchesWindow() + assert.CurrentViewName("localBranches") + + assert.MatchSelectedLine(Contains("current-branch")) + input.NextItem() + assert.MatchSelectedLine(Contains("other-branch")) + + input.PressKeys(keys.Commits.ViewResetOptions) + assert.InMenu() + assert.MatchCurrentViewTitle(Contains("reset to other-branch")) + + assert.MatchSelectedLine(Contains("soft reset")) + input.NextItem() + assert.MatchSelectedLine(Contains("mixed reset")) + input.NextItem() + assert.MatchSelectedLine(Contains("hard reset")) + + input.Confirm() + + // ensure that we've returned from the menu before continuing + assert.CurrentViewName("localBranches") + + // assert that we now have the expected commits in the commit panel + input.SwitchToCommitsWindow() + assert.CurrentViewName("commits") + assert.CommitCount(2) + assert.MatchSelectedLine(Contains("other-branch commit")) + input.NextItem() + assert.MatchSelectedLine(Contains("root commit")) + }, +}) |