ui

package
v0.62.1 Latest Latest
Warning

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

Go to latest
Published: May 28, 2026 License: MIT Imports: 5 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Accordion = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Verify accordion mode kicks in when the screen height is too small",
	ExtraCmdArgs: []string{},
	Width:        100,
	Height:       10,
	Skip:         false,
	SetupConfig:  func(config *config.AppConfig) {},
	SetupRepo: func(shell *Shell) {
		shell.CreateNCommits(20)
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().Commits().
			Focus().
			VisibleLines(
				Contains("commit 20").IsSelected(),
				Contains("commit 19"),
				Contains("commit 18"),
			).
			NavigateToLine(Contains("commit 11")).
			NavigateToLine(Contains("commit 10")).
			NavigateToLine(Contains("commit 11")).
			VisibleLines(
				Contains("commit 12"),
				Contains("commit 11").IsSelected(),
				Contains("commit 10"),
			)

		t.Views().Files().
			Focus()

		t.Views().Commits().
			Focus().
			VisibleLines(
				Contains("commit 12"),
				Contains("commit 11").IsSelected(),
				Contains("commit 10"),
			)
	},
})
View Source
var DisableSwitchTabWithPanelJumpKeys = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Verify that the tab does not change by default when jumping to an already focused panel",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupConfig: func(config *config.AppConfig) {
	},
	SetupRepo: func(shell *Shell) {
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().Status().Focus().
			Press(keys.Universal.JumpToBlock[1])
		t.Views().Files().IsFocused().
			Press(keys.Universal.JumpToBlock[1])

		t.Views().Files().IsFocused()
	},
})
View Source
var EmptyMenu = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Verify that we don't crash on an empty menu",
	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.Views().Menu().
			IsFocused().
			FilterOrSearch("ljasldkjaslkdjalskdjalsdjaslkd").
			IsEmpty().
			Press(keys.Universal.Select).
			Tap(func() {
				t.ExpectToast(Equals("Disabled: No item selected"))
			}).
			PressEscape().
			PressEscape()

		t.Views().Files().
			IsFocused()
	},
})
View Source
var KeybindingSuggestionsDontCrashOnDisabledBindings = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Filter out keybinding suggestions whose bindings are disabled",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupConfig: func(config *config.AppConfig) {
		config.GetUserConfig().Keybinding.Files.StashAllChanges = []string{}
	},
	SetupRepo: func(shell *Shell) {},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().Files().Focus()
		t.Views().Options().Content(
			Equals("Commit: c | Reset: D | Keybindings: ?"))
	},
})
View Source
var KeybindingSuggestionsWhenSwitchingRepos = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Show correct keybinding suggestions after switching between repos",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupConfig: func(config *config.AppConfig) {
		otherRepo, _ := filepath.Abs("../other")
		config.GetAppState().RecentRepos = []string{otherRepo}
	},
	SetupRepo: func(shell *Shell) {
		shell.CloneNonBare("other")
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		switchToRepo := func(repo string) {
			t.GlobalPress(keys.Universal.OpenRecentRepos)
			t.ExpectPopup().Menu().Title(Equals("Recent repositories")).
				Lines(
					Contains(repo).IsSelected(),
					Contains("Cancel"),
				).Confirm()
			t.Views().Status().Content(Contains(repo + " → master"))
		}

		t.Views().Files().Focus()
		t.Views().Options().Content(
			Equals("Commit: c | Stash: s | Reset: D | Keybindings: ?"))

		switchToRepo("other")
		switchToRepo("repo")

		t.Views().Options().Content(
			Equals("Commit: c | Stash: s | Reset: D | Keybindings: ?"))
	},
})
View Source
var ModeSpecificKeybindingSuggestions = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "When in various modes, we should corresponding keybinding suggestions onscreen",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupConfig:  func(config *config.AppConfig) {},
	SetupRepo: func(shell *Shell) {
		shell.CreateNCommits(2)
		shell.NewBranch("base-branch")
		shared.MergeConflictsSetup(shell)
		shell.Checkout("base-branch")
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		rebaseSuggestion := "View rebase options: m"
		cherryPickSuggestion := "Paste (cherry-pick): V"
		bisectSuggestion := "View bisect options: b"
		customPatchSuggestion := "View custom patch options: <ctrl+p>"
		mergeSuggestion := "View merge options: m"

		t.Views().Commits().
			Focus().
			Lines(
				Contains("commit 02").IsSelected(),
				Contains("commit 01"),
			).
			Tap(func() {

				t.Views().Options().Content(
					DoesNotContain(rebaseSuggestion).
						DoesNotContain(mergeSuggestion).
						DoesNotContain(cherryPickSuggestion).
						DoesNotContain(bisectSuggestion).
						DoesNotContain(customPatchSuggestion),
				)
			}).
			Press(keys.Universal.Edit).
			Tap(func() {

				t.Views().Options().Content(Contains(rebaseSuggestion))
			}).
			Press(keys.Commits.CherryPickCopy).
			Tap(func() {

				t.Views().Options().Content(Contains(cherryPickSuggestion))

				t.Views().Options().Content(Contains(rebaseSuggestion))
			}).
			PressEscape().
			Tap(func() {
				t.Views().Options().Content(DoesNotContain(cherryPickSuggestion))
			}).
			Tap(func() {
				t.Common().AbortRebase()

				t.Views().Options().Content(DoesNotContain(rebaseSuggestion))
			}).
			Press(keys.Commits.ViewBisectOptions).
			Tap(func() {
				t.ExpectPopup().Menu().
					Title(Equals("Bisect")).
					Select(MatchesRegexp("Mark.* as bad")).
					Confirm()

				t.Views().Options().Content(Contains(bisectSuggestion))

				t.Common().ResetBisect()

				t.Views().Options().Content(DoesNotContain(bisectSuggestion))
			}).
			PressEnter()

		t.Views().CommitFiles().
			IsFocused().
			Press(keys.Universal.Select).
			Tap(func() {
				t.Views().Options().Content(Contains(customPatchSuggestion))

				t.Common().ResetCustomPatch()

				t.Views().Options().Content(DoesNotContain(customPatchSuggestion))
			})

		t.Views().Branches().
			Focus().
			NavigateToLine(Contains("first-change-branch")).
			Press(keys.Universal.Select).
			NavigateToLine(Contains("second-change-branch")).
			Press(keys.Branches.MergeIntoCurrentBranch).
			Tap(func() {
				t.ExpectPopup().Menu().
					Title(Equals("Merge")).
					Select(Contains("Regular merge (with merge commit)")).
					Confirm()

				t.Common().AcknowledgeConflicts()

				t.Views().Options().Content(Contains(mergeSuggestion))

				t.Common().AbortMerge()

				t.Views().Options().Content(DoesNotContain(mergeSuggestion))
			})
	},
})
View Source
var OpenLinkFailure = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "When opening links via the OS fails, show a dialog instead.",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupConfig: func(config *config.AppConfig) {
		config.GetUserConfig().OS.OpenLink = "exit 42"
	},
	SetupRepo: func(shell *Shell) {},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().Information().Click(0, 0)

		t.ExpectPopup().Confirmation().
			Title(Equals("Error")).
			Content(Equals("Failed to open URL https://github.com/sponsors/jesseduffield\n\nError: exit status 42")).
			Confirm()
	},
})
View Source
var RangeSelect = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Verify range select works as expected in list views and in patch explorer views",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupConfig: func(config *config.AppConfig) {
		config.GetUserConfig().Gui.UseHunkModeInStagingView = false
	},
	SetupRepo: func(shell *Shell) {

		fileContent := "staged\n"
		total := 10
		for i := 1; i <= total; i++ {
			remaining := total - i + 1

			shell.EmptyCommit(fmt.Sprintf("line %d", remaining))
			fileContent = fmt.Sprintf("%sline %d\n", fileContent, i)
		}
		shell.CreateFileAndAdd("file1", "staged\n")
		shell.UpdateFile("file1", fileContent)
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		assertRangeSelectBehaviour := func(v *ViewDriver, focusOtherView func(), lineIdxOfFirstItem int) {
			v.
				SelectedLines(
					Contains("line 1"),
				).
				Press(keys.Universal.ToggleRangeSelect).
				SelectedLines(
					Contains("line 1"),
				).
				SelectNextItem().
				SelectedLines(
					Contains("line 1"),
					Contains("line 2"),
				).
				Press(keys.Universal.ToggleRangeSelect).
				SelectedLines(
					Contains("line 2"),
				).
				SelectPreviousItem().
				SelectedLines(
					Contains("line 1"),
				).
				Press(keys.Universal.RangeSelectDown).
				SelectedLines(
					Contains("line 1"),
					Contains("line 2"),
				).
				Press(keys.Universal.RangeSelectDown).
				SelectedLines(
					Contains("line 1"),
					Contains("line 2"),
					Contains("line 3"),
				).
				Press(keys.Universal.RangeSelectUp).
				SelectedLines(
					Contains("line 1"),
					Contains("line 2"),
				).
				SelectNextItem().
				SelectedLines(
					Contains("line 3"),
				).
				Press(keys.Universal.ToggleRangeSelect).
				SelectedLines(
					Contains("line 3"),
				).
				SelectNextItem().
				SelectedLines(
					Contains("line 3"),
					Contains("line 4"),
				).
				Press(keys.Universal.RangeSelectDown).
				SelectedLines(
					Contains("line 3"),
					Contains("line 4"),
					Contains("line 5"),
				).
				SelectNextItem().
				SelectedLines(
					Contains("line 6"),
				).
				Press(keys.Universal.RangeSelectDown).
				SelectedLines(
					Contains("line 6"),
					Contains("line 7"),
				).
				Press(keys.Universal.ToggleRangeSelect).
				SelectedLines(
					Contains("line 7"),
				).
				Press(keys.Universal.RangeSelectDown).
				SelectedLines(
					Contains("line 7"),
					Contains("line 8"),
				).
				PressEscape().
				SelectedLines(
					Contains("line 8"),
				).
				Press(keys.Universal.ToggleRangeSelect).
				Press(keys.Universal.GotoBottom).
				SelectedLines(
					Contains("line 8"),
					Contains("line 9"),
					Contains("line 10"),
				).
				PressEscape().
				SelectedLines(
					Contains("line 10"),
				)

			focusOtherView()
			v.Click(1, lineIdxOfFirstItem).
				SelectedLines(
					Contains("line 1"),
				).
				Press(keys.Universal.RangeSelectDown).
				SelectedLines(
					Contains("line 1"),
					Contains("line 2"),
				)
		}

		assertRangeSelectBehaviour(t.Views().Commits().Focus(), func() { t.Views().Branches().Focus() }, 0)

		t.Views().Files().
			Focus().
			SelectedLine(
				Contains("file1"),
			).
			PressEnter()

		assertRangeSelectBehaviour(t.Views().Staging().IsFocused(), func() { t.Views().Staging().PressTab() }, 6)
	},
})
View Source
var SwitchTabFromMenu = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Switch tab via the options menu",
	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")).
			Select(Contains("Next tab")).
			Confirm()

		t.Views().Worktrees().IsFocused()
	},
})
View Source
var SwitchTabWithPanelJumpKeys = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Switch tab with the panel jump keys after enabling the feature",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupConfig: func(config *config.AppConfig) {
		config.GetUserConfig().Gui.SwitchTabsWithPanelJumpKeys = true
	},
	SetupRepo: func(shell *Shell) {
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().Worktrees().Focus().
			Press(keys.Universal.JumpToBlock[2])

		t.Views().Branches().IsFocused().
			Press(keys.Universal.JumpToBlock[2])

		t.Views().Remotes().IsFocused().
			Press(keys.Universal.JumpToBlock[2])

		t.Views().Tags().IsFocused().
			Press(keys.Universal.JumpToBlock[2])

		t.Views().Branches().IsFocused().
			Press(keys.Universal.JumpToBlock[1])

		t.Views().Worktrees().IsFocused()
	},
})

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