From be3683ccc8ec3d12d4c7278966d31e0da87ce13a Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Sun, 15 Sep 2024 16:53:04 +0200 Subject: [PATCH] Add test that demonstrates bug with deleting remote branch with different name It's maybe not very common, but it's totally possible for a remote branch to have a different name than the local branch. This test shows that we don't support this properly when deleting the remote branch. --- ...elete_remote_branch_with_different_name.go | 56 +++++++++++++++++++ pkg/integration/tests/test_list.go | 1 + 2 files changed, 57 insertions(+) create mode 100644 pkg/integration/tests/branch/delete_remote_branch_with_different_name.go diff --git a/pkg/integration/tests/branch/delete_remote_branch_with_different_name.go b/pkg/integration/tests/branch/delete_remote_branch_with_different_name.go new file mode 100644 index 000000000..cd9183b2a --- /dev/null +++ b/pkg/integration/tests/branch/delete_remote_branch_with_different_name.go @@ -0,0 +1,56 @@ +package branch + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var DeleteRemoteBranchWithDifferentName = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Delete a remote branch that has a different name than the local branch", + ExtraCmdArgs: []string{}, + Skip: false, + SetupConfig: func(config *config.AppConfig) { + }, + SetupRepo: func(shell *Shell) { + shell.EmptyCommit("one") + shell.CloneIntoRemote("origin") + shell.NewBranch("mybranch-local") + shell.PushBranchAndSetUpstream("origin", "mybranch-local:mybranch-remote") + shell.Checkout("master") + }, + Run: func(t *TestDriver, keys config.KeybindingConfig) { + t.Views().Branches(). + Focus(). + Lines( + Contains("master").IsSelected(), + Contains("mybranch-local ✓"), + ). + SelectNextItem(). + Press(keys.Universal.Remove). + Tap(func() { + t.ExpectPopup(). + Menu(). + Title(Equals("Delete branch 'mybranch-local'?")). + Select(Contains("Delete remote branch")). + Confirm() + }). + Tap(func() { + t.ExpectPopup(). + Confirmation(). + /* EXPECTED: + Title(Equals("Delete branch 'mybranch-remote'?")). + Content(Equals("Are you sure you want to delete the remote branch 'mybranch-remote' from 'origin'?")). + ACTUAL: */ + Title(Equals("Delete branch 'mybranch-local'?")). + Content(Equals("Are you sure you want to delete the remote branch 'mybranch-local' from 'origin'?")). + Confirm() + }). + Lines( + Contains("master"), + /* EXPECTED: + Contains("mybranch-local (upstream gone)").IsSelected(), + ACTUAL: */ + Contains("mybranch-local ✓").IsSelected(), + ) + }, +}) diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go index 281b0a2b3..6c6d484cf 100644 --- a/pkg/integration/tests/test_list.go +++ b/pkg/integration/tests/test_list.go @@ -43,6 +43,7 @@ var tests = []*components.IntegrationTest{ branch.CreateTag, branch.Delete, branch.DeleteRemoteBranchWithCredentialPrompt, + branch.DeleteRemoteBranchWithDifferentName, branch.DetachedHead, branch.NewBranchAutostash, branch.NewBranchFromRemoteTrackingDifferentName,