ui

package
v0.42.0 Latest Latest
Warning

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

Go to latest
Published: May 19, 2024 License: MIT Imports: 4 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 DoublePopup = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Open a popup from within another popup and assert you can escape back to the side panels",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupConfig:  func(config *config.AppConfig) {},
	SetupRepo: func(shell *Shell) {
		shell.EmptyCommit("one")
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().Branches().
			Focus().
			PressPrimaryAction()

		t.ExpectPopup().Alert().
			Title(Contains("Error")).
			Content(Contains("You have already checked out this branch"))

		t.GlobalPress(keys.Universal.OpenRecentRepos)

		t.ExpectPopup().Menu().Title(Contains("Recent repositories")).Cancel()

		t.Views().Branches().IsFocused()

		t.Views().Files().Focus()
	},
})
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 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: <c-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().Confirmation().
					Title(Equals("Merge")).
					Content(Contains("Are you sure you want to merge")).
					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.UserConfig.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("Donate")).
			Content(Equals("Please go to https://github.com/sponsors/jesseduffield")).
			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) {},
	SetupRepo: func(shell *Shell) {

		fileContent := ""
		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.CreateFile("file1", fileContent)
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		assertRangeSelectBehaviour := func(v *ViewDriver) {
			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).
				SelectedLines(
					Contains("line 8"),
				).
				SelectNextItem().
				SelectedLines(
					Contains("line 8"),
					Contains("line 9"),
				).
				PressEscape().
				SelectedLines(
					Contains("line 9"),
				)
		}

		assertRangeSelectBehaviour(t.Views().Commits().Focus())

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

		assertRangeSelectBehaviour(t.Views().Staging().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.OptionMenuAlt1)

		t.ExpectPopup().Menu().Title(Equals("Keybindings")).
			Select(Contains("Next tab")).
			Confirm()

		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