Skip to content

Commit 43b5a80

Browse files
Merge pull request #2320 from jesseduffield/migrate-yet-another-integration-test
2 parents b647241 + b13cfdf commit 43b5a80

File tree

66 files changed

+75
-205
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+75
-205
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package branch
2+
3+
import (
4+
"github.com/jesseduffield/lazygit/pkg/config"
5+
. "github.com/jesseduffield/lazygit/pkg/integration/components"
6+
)
7+
8+
var Reset = NewIntegrationTest(NewIntegrationTestArgs{
9+
Description: "Hard reset to another branch",
10+
ExtraCmdArgs: "",
11+
Skip: false,
12+
SetupConfig: func(config *config.AppConfig) {},
13+
SetupRepo: func(shell *Shell) {
14+
shell.NewBranch("current-branch")
15+
shell.EmptyCommit("root commit")
16+
17+
shell.NewBranch("other-branch")
18+
shell.EmptyCommit("other-branch commit")
19+
20+
shell.Checkout("current-branch")
21+
shell.EmptyCommit("current-branch commit")
22+
},
23+
Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
24+
input.SwitchToBranchesWindow()
25+
assert.CurrentViewName("localBranches")
26+
27+
assert.MatchSelectedLine(Contains("current-branch"))
28+
input.NextItem()
29+
assert.MatchSelectedLine(Contains("other-branch"))
30+
31+
input.PressKeys(keys.Commits.ViewResetOptions)
32+
assert.InMenu()
33+
assert.MatchCurrentViewTitle(Contains("reset to other-branch"))
34+
35+
assert.MatchSelectedLine(Contains("soft reset"))
36+
input.NextItem()
37+
assert.MatchSelectedLine(Contains("mixed reset"))
38+
input.NextItem()
39+
assert.MatchSelectedLine(Contains("hard reset"))
40+
41+
input.Confirm()
42+
43+
// ensure that we've returned from the menu before continuing
44+
assert.CurrentViewName("localBranches")
45+
46+
// assert that we now have the expected commits in the commit panel
47+
input.SwitchToCommitsWindow()
48+
assert.CurrentViewName("commits")
49+
assert.CommitCount(2)
50+
assert.MatchSelectedLine(Contains("other-branch commit"))
51+
input.NextItem()
52+
assert.MatchSelectedLine(Contains("root commit"))
53+
},
54+
})

pkg/integration/tests/tests.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ var tests = []*components.IntegrationTest{
3232
branch.Rebase,
3333
branch.RebaseAndDrop,
3434
branch.Suggestions,
35+
branch.Reset,
3536
cherry_pick.CherryPick,
3637
cherry_pick.CherryPickConflicts,
3738
commit.Commit,

test/integration/branchReset/expected/repo/.git_keep/COMMIT_EDITMSG

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/integration/branchReset/expected/repo/.git_keep/HEAD

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/integration/branchReset/expected/repo/.git_keep/ORIG_HEAD

Lines changed: 0 additions & 1 deletion
This file was deleted.
-547 Bytes
Binary file not shown.

test/integration/branchReset/expected/repo/.git_keep/logs/HEAD

Lines changed: 0 additions & 18 deletions
This file was deleted.

test/integration/branchReset/expected/repo/.git_keep/logs/refs/heads/develop

Lines changed: 0 additions & 5 deletions
This file was deleted.

test/integration/branchReset/expected/repo/.git_keep/logs/refs/heads/master

Lines changed: 0 additions & 6 deletions
This file was deleted.
Binary file not shown.

0 commit comments

Comments
 (0)