From 706891e92bf54f659952f60b905bd5b3ac45d9e9 Mon Sep 17 00:00:00 2001 From: Chris McDonnell Date: Tue, 27 May 2025 22:47:04 -0400 Subject: [PATCH] Add integration test for resetting to upstream branch with duplicate name --- .../reset_to_duplicate_named_upstream.go | 57 +++++++++++++++++++ pkg/integration/tests/test_list.go | 1 + 2 files changed, 58 insertions(+) create mode 100644 pkg/integration/tests/branch/reset_to_duplicate_named_upstream.go diff --git a/pkg/integration/tests/branch/reset_to_duplicate_named_upstream.go b/pkg/integration/tests/branch/reset_to_duplicate_named_upstream.go new file mode 100644 index 000000000..a375e7e75 --- /dev/null +++ b/pkg/integration/tests/branch/reset_to_duplicate_named_upstream.go @@ -0,0 +1,57 @@ +package branch + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var ResetToDuplicateNamedUpstream = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Hard reset the current branch to an upstream branch when there is a competing tag name", + ExtraCmdArgs: []string{}, + Skip: false, + SetupConfig: func(config *config.AppConfig) {}, + SetupRepo: func(shell *Shell) { + shell. + CloneIntoRemote("origin"). + NewBranch("foo"). + EmptyCommit("commit 1"). + PushBranchAndSetUpstream("origin", "foo"). + EmptyCommit("commit 2"). + CreateLightweightTag("origin/foo", "HEAD") + }, + Run: func(t *TestDriver, keys config.KeybindingConfig) { + t.Views().Commits().Lines( + Contains("commit 2"), + Contains("commit 1"), + ) + t.Views().Tags().Focus().Lines(Contains("origin/foo")) + + t.Views().Remotes().Focus(). + Lines(Contains("origin")). + PressEnter() + t.Views().RemoteBranches().IsFocused(). + Lines(Contains("foo")). + Press(keys.Commits.ViewResetOptions) + t.ExpectPopup().Menu(). + Title(Contains("Reset to origin/foo")). + Select(Contains("Hard reset")). + Confirm() + + t.Views().Commits().Lines( + Contains("commit 1"), + ) + + t.Views().Tags().Focus(). + Lines(Contains("origin/foo")). + Press(keys.Commits.ViewResetOptions) + t.ExpectPopup().Menu(). + Title(Contains("Reset to origin/foo")). + Select(Contains("Hard reset")). + Confirm() + + t.Views().Commits().Lines( + Contains("commit 2"), + Contains("commit 1"), + ) + }, +}) diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go index e46ff0ca3..8ef18fe47 100644 --- a/pkg/integration/tests/test_list.go +++ b/pkg/integration/tests/test_list.go @@ -72,6 +72,7 @@ var tests = []*components.IntegrationTest{ branch.Rename, branch.Reset, branch.ResetToDuplicateNamedTag, + branch.ResetToDuplicateNamedUpstream, branch.ResetToUpstream, branch.SelectCommitsOfCurrentBranch, branch.SetUpstream,