diff --git a/pkg/integration/components/shell.go b/pkg/integration/components/shell.go index 01a9caf3a..4fb2d5f52 100644 --- a/pkg/integration/components/shell.go +++ b/pkg/integration/components/shell.go @@ -142,6 +142,10 @@ func (self *Shell) NewBranchFrom(name string, from string) *Shell { return self.RunCommand([]string{"git", "checkout", "-b", name, from}) } +func (self *Shell) RenameCurrentBranch(newName string) *Shell { + return self.RunCommand([]string{"git", "branch", "-m", newName}) +} + func (self *Shell) Checkout(name string) *Shell { return self.RunCommand([]string{"git", "checkout", name}) } diff --git a/pkg/integration/tests/branch/rebase_to_upstream.go b/pkg/integration/tests/branch/rebase_to_upstream.go index f8b2d6fd1..a47da2b1a 100644 --- a/pkg/integration/tests/branch/rebase_to_upstream.go +++ b/pkg/integration/tests/branch/rebase_to_upstream.go @@ -16,8 +16,9 @@ var RebaseToUpstream = NewIntegrationTest(NewIntegrationTestArgs{ EmptyCommit("ensure-master"). EmptyCommit("to-be-added"). // <- this will only exist remotely PushBranchAndSetUpstream("origin", "master"). + RenameCurrentBranch("master-local"). HardReset("HEAD~1"). - NewBranchFrom("base-branch", "master"). + NewBranchFrom("base-branch", "master-local"). EmptyCommit("base-branch-commit"). NewBranch("target"). EmptyCommit("target-commit") @@ -34,13 +35,13 @@ var RebaseToUpstream = NewIntegrationTest(NewIntegrationTestArgs{ Lines( Contains("target").IsSelected(), Contains("base-branch"), - Contains("master"), + Contains("master-local"), ). SelectNextItem(). Lines( Contains("target"), Contains("base-branch").IsSelected(), - Contains("master"), + Contains("master-local"), ). Press(keys.Branches.SetUpstream). Tap(func() { @@ -58,13 +59,16 @@ var RebaseToUpstream = NewIntegrationTest(NewIntegrationTestArgs{ Lines( Contains("target"), Contains("base-branch"), - Contains("master").IsSelected(), + Contains("master-local").IsSelected(), ). Press(keys.Branches.SetUpstream). Tap(func() { t.ExpectPopup().Menu(). Title(Equals("Upstream options")). + /* EXPECTED: Select(Contains("Rebase checked-out branch onto origin/master...")). + ACTUAL: */ + Select(Contains("Rebase checked-out branch onto origin/master-local...")). Confirm() t.ExpectPopup().Menu(). Title(Equals("Rebase 'target'")). diff --git a/pkg/integration/tests/branch/reset_to_upstream.go b/pkg/integration/tests/branch/reset_to_upstream.go index 3cdbb561d..75dcfd3bd 100644 --- a/pkg/integration/tests/branch/reset_to_upstream.go +++ b/pkg/integration/tests/branch/reset_to_upstream.go @@ -19,6 +19,7 @@ var ResetToUpstream = NewIntegrationTest(NewIntegrationTestArgs{ NewBranch("soft-branch"). EmptyCommit("soft commit"). PushBranchAndSetUpstream("origin", "soft-branch"). + RenameCurrentBranch("soft-branch-local"). NewBranch("base"). EmptyCommit("base-branch commit"). CreateFile("file-1", "content"). @@ -33,7 +34,7 @@ var ResetToUpstream = NewIntegrationTest(NewIntegrationTestArgs{ Focus(). Lines( Contains("base").IsSelected(), - Contains("soft-branch"), + Contains("soft-branch-local"), Contains("hard-branch"), ). Press(keys.Branches.SetUpstream). @@ -51,21 +52,34 @@ var ResetToUpstream = NewIntegrationTest(NewIntegrationTestArgs{ SelectNextItem(). Lines( Contains("base"), - Contains("soft-branch").IsSelected(), + Contains("soft-branch-local").IsSelected(), Contains("hard-branch"), ). Press(keys.Branches.SetUpstream). Tap(func() { t.ExpectPopup().Menu(). Title(Equals("Upstream options")). + /* EXPECTED: Select(Contains("Reset checked-out branch onto origin/soft-branch...")). + ACTUAL: */ + Select(Contains("Reset checked-out branch onto origin/soft-branch-local...")). Confirm() t.ExpectPopup().Menu(). + /* EXPECTED: Title(Equals("Reset to origin/soft-branch")). + ACTUAL: */ + Title(Equals("Reset to origin/soft-branch-local")). Select(Contains("Soft reset")). Confirm() + + // Bug: the command fails + t.ExpectPopup().Alert(). + Title(Equals("Error")). + Content(Contains("fatal: ambiguous argument 'origin/soft-branch-local': unknown revision or path not in the working tree.")). + Confirm() }) + /* Since the command failed, the following assertions are not valid t.Views().Commits().Lines( Contains("soft commit"), Contains("hard commit"), @@ -74,13 +88,14 @@ var ResetToUpstream = NewIntegrationTest(NewIntegrationTestArgs{ Contains("file-1").Contains("A"), Contains("file-2").Contains("A"), ) + */ // hard reset t.Views().Branches(). Focus(). Lines( Contains("base"), - Contains("soft-branch").IsSelected(), + Contains("soft-branch-local").IsSelected(), Contains("hard-branch"), ). NavigateToLine(Contains("hard-branch")).