From 0b0910573bf088db1fc98bb7cd027c5326d3c49b Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Sun, 24 Nov 2024 13:48:36 +0100 Subject: [PATCH] Extract test helper function checkRemoteBranches We'll need it a few more times in the next test we add. --- pkg/integration/tests/branch/delete.go | 24 ++++++------------------ pkg/integration/tests/branch/shared.go | 25 +++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 18 deletions(-) create mode 100644 pkg/integration/tests/branch/shared.go diff --git a/pkg/integration/tests/branch/delete.go b/pkg/integration/tests/branch/delete.go index d277f31b4..ae29a679c 100644 --- a/pkg/integration/tests/branch/delete.go +++ b/pkg/integration/tests/branch/delete.go @@ -150,24 +150,12 @@ var Delete = NewIntegrationTest(NewIntegrationTestArgs{ Confirm() }). Tap(func() { - t.Views().Remotes(). - Focus(). - Lines(Contains("origin")). - PressEnter() - - t.Views(). - RemoteBranches(). - Lines( - Equals("branch-five"), - Equals("branch-four"), - Equals("branch-six"), - Equals("branch-two"), - ). - Press(keys.Universal.Return) - - t.Views(). - Branches(). - Focus() + checkRemoteBranches(t, keys, "origin", []string{ + "branch-five", + "branch-four", + "branch-six", + "branch-two", + }) }). Lines( Contains("current-head"), diff --git a/pkg/integration/tests/branch/shared.go b/pkg/integration/tests/branch/shared.go new file mode 100644 index 000000000..215a3c3af --- /dev/null +++ b/pkg/integration/tests/branch/shared.go @@ -0,0 +1,25 @@ +package branch + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" + "github.com/samber/lo" +) + +func checkRemoteBranches(t *TestDriver, keys config.KeybindingConfig, remoteName string, expectedBranches []string) { + t.Views().Remotes(). + Focus(). + NavigateToLine(Contains(remoteName)). + PressEnter() + + t.Views(). + RemoteBranches(). + Lines( + lo.Map(expectedBranches, func(branch string, _ int) *TextMatcher { return Equals(branch) })..., + ). + Press(keys.Universal.Return) + + t.Views(). + Branches(). + Focus() +}