ui

package
v0.64.1 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2026 License: MIT Imports: 5 Imported by: 0

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 BranchesNotFirstTab = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "With gui.sidePanels grouping branches behind another tab, no ghost view must appear over the side panels",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupConfig: func(cfg *config.AppConfig) {
		cfg.GetUserConfig().Gui.SidePanels = []config.SidePanel{
			{"worktrees", "branches", "remotes"},
			{"files"},
			{"commits", "tags"},
			{"stash"},
		}
	},
	SetupRepo: func(shell *Shell) {
		shell.EmptyCommit("one")
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {

		t.Views().RemoteBranches().
			IsInvisible()
		t.Views().SubCommits().IsInvisible()
	},
})
View Source
var CommitsNotFirstTab = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "With gui.sidePanels grouping commits behind another tab, no ghost view must appear over the side panels",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupConfig: func(cfg *config.AppConfig) {
		cfg.GetUserConfig().Gui.SidePanels = []config.SidePanel{
			{"branches", "worktrees", "remotes"},
			{"files"},
			{"tags", "commits"},
			{"stash"},
		}
	},
	SetupRepo: func(shell *Shell) {
		shell.EmptyCommit("one")
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {

		t.Views().CommitFiles().
			IsInvisible()
	},
})
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 HideSidePanel = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Hide a side panel by omitting it from gui.sidePanels",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupConfig: func(cfg *config.AppConfig) {

		cfg.GetUserConfig().Gui.SidePanels = []config.SidePanel{
			{"status"},
			{"files", "worktrees", "submodules"},
			{"branches", "remotes", "tags"},
			{"commits", "reflog"},
		}
	},
	SetupRepo: func(shell *Shell) {
		shell.CreateNCommits(2)
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {

		t.Views().Files().IsFocused().
			Press(keys.Universal.JumpToBlock[3])
		t.Views().Commits().IsFocused().
			Press(keys.Universal.NextBlock)
		t.Views().Status().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 PromoteTabToSidePanel = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Promote the worktrees tab to its own top-level side panel via gui.sidePanels",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupConfig: func(cfg *config.AppConfig) {

		cfg.GetUserConfig().Gui.SidePanels = []config.SidePanel{
			{"status"},
			{"files", "submodules"},
			{"worktrees"},
			{"branches", "remotes", "tags"},
			{"commits", "reflog"},
			{"stash"},
		}
	},
	SetupRepo: func(shell *Shell) {
		shell.CreateNCommits(2)
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {

		t.Views().Files().IsFocused().
			Press(keys.Universal.JumpToBlock[2])
		t.Views().Worktrees().IsFocused().
			Press(keys.Universal.JumpToBlock[1])

		t.Views().Files().IsFocused().
			Press(keys.Universal.NextTab)
		t.Views().Submodules().IsFocused()
	},
})
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
		config.GetUserConfig().Gui.ExpandFocusedSidePanel = true
	},
	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)
		shell.NewBranch("branch1").NewBranch("branch2")
	},
	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)

		t.Views().Branches().Focus()
		t.Views().Branches().
			SelectedLines(
				Contains("branch2"),
			)
		t.Views().Commits().
			ClickAndHold(1, 3).
			MouseMoveToView(t.Views().Branches(), 1, 2).
			SelectedLines(
				Contains("line 1"),
				Contains("line 2"),
				Contains("line 3"),
				Contains("line 4"),
			).
			Tap(func() {
				t.Views().Branches().SelectedLines(
					Contains("branch2"),
				)
			}).
			MouseRelease()

		t.Views().Branches().Focus()
		t.Views().Commits().
			ClickAndHold(1, 0).
			SelectedLines(
				Contains("line 1"),
			).
			RepeatMouseMove().
			SelectedLines(
				Contains("line 1"),
			).
			MouseMove(1, 3).
			SelectedLines(
				Contains("line 1"),
				Contains("line 2"),
				Contains("line 3"),
				Contains("line 4"),
			).
			MouseRelease().
			Click(1, 0)
	},
})
View Source
var RangeSelectWithAutoscroll = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Keep scrolling while creating a range selection at the panel edge",
	ExtraCmdArgs: []string{},
	Skip:         false,
	Width:        120,
	Height:       30,
	SetupConfig: func(config *config.AppConfig) {
		config.GetUserConfig().Gui.UseHunkModeInStagingView = false
	},
	SetupRepo: func(shell *Shell) {
		shell.CreateNCommits(40)
		fileContent := "base\n"
		shell.CreateFileAndAdd("file1", fileContent)
		for i := 1; i <= 40; i++ {
			fileContent += fmt.Sprintf("line %d\n", i)
		}
		shell.UpdateFile("file1", fileContent)
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().Branches().Focus()
		t.Views().Commits().
			ClickAndHold(1, 0).
			MouseMoveToBottom(1).
			OriginYAtLeast(3).
			SelectedLineIdxAtLeast(3).
			MouseRelease()

		t.Views().Files().
			Focus().
			PressEnter()
		t.Views().Staging().
			ClickAndHold(1, 6).
			MouseMoveToBottom(1).
			OriginYAtLeast(3).
			SelectedLineIdxAtLeast(9).
			MouseRelease()
	},
})
View Source
var ReloadSidePanels = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Editing the side panel config and refocusing the window re-applies the layout live, keeping the focused panel focused",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupConfig:  func(cfg *config.AppConfig) {},
	SetupRepo: func(shell *Shell) {
		shell.CreateNCommits(2)

		shell.CreateFile(".git/lazygit.yml", `
gui:
  sidePanels:
    - [status]
    - [files, submodules]
    - [worktrees]
    - [branches, remotes, tags]
    - [commits, reflog]
    - [stash]`)
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {

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

		t.Shell().UpdateFile(".git/lazygit.yml", `
gui:
  sidePanels:
    - [status]
    - [files, worktrees, submodules]
    - [branches, remotes, tags]
    - [commits, reflog]
    - [stash]`)
		t.FocusIn()

		t.Views().Worktrees().IsActiveTab().IsFocused().
			Press(keys.Universal.PrevTab)
		t.Views().Files().IsActiveTab().IsFocused()
	},
})
View Source
var ReorderSidePanels = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Reorder the side panels with gui.sidePanels, swapping the branches and commits panels",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupConfig: func(cfg *config.AppConfig) {
		cfg.GetUserConfig().Gui.SidePanels = []config.SidePanel{
			{"status"},
			{"files", "worktrees", "submodules"},
			{"commits", "reflog"},
			{"branches", "remotes", "tags"},
			{"stash"},
		}
	},
	SetupRepo: func(shell *Shell) {
		shell.CreateNCommits(2)
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {

		t.Views().Files().IsFocused().
			Press(keys.Universal.JumpToBlock[2])
		t.Views().Commits().IsFocused().
			Press(keys.Universal.JumpToBlock[3])
		t.Views().Branches().IsFocused()
	},
})
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