Add integration test for commit highlighting on focus
A better refactor would be to allow matchers to assert against either a string or a slice of cells, so that I could have the same ergonomics that I have elsewhere, but this is a start.
This commit is contained in:
@@ -133,6 +133,34 @@ func (self *ViewDriver) ContainsLines(matchers ...*Matcher) *ViewDriver {
|
||||
return self
|
||||
}
|
||||
|
||||
func (self *ViewDriver) ContainsColoredText(fgColorStr string, text string) *ViewDriver {
|
||||
self.t.assertWithRetries(func() (bool, string) {
|
||||
view := self.getView()
|
||||
ok := self.getView().ContainsColoredText(fgColorStr, text)
|
||||
if !ok {
|
||||
return false, fmt.Sprintf("expected view '%s' to contain colored text '%s' but it didn't", view.Name(), text)
|
||||
}
|
||||
|
||||
return true, ""
|
||||
})
|
||||
|
||||
return self
|
||||
}
|
||||
|
||||
func (self *ViewDriver) DoesNotContainColoredText(fgColorStr string, text string) *ViewDriver {
|
||||
self.t.assertWithRetries(func() (bool, string) {
|
||||
view := self.getView()
|
||||
ok := !self.getView().ContainsColoredText(fgColorStr, text)
|
||||
if !ok {
|
||||
return false, fmt.Sprintf("expected view '%s' to NOT contain colored text '%s' but it didn't", view.Name(), text)
|
||||
}
|
||||
|
||||
return true, ""
|
||||
})
|
||||
|
||||
return self
|
||||
}
|
||||
|
||||
// asserts on the lines that are selected in the view. Don't use the `IsSelected` matcher with this because it's redundant.
|
||||
func (self *ViewDriver) SelectedLines(matchers ...*Matcher) *ViewDriver {
|
||||
self.validateMatchersPassed(matchers)
|
||||
|
||||
37
pkg/integration/tests/commit/highlight.go
Normal file
37
pkg/integration/tests/commit/highlight.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package commit
|
||||
|
||||
import (
|
||||
"github.com/jesseduffield/lazygit/pkg/config"
|
||||
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||
)
|
||||
|
||||
var Highlight = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Description: "Verify that the commit view highlights the correct lines",
|
||||
ExtraCmdArgs: []string{},
|
||||
Skip: false,
|
||||
SetupConfig: func(config *config.AppConfig) {
|
||||
config.GetUserConfig().Git.Log.ShowGraph = "always"
|
||||
config.GetUserConfig().Gui.AuthorColors = map[string]string{
|
||||
"CI": "red",
|
||||
}
|
||||
},
|
||||
SetupRepo: func(shell *Shell) {
|
||||
shell.EmptyCommit("one")
|
||||
shell.EmptyCommit("two")
|
||||
shell.EmptyCommit("three")
|
||||
},
|
||||
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||
highlightedColor := "#ffffff"
|
||||
|
||||
t.Views().Commits().
|
||||
DoesNotContainColoredText(highlightedColor, "◯").
|
||||
Focus().
|
||||
ContainsColoredText(highlightedColor, "◯")
|
||||
|
||||
t.Views().Files().
|
||||
Focus()
|
||||
|
||||
t.Views().Commits().
|
||||
DoesNotContainColoredText(highlightedColor, "◯")
|
||||
},
|
||||
})
|
||||
@@ -53,6 +53,7 @@ var tests = []*components.IntegrationTest{
|
||||
commit.CommitWithPrefix,
|
||||
commit.CreateTag,
|
||||
commit.DiscardOldFileChange,
|
||||
commit.Highlight,
|
||||
commit.History,
|
||||
commit.HistoryComplex,
|
||||
commit.NewBranch,
|
||||
|
||||
Reference in New Issue
Block a user