filter_and_search

package
v0.41.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 22, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var FilterCommitFiles = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Basic commit file filtering by text",
	ExtraCmdArgs: []string{},
	Skip:         true,
	SetupConfig:  func(config *config.AppConfig) {},
	SetupRepo: func(shell *Shell) {
		shell.CreateDir("folder1")
		shell.CreateFileAndAdd("folder1/apple-grape", "apple-grape")
		shell.CreateFileAndAdd("folder1/apple-orange", "apple-orange")
		shell.CreateFileAndAdd("folder1/grape-orange", "grape-orange")
		shell.Commit("first commit")
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().Commits().
			Focus().
			Lines(
				Contains(`first commit`).IsSelected(),
			).
			Press(keys.Universal.Confirm)

		t.Views().CommitFiles().
			IsFocused().
			Lines(
				Contains(`folder1`).IsSelected(),
				Contains(`apple-grape`),
				Contains(`apple-orange`),
				Contains(`grape-orange`),
			).
			Press(keys.Files.ToggleTreeView).
			Lines(
				Contains(`folder1/apple-grape`).IsSelected(),
				Contains(`folder1/apple-orange`),
				Contains(`folder1/grape-orange`),
			).
			FilterOrSearch("apple").
			Lines(
				Contains(`folder1/apple-grape`).IsSelected(),
				Contains(`folder1/apple-orange`),
			).
			Press(keys.Files.ToggleTreeView).
			Lines(
				Contains(`folder1`),
				Contains(`apple-grape`).IsSelected(),
				Contains(`apple-orange`),
			).
			Press(keys.Files.ToggleTreeView).
			Lines(
				Contains(`folder1/apple-grape`).IsSelected(),
				Contains(`folder1/apple-orange`),
			).
			NavigateToLine(Contains(`folder1/apple-orange`)).
			Press(keys.Universal.Return).
			Lines(
				Contains(`folder1/apple-grape`),

				Contains(`folder1/apple-orange`).IsSelected(),
				Contains(`folder1/grape-orange`),
			).
			Tap(func() {
				t.Views().Search().IsInvisible()
			}).
			Press(keys.Files.ToggleTreeView).
			Lines(
				Contains(`folder1`),
				Contains(`apple-grape`),
				Contains(`apple-orange`).IsSelected(),
				Contains(`grape-orange`),
			).
			FilterOrSearch("folder1/grape").
			Lines(

				Contains(`folder1`).IsSelected(),
				Contains(`grape-orange`),
			)
	},
})
View Source
var FilterFiles = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Basic file filtering by text",
	ExtraCmdArgs: []string{},
	Skip:         true,
	SetupConfig:  func(config *config.AppConfig) {},
	SetupRepo: func(shell *Shell) {
		shell.CreateDir("folder1")
		shell.CreateFile("folder1/apple-grape", "apple-grape")
		shell.CreateFile("folder1/apple-orange", "apple-orange")
		shell.CreateFile("folder1/grape-orange", "grape-orange")
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().Files().
			Focus().
			Lines(
				Contains(`folder1`).IsSelected(),
				Contains(`apple-grape`),
				Contains(`apple-orange`),
				Contains(`grape-orange`),
			).
			Press(keys.Files.ToggleTreeView).
			Lines(
				Contains(`folder1/apple-grape`).IsSelected(),
				Contains(`folder1/apple-orange`),
				Contains(`folder1/grape-orange`),
			).
			FilterOrSearch("apple").
			Lines(
				Contains(`folder1/apple-grape`).IsSelected(),
				Contains(`folder1/apple-orange`),
			).
			Press(keys.Files.ToggleTreeView).
			Lines(
				Contains(`folder1`),
				Contains(`apple-grape`).IsSelected(),
				Contains(`apple-orange`),
			).
			Press(keys.Files.ToggleTreeView).
			Lines(
				Contains(`folder1/apple-grape`).IsSelected(),
				Contains(`folder1/apple-orange`),
			).
			NavigateToLine(Contains(`folder1/apple-orange`)).
			Press(keys.Universal.Return).
			Lines(
				Contains(`folder1/apple-grape`),

				Contains(`folder1/apple-orange`).IsSelected(),
				Contains(`folder1/grape-orange`),
			).
			Tap(func() {
				t.Views().Search().IsInvisible()
			}).
			Press(keys.Files.ToggleTreeView).
			Lines(
				Contains(`folder1`),
				Contains(`apple-grape`),
				Contains(`apple-orange`).IsSelected(),
				Contains(`grape-orange`),
			).
			FilterOrSearch("folder1/grape").
			Lines(

				Contains(`folder1`).IsSelected(),
				Contains(`grape-orange`),
			)
	},
})
View Source
var FilterFuzzy = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Verify that fuzzy filtering works (not just exact matches)",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupConfig: func(config *config.AppConfig) {
		config.UserConfig.Gui.FilterMode = "fuzzy"
	},
	SetupRepo: func(shell *Shell) {
		shell.NewBranch("this-is-my-branch")
		shell.EmptyCommit("first commit")
		shell.NewBranch("other-branch")
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().Branches().
			Focus().
			Lines(
				Contains(`other-branch`).IsSelected(),
				Contains(`this-is-my-branch`),
			).
			FilterOrSearch("timb").
			Lines(
				Contains(`this-is-my-branch`).IsSelected(),
			).
			FilterOrSearch("brnch").
			Lines(
				Contains(`other-branch`).IsSelected(),
				Contains(`this-is-my-branch`),
			)
	},
})
View Source
var FilterMenu = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Filtering the keybindings menu",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupConfig:  func(config *config.AppConfig) {},
	SetupRepo: func(shell *Shell) {
		shell.CreateFile("myfile", "myfile")
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().Files().
			IsFocused().
			Lines(
				Contains(`??`).Contains(`myfile`).IsSelected(),
			).
			Press(keys.Universal.OptionMenu).
			Tap(func() {
				t.ExpectPopup().Menu().
					Title(Equals("Keybindings")).
					Filter("Ignore").
					Lines(

						Contains(`--- Local ---`),
						Contains(`Ignore`).IsSelected(),
					).
					Confirm()

				t.ExpectPopup().Menu().
					Title(Equals("Ignore or exclude file")).
					Select(Contains("Add to .gitignore")).
					Confirm()
			})

		t.Views().Files().
			IsFocused().
			Lines(

				Contains(`.gitignore`).IsSelected(),
			).
			Press(keys.Universal.OptionMenu).
			Tap(func() {
				t.ExpectPopup().Menu().
					Title(Equals("Keybindings")).
					LineCount(GreaterThan(1))
			})
	},
})
View Source
var FilterMenuCancelFilterWithEscape = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Filtering the keybindings menu, then pressing esc to turn off the filter",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupConfig:  func(config *config.AppConfig) {},
	SetupRepo:    func(shell *Shell) {},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().Files().IsFocused().
			Press(keys.Universal.OptionMenu)

		t.ExpectPopup().Menu().
			Title(Equals("Keybindings")).
			Filter("Ignore").
			Lines(

				Contains(`--- Local ---`),
				Contains(`Ignore`).IsSelected(),
			)

		t.GlobalPress(keys.Universal.Return)
		t.ExpectPopup().Menu().
			Title(Equals("Keybindings")).
			LineCount(GreaterThan(1))

		t.GlobalPress(keys.Universal.Return)
		t.Views().Files().IsFocused()
	},
})
View Source
var FilterRemoteBranches = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Filtering remote branches",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupConfig:  func(config *config.AppConfig) {},
	SetupRepo: func(shell *Shell) {
		shell.NewBranch("branch-apple")
		shell.EmptyCommit("commit-one")
		shell.NewBranch("branch-grape")
		shell.NewBranch("branch-orange")

		shell.CloneIntoRemote("origin")
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().Remotes().
			Focus().
			Lines(
				Contains(`origin`).IsSelected(),
			).
			PressEnter()

		t.Views().RemoteBranches().
			IsFocused().
			Lines(
				Contains(`branch-apple`).IsSelected(),
				Contains(`branch-grape`),
				Contains(`branch-orange`),
			).
			FilterOrSearch("grape").
			Lines(
				Contains(`branch-grape`).IsSelected(),
			).
			PressEscape().
			Tap(func() {
				t.Views().Search().IsInvisible()
			}).
			Lines(
				Contains(`branch-apple`),
				Contains(`branch-grape`).IsSelected(),
				Contains(`branch-orange`),
			).
			PressEscape()

		t.Views().Remotes().
			IsFocused().
			Lines(
				Contains(`origin`).IsSelected(),
			)
	},
})
View Source
var FilterRemotes = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Filtering remotes",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupConfig:  func(config *config.AppConfig) {},
	SetupRepo: func(shell *Shell) {
		shell.EmptyCommit("commit-one")
		shell.CloneIntoRemote("remote1")
		shell.CloneIntoRemote("remote2")
		shell.CloneIntoRemote("remote3")
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().Remotes().
			Focus().
			Lines(
				Contains("remote1").IsSelected(),
				Contains("remote2"),
				Contains("remote3"),
			).
			FilterOrSearch("2").
			Lines(
				Contains("remote2").IsSelected(),
			).
			PressEscape().
			Tap(func() {
				t.Views().Search().IsInvisible()
			}).
			Lines(
				Contains("remote1"),
				Contains("remote2").IsSelected(),
				Contains("remote3"),
			)
	},
})
View Source
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().
			FilterOrSearch("1").
			FilterOrSearch("2").
			FilterOrSearch("3").
			Press(keys.Universal.StartSearch).
			Tap(func() {
				t.ExpectSearch().Clear()
			}).
			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()
			}).
			Press(keys.Universal.StartSearch).
			Tap(func() {
				t.Views().Search().
					Press(keys.Universal.PrevItem).
					Content(Contains("3")).
					PressEscape()
			})

		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 Source
var FilterUpdatesWhenModelChanges = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Verify that after deleting a branch the filter is reapplied to show only the remaining branches",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupConfig:  func(config *config.AppConfig) {},
	SetupRepo: func(shell *Shell) {
		shell.EmptyCommit("first commit")
		shell.NewBranch("branch-to-delete")
		shell.NewBranch("other")
		shell.NewBranch("checked-out-branch")
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().Branches().
			Focus().
			Lines(
				Contains("checked-out-branch").IsSelected(),
				Contains("other"),
				Contains("branch-to-delete"),
				Contains("master"),
			).
			FilterOrSearch("branch").
			Lines(
				Contains("checked-out-branch").IsSelected(),
				Contains("branch-to-delete"),
			).
			SelectNextItem().
			Press(keys.Universal.Remove).
			Tap(func() {
				t.ExpectPopup().
					Menu().
					Title(Equals("Delete branch 'branch-to-delete'?")).
					Select(Contains("Delete local branch")).
					Confirm()
			}).
			Lines(
				Contains("checked-out-branch").IsSelected(),
			).
			PressEscape().
			Lines(
				Contains("checked-out-branch").IsSelected(),
				Contains("other"),
				Contains("master"),
			)
	},
})
View Source
var NestedFilter = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Filter in the several nested panels and verify the filters are preserved as you escape back to the surface",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupConfig:  func(config *config.AppConfig) {},
	SetupRepo: func(shell *Shell) {

		shell.NewBranch("branch-gold")
		shell.CreateFileAndAdd("apple", "apple")
		shell.CreateFileAndAdd("orange", "orange")
		shell.CreateFileAndAdd("grape", "grape")
		shell.Commit("commit-knife")

		shell.NewBranch("branch-silver")
		shell.UpdateFileAndAdd("apple", "apple-2")
		shell.UpdateFileAndAdd("orange", "orange-2")
		shell.UpdateFileAndAdd("grape", "grape-2")
		shell.Commit("commit-spoon")

		shell.NewBranch("branch-bronze")
		shell.UpdateFileAndAdd("apple", "apple-3")
		shell.UpdateFileAndAdd("orange", "orange-3")
		shell.UpdateFileAndAdd("grape", "grape-3")
		shell.Commit("commit-fork")
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().Branches().
			Focus().
			Lines(
				Contains(`branch-bronze`).IsSelected(),
				Contains(`branch-silver`),
				Contains(`branch-gold`),
			).
			FilterOrSearch("sil").
			Lines(
				Contains(`branch-silver`).IsSelected(),
			).
			PressEnter()

		t.Views().SubCommits().
			IsFocused().
			Lines(
				Contains(`commit-spoon`).IsSelected(),
				Contains(`commit-knife`),
			).
			FilterOrSearch("knife").
			Lines(

				Contains(`commit-spoon`),
				Contains(`commit-knife`).IsSelected(),
			).
			PressEnter()

		t.Views().CommitFiles().
			IsFocused().
			Lines(
				Contains(`apple`).IsSelected(),
				Contains(`grape`),
				Contains(`orange`),
			).
			FilterOrSearch("grape").
			Lines(
				Contains(`apple`),
				Contains(`grape`).IsSelected(),
				Contains(`orange`),
			).
			PressEnter()

		t.Views().PatchBuilding().
			IsFocused().
			FilterOrSearch("newline").
			SelectedLine(Contains("No newline at end of file")).
			PressEscape().
			Tap(func() {
				t.Views().Search().IsInvisible()
			}).
			PressEscape()

		t.Views().CommitFiles().
			IsFocused().
			Lines(
				Contains(`apple`),
				Contains(`grape`).IsSelected(),
				Contains(`orange`),
			).
			Tap(func() {
				t.Views().Search().IsVisible().Content(Contains("matches for 'grape'"))
			}).
			PressEscape().
			Tap(func() {
				t.Views().Search().IsInvisible()
			}).
			Lines(
				Contains(`apple`),
				Contains(`grape`).IsSelected(),
				Contains(`orange`),
			).
			PressEscape()

		t.Views().SubCommits().
			IsFocused().
			Lines(
				Contains(`commit-spoon`),
				Contains(`commit-knife`).IsSelected(),
			).
			Tap(func() {
				t.Views().Search().IsVisible().Content(Contains("matches for 'knife'"))
			}).
			PressEscape().
			Tap(func() {
				t.Views().Search().IsInvisible()
			}).
			Lines(
				Contains(`commit-spoon`),

				Contains(`commit-knife`).IsSelected(),
			).
			PressEscape()

		t.Views().Branches().
			IsFocused().
			Lines(
				Contains(`branch-silver`).IsSelected(),
			).
			Tap(func() {
				t.Views().Search().IsVisible().Content(Contains("matches for 'sil'"))
			}).
			PressEscape().
			Tap(func() {
				t.Views().Search().IsInvisible()
			}).
			Lines(
				Contains(`branch-bronze`),
				Contains(`branch-silver`).IsSelected(),
				Contains(`branch-gold`),
			)
	},
})
View Source
var NestedFilterTransient = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Filter in a transient panel (sub-commits and diff-files) and ensure filter is cancelled when the panel is moved",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupConfig:  func(config *config.AppConfig) {},
	SetupRepo: func(shell *Shell) {

		shell.NewBranch("mybranch")
		shell.CreateFileAndAdd("file-one", "file-one")
		shell.CreateFileAndAdd("file-two", "file-two")
		shell.Commit("commit-one")
		shell.EmptyCommit("commit-two")
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().Branches().
			Focus().
			Lines(
				Contains(`mybranch`).IsSelected(),
			).
			PressEnter()

		t.Views().SubCommits().
			IsFocused().
			Lines(
				Contains(`commit-two`).IsSelected(),
				Contains(`commit-one`),
			).
			FilterOrSearch("one").
			Lines(
				Contains(`commit-two`),
				Contains(`commit-one`).IsSelected(),
			)

		t.Views().ReflogCommits().
			Focus().
			SelectedLine(Contains("commit: commit-two")).
			PressEnter()

		t.Views().SubCommits().
			IsFocused().
			Lines(
				Contains(`commit-two`).IsSelected(),
				Contains(`commit-one`),
			).
			Tap(func() {
				t.Views().Search().IsInvisible()
			}).
			NavigateToLine(Contains("commit-one")).
			PressEnter()

		t.Views().CommitFiles().
			IsFocused().
			Lines(
				Contains(`file-one`).IsSelected(),
				Contains(`file-two`),
			).
			FilterOrSearch("two").
			Lines(
				Contains(`file-one`),
				Contains(`file-two`).IsSelected(),
			)

		t.Views().Branches().
			Focus().
			SelectedLine(Contains("mybranch")).
			PressEnter()

		t.Views().SubCommits().
			IsFocused().
			Lines(
				Contains(`commit-two`).IsSelected(),
				Contains(`commit-one`),
			).
			NavigateToLine(Contains("commit-one")).
			PressEnter()

		t.Views().CommitFiles().
			IsFocused().
			Lines(
				Contains(`file-one`).IsSelected(),
				Contains(`file-two`),
			).
			Tap(func() {
				t.Views().Search().IsInvisible()
			})
	},
})
View Source
var NewSearch = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Start a new search and verify the search begins from the current cursor position, not from the current search match",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupConfig:  func(config *config.AppConfig) {},
	SetupRepo: func(shell *Shell) {

		shell.EmptyCommit("Add foo")
		shell.EmptyCommit("Remove foo")
		shell.EmptyCommit("Add bar")
		shell.EmptyCommit("Remove bar")
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().Commits().
			Focus().
			Lines(
				Contains(`Remove bar`).IsSelected(),
				Contains(`Add bar`),
				Contains(`Remove foo`),
				Contains(`Add foo`),
			).
			FilterOrSearch("Add").
			SelectedLine(Contains(`Add bar`)).
			SelectPreviousItem().
			SelectedLine(Contains(`Remove bar`)).
			FilterOrSearch("Remove").
			SelectedLine(Contains(`Remove bar`))
	},
})

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL