mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-04-25 12:24:47 +02:00
More explicit test of status panel content
Use Equals instead of Contains for asserting the status view content. This solves the problem that we might assert Contains("↓2 repo"), but what it really shows is "↑1↓2 repo", and the test still succeeds. At best this is confusing. Also, this way we don't have to use the awkward DoesNotContain to check that it really doesn't show a checkmark. To do this, we need to fix two whitespace problems: - there was always a space at the end for no reason. Simply remove it. It was added in efb51eee96, but from looking at that diff it seems it was added accidentally. - there was a space at the beginning if the branch status was empty. This is actually a cosmetic problem, for branches without a status the text was indented by once space. Change this so that the space is added conditionally. It's a bit awkward that we have to use Decolorise here, but this will go away again later in this branch.
This commit is contained in:
parent
7c51ec21bf
commit
19d0048cc4
@ -10,6 +10,7 @@ import (
|
||||
"github.com/jesseduffield/lazygit/pkg/gui/style"
|
||||
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
||||
"github.com/jesseduffield/lazygit/pkg/i18n"
|
||||
"github.com/jesseduffield/lazygit/pkg/utils"
|
||||
)
|
||||
|
||||
func FormatStatus(
|
||||
@ -24,7 +25,10 @@ func FormatStatus(
|
||||
status := ""
|
||||
|
||||
if currentBranch.IsRealBranch() {
|
||||
status += ColoredBranchStatus(currentBranch, itemOperation, tr, userConfig) + " "
|
||||
status += ColoredBranchStatus(currentBranch, itemOperation, tr, userConfig)
|
||||
if utils.Decolorise(status) != "" {
|
||||
status += " "
|
||||
}
|
||||
}
|
||||
|
||||
if workingTreeState != enums.REBASE_MODE_NONE {
|
||||
|
@ -44,7 +44,7 @@ var DeleteRemoteBranchWithCredentialPrompt = NewIntegrationTest(NewIntegrationTe
|
||||
Confirm()
|
||||
}
|
||||
|
||||
t.Views().Status().Content(Contains("✓ repo → mybranch"))
|
||||
t.Views().Status().Content(Equals("✓ repo → mybranch"))
|
||||
|
||||
deleteBranch()
|
||||
|
||||
@ -66,7 +66,7 @@ var DeleteRemoteBranchWithCredentialPrompt = NewIntegrationTest(NewIntegrationTe
|
||||
Content(Contains("incorrect username/password")).
|
||||
Confirm()
|
||||
|
||||
t.Views().Status().Content(Contains("✓ repo → mybranch"))
|
||||
t.Views().Status().Content(Equals("✓ repo → mybranch"))
|
||||
|
||||
// try again with correct password
|
||||
deleteBranch()
|
||||
@ -81,7 +81,7 @@ var DeleteRemoteBranchWithCredentialPrompt = NewIntegrationTest(NewIntegrationTe
|
||||
Type("password").
|
||||
Confirm()
|
||||
|
||||
t.Views().Status().Content(Contains("repo → mybranch").DoesNotContain("✓"))
|
||||
t.Views().Status().Content(Equals("(upstream gone) repo → mybranch"))
|
||||
t.Views().Branches().TopLines(Contains("mybranch (upstream gone)"))
|
||||
},
|
||||
})
|
||||
|
@ -26,7 +26,7 @@ var ForcePush = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Contains("one"),
|
||||
)
|
||||
|
||||
t.Views().Status().Content(Contains("↓1 repo → master"))
|
||||
t.Views().Status().Content(Equals("↓1 repo → master"))
|
||||
|
||||
t.Views().Files().IsFocused().Press(keys.Universal.Push)
|
||||
|
||||
@ -40,7 +40,7 @@ var ForcePush = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Contains("one"),
|
||||
)
|
||||
|
||||
t.Views().Status().Content(Contains("✓ repo → master"))
|
||||
t.Views().Status().Content(Equals("✓ repo → master"))
|
||||
|
||||
t.Views().Remotes().Focus().
|
||||
Lines(Contains("origin")).
|
||||
|
@ -22,7 +22,7 @@ var ForcePushMultipleMatching = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Contains("one"),
|
||||
)
|
||||
|
||||
t.Views().Status().Content(Contains("↓1 repo → master"))
|
||||
t.Views().Status().Content(Equals("↓1 repo → master"))
|
||||
|
||||
t.Views().Branches().
|
||||
Lines(
|
||||
@ -42,7 +42,7 @@ var ForcePushMultipleMatching = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Contains("one"),
|
||||
)
|
||||
|
||||
t.Views().Status().Content(Contains("✓ repo → master"))
|
||||
t.Views().Status().Content(Equals("✓ repo → master"))
|
||||
|
||||
t.Views().Branches().
|
||||
Lines(
|
||||
|
@ -21,7 +21,7 @@ var ForcePushMultipleUpstream = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Contains("one"),
|
||||
)
|
||||
|
||||
t.Views().Status().Content(Contains("↓1 repo → master"))
|
||||
t.Views().Status().Content(Equals("↓1 repo → master"))
|
||||
|
||||
t.Views().Branches().
|
||||
Lines(
|
||||
@ -41,7 +41,7 @@ var ForcePushMultipleUpstream = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Contains("one"),
|
||||
)
|
||||
|
||||
t.Views().Status().Content(Contains("✓ repo → master"))
|
||||
t.Views().Status().Content(Equals("✓ repo → master"))
|
||||
|
||||
t.Views().Branches().
|
||||
Lines(
|
||||
|
@ -26,7 +26,7 @@ var Pull = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Contains("one"),
|
||||
)
|
||||
|
||||
t.Views().Status().Content(Contains("↓1 repo → master"))
|
||||
t.Views().Status().Content(Equals("↓1 repo → master"))
|
||||
|
||||
t.Views().Files().IsFocused().Press(keys.Universal.Pull)
|
||||
|
||||
@ -36,6 +36,6 @@ var Pull = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Contains("one"),
|
||||
)
|
||||
|
||||
t.Views().Status().Content(Contains("✓ repo → master"))
|
||||
t.Views().Status().Content(Equals("✓ repo → master"))
|
||||
},
|
||||
})
|
||||
|
@ -25,7 +25,7 @@ var PullAndSetUpstream = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Contains("one"),
|
||||
)
|
||||
|
||||
t.Views().Status().Content(Contains("repo → master"))
|
||||
t.Views().Status().Content(Equals("repo → master"))
|
||||
|
||||
t.Views().Files().IsFocused().Press(keys.Universal.Pull)
|
||||
|
||||
@ -40,6 +40,6 @@ var PullAndSetUpstream = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Contains("one"),
|
||||
)
|
||||
|
||||
t.Views().Status().Content(Contains("✓ repo → master"))
|
||||
t.Views().Status().Content(Equals("✓ repo → master"))
|
||||
},
|
||||
})
|
||||
|
@ -33,13 +33,13 @@ var PullMerge = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Contains("one"),
|
||||
)
|
||||
|
||||
t.Views().Status().Content(Contains("↓2 repo → master"))
|
||||
t.Views().Status().Content(Equals("↑1↓2 repo → master"))
|
||||
|
||||
t.Views().Files().
|
||||
IsFocused().
|
||||
Press(keys.Universal.Pull)
|
||||
|
||||
t.Views().Status().Content(Contains("↑2 repo → master"))
|
||||
t.Views().Status().Content(Equals("↑2 repo → master"))
|
||||
|
||||
t.Views().Commits().
|
||||
Lines(
|
||||
|
@ -34,7 +34,7 @@ var PullMergeConflict = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Contains("one"),
|
||||
)
|
||||
|
||||
t.Views().Status().Content(Contains("↓2 repo → master"))
|
||||
t.Views().Status().Content(Equals("↑1↓2 repo → master"))
|
||||
|
||||
t.Views().Files().
|
||||
IsFocused().
|
||||
@ -62,7 +62,7 @@ var PullMergeConflict = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
|
||||
t.Common().ContinueOnConflictsResolved()
|
||||
|
||||
t.Views().Status().Content(Contains("↑2 repo → master"))
|
||||
t.Views().Status().Content(Equals("↑2 repo → master"))
|
||||
|
||||
t.Views().Commits().
|
||||
Focus().
|
||||
|
@ -35,13 +35,13 @@ var PullRebase = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Contains("one"),
|
||||
)
|
||||
|
||||
t.Views().Status().Content(Contains("↓2 repo → master"))
|
||||
t.Views().Status().Content(Equals("↑1↓2 repo → master"))
|
||||
|
||||
t.Views().Files().
|
||||
IsFocused().
|
||||
Press(keys.Universal.Pull)
|
||||
|
||||
t.Views().Status().Content(Contains("↑1 repo → master"))
|
||||
t.Views().Status().Content(Equals("↑1 repo → master"))
|
||||
|
||||
t.Views().Commits().
|
||||
Lines(
|
||||
|
@ -34,7 +34,7 @@ var PullRebaseConflict = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Contains("one"),
|
||||
)
|
||||
|
||||
t.Views().Status().Content(Contains("↓2 repo → master"))
|
||||
t.Views().Status().Content(Equals("↑1↓2 repo → master"))
|
||||
|
||||
t.Views().Files().
|
||||
IsFocused().
|
||||
@ -63,7 +63,7 @@ var PullRebaseConflict = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
|
||||
t.Common().ContinueOnConflictsResolved()
|
||||
|
||||
t.Views().Status().Content(Contains("↑1 repo → master"))
|
||||
t.Views().Status().Content(Equals("↑1 repo → master"))
|
||||
|
||||
t.Views().Commits().
|
||||
Focus().
|
||||
|
@ -38,7 +38,7 @@ var PullRebaseInteractiveConflict = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Contains("one"),
|
||||
)
|
||||
|
||||
t.Views().Status().Content(Contains("↓2 repo → master"))
|
||||
t.Views().Status().Content(Equals("↑2↓2 repo → master"))
|
||||
|
||||
t.Views().Files().
|
||||
IsFocused().
|
||||
@ -76,7 +76,7 @@ var PullRebaseInteractiveConflict = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
|
||||
t.Common().ContinueOnConflictsResolved()
|
||||
|
||||
t.Views().Status().Content(Contains("↑2 repo → master"))
|
||||
t.Views().Status().Content(Equals("↑2 repo → master"))
|
||||
|
||||
t.Views().Commits().
|
||||
Focus().
|
||||
|
@ -38,7 +38,7 @@ var PullRebaseInteractiveConflictDrop = NewIntegrationTest(NewIntegrationTestArg
|
||||
Contains("one"),
|
||||
)
|
||||
|
||||
t.Views().Status().Content(Contains("↓2 repo → master"))
|
||||
t.Views().Status().Content(Equals("↑2↓2 repo → master"))
|
||||
|
||||
t.Views().Files().
|
||||
IsFocused().
|
||||
@ -85,7 +85,7 @@ var PullRebaseInteractiveConflictDrop = NewIntegrationTest(NewIntegrationTestArg
|
||||
|
||||
t.Common().ContinueOnConflictsResolved()
|
||||
|
||||
t.Views().Status().Content(Contains("↑1 repo → master"))
|
||||
t.Views().Status().Content(Equals("↑1 repo → master"))
|
||||
|
||||
t.Views().Commits().
|
||||
Focus().
|
||||
|
@ -21,7 +21,7 @@ var Push = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
shell.EmptyCommit("two")
|
||||
},
|
||||
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.Views().Status().Content(Contains("↑1 repo → master"))
|
||||
t.Views().Status().Content(Equals("↑1 repo → master"))
|
||||
|
||||
t.Views().Files().
|
||||
IsFocused().
|
||||
|
@ -22,7 +22,7 @@ var PushAndAutoSetUpstream = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
},
|
||||
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||
// assert no mention of upstream/downstream changes
|
||||
t.Views().Status().Content(MatchesRegexp(`^\s+repo → master`))
|
||||
t.Views().Status().Content(Equals("repo → master"))
|
||||
|
||||
t.Views().Files().
|
||||
IsFocused().
|
||||
|
@ -19,7 +19,7 @@ var PushAndSetUpstream = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
},
|
||||
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||
// assert no mention of upstream/downstream changes
|
||||
t.Views().Status().Content(MatchesRegexp(`^\s+repo → master`))
|
||||
t.Views().Status().Content(Equals("repo → master"))
|
||||
|
||||
t.Views().Files().
|
||||
IsFocused().
|
||||
|
@ -24,13 +24,13 @@ var PushFollowTags = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
shell.SetConfig("push.followTags", "true")
|
||||
},
|
||||
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.Views().Status().Content(Contains("↑1 repo → master"))
|
||||
t.Views().Status().Content(Equals("↑1 repo → master"))
|
||||
|
||||
t.Views().Files().
|
||||
IsFocused().
|
||||
Press(keys.Universal.Push)
|
||||
|
||||
t.Views().Status().Content(Contains("✓ repo → master"))
|
||||
t.Views().Status().Content(Equals("✓ repo → master"))
|
||||
|
||||
t.Views().Remotes().
|
||||
Focus().
|
||||
|
@ -22,13 +22,13 @@ var PushNoFollowTags = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
shell.CreateAnnotatedTag("mytag", "message", "HEAD")
|
||||
},
|
||||
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.Views().Status().Content(Contains("✓ repo → master"))
|
||||
t.Views().Status().Content(Equals("✓ repo → master"))
|
||||
|
||||
t.Views().Files().
|
||||
IsFocused().
|
||||
Press(keys.Universal.Push)
|
||||
|
||||
t.Views().Status().Content(Contains("✓ repo → master"))
|
||||
t.Views().Status().Content(Equals("✓ repo → master"))
|
||||
|
||||
t.Views().Remotes().
|
||||
Focus().
|
||||
|
@ -26,7 +26,7 @@ var PushWithCredentialPrompt = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
shell.CopyHelpFile("pre-push", ".git/hooks/pre-push")
|
||||
},
|
||||
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.Views().Status().Content(Contains("↑1 repo → master"))
|
||||
t.Views().Status().Content(Equals("↑1 repo → master"))
|
||||
|
||||
t.Views().Files().
|
||||
IsFocused().
|
||||
@ -50,7 +50,7 @@ var PushWithCredentialPrompt = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Content(Contains("incorrect username/password")).
|
||||
Confirm()
|
||||
|
||||
t.Views().Status().Content(Contains("↑1 repo → master"))
|
||||
t.Views().Status().Content(Equals("↑1 repo → master"))
|
||||
|
||||
// try again with correct password
|
||||
t.Views().Files().
|
||||
@ -67,7 +67,7 @@ var PushWithCredentialPrompt = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Type("password").
|
||||
Confirm()
|
||||
|
||||
t.Views().Status().Content(Contains("✓ repo → master"))
|
||||
t.Views().Status().Content(Equals("✓ repo → master"))
|
||||
|
||||
assertSuccessfullyPushed(t)
|
||||
},
|
||||
|
@ -24,7 +24,7 @@ func createTwoBranchesReadyToForcePush(shell *Shell) {
|
||||
}
|
||||
|
||||
func assertSuccessfullyPushed(t *TestDriver) {
|
||||
t.Views().Status().Content(Contains("✓ repo → master"))
|
||||
t.Views().Status().Content(Equals("✓ repo → master"))
|
||||
|
||||
t.Views().Remotes().
|
||||
Focus().
|
||||
|
Loading…
x
Reference in New Issue
Block a user