1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-07-30 03:23:08 +03:00

Add search history

Add search history for filterable and searchable views.
This commit is contained in:
Karim Khaleel
2023-08-04 14:01:30 +03:00
parent ab5875c78f
commit edec116ceb
12 changed files with 270 additions and 8 deletions

View File

@ -0,0 +1,77 @@
package filter_and_search
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var FilterSearchHistory = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Navigating search history",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Files().
// populate search history with some values
FilterOrSearch("1").
FilterOrSearch("2").
FilterOrSearch("3").
Press(keys.Universal.StartSearch).
// clear initial search value
Tap(func() {
t.ExpectSearch().Clear()
}).
// test main search history functionality
Tap(func() {
t.Views().Search().
Press(keys.Universal.PrevItem).
Content(Contains("3")).
Press(keys.Universal.PrevItem).
Content(Contains("2")).
Press(keys.Universal.PrevItem).
Content(Contains("1")).
Press(keys.Universal.PrevItem).
Content(Contains("1")).
Press(keys.Universal.NextItem).
Content(Contains("2")).
Press(keys.Universal.NextItem).
Content(Contains("3")).
Press(keys.Universal.NextItem).
Content(Contains("")).
Press(keys.Universal.NextItem).
Content(Contains("")).
Press(keys.Universal.PrevItem).
Content(Contains("3")).
PressEscape()
}).
// test that it resets after you enter and exit a search
Press(keys.Universal.StartSearch).
Tap(func() {
t.Views().Search().
Press(keys.Universal.PrevItem).
Content(Contains("3")).
PressEscape()
})
// test that the histories are separate for each view
t.Views().Commits().
Focus().
FilterOrSearch("a").
FilterOrSearch("b").
FilterOrSearch("c").
Press(keys.Universal.StartSearch).
Tap(func() {
t.ExpectSearch().Clear()
}).
Tap(func() {
t.Views().Search().
Press(keys.Universal.PrevItem).
Content(Contains("c")).
Press(keys.Universal.PrevItem).
Content(Contains("b")).
Press(keys.Universal.PrevItem).
Content(Contains("a"))
})
},
})

View File

@ -118,6 +118,7 @@ var tests = []*components.IntegrationTest{
filter_and_search.FilterFuzzy,
filter_and_search.FilterMenu,
filter_and_search.FilterRemoteBranches,
filter_and_search.FilterSearchHistory,
filter_and_search.NestedFilter,
filter_and_search.NestedFilterTransient,
filter_by_path.CliArg,