Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var CopyToClipboard = NewIntegrationTest(NewIntegrationTestArgs{ Description: "The copy menu allows to copy name and diff of selected/all files", ExtraCmdArgs: []string{}, Skip: false, SetupConfig: func(config *config.AppConfig) { config.GetUserConfig().OS.CopyToClipboardCmd = "printf '%s' {{text}} > clipboard" }, SetupRepo: func(shell *Shell) { shell.CreateDir("dir") shell.CreateFileAndAdd("dir/file1", "1st line\n") shell.Commit("1") shell.UpdateFileAndAdd("dir/file1", "1st line\n2nd line\n") shell.CreateFileAndAdd("dir/file2", "file2\n") shell.Commit("2") shell.UpdateFileAndAdd("dir/file1", "1st line\n2nd line\n3rd line\n") shell.Commit("3") }, Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Commits(). Focus(). Lines( Contains("3").IsSelected(), Contains("2"), Contains("1"), ). SelectNextItem(). PressEnter() t.Views().CommitFiles(). IsFocused(). Lines( Contains("dir").IsSelected(), Contains("file1"), Contains("file2"), ). NavigateToLine(Contains("file1")). Press(keys.Files.CopyFileInfoToClipboard). Tap(func() { t.ExpectPopup().Menu(). Title(Equals("Copy to clipboard")). Select(Contains("File name")). Confirm(). Tap(func() { t.ExpectToast(Equals("File name copied to clipboard")) expectClipboard(t, Equals("file1")) }) }). Press(keys.Files.CopyFileInfoToClipboard). Tap(func() { t.ExpectPopup().Menu(). Title(Equals("Copy to clipboard")). Select(Contains("Relative path")). Confirm(). Tap(func() { t.ExpectToast(Equals("File path copied to clipboard")) expectClipboard(t, Equals("dir/file1")) }) }). Press(keys.Files.CopyFileInfoToClipboard). Tap(func() { t.ExpectPopup().Menu(). Title(Equals("Copy to clipboard")). Select(Contains("Absolute path")). Confirm(). Tap(func() { t.ExpectToast(Equals("File path copied to clipboard")) repoDir, _ := os.Getwd() expectClipboard(t, Equals(repoDir+"/dir/file1")) }) }). Press(keys.Files.CopyFileInfoToClipboard). Tap(func() { t.ExpectPopup().Menu(). Title(Equals("Copy to clipboard")). Select(Contains("Diff of selected file")). Confirm(). Tap(func() { t.ExpectToast(Equals("File diff copied to clipboard")) expectClipboard(t, Contains("diff --git a/dir/file1 b/dir/file1").Contains("+2nd line").DoesNotContain("+1st line"). DoesNotContain("diff --git a/dir/file2 b/dir/file2").DoesNotContain("+file2")) }) }). Press(keys.Files.CopyFileInfoToClipboard). Tap(func() { t.ExpectPopup().Menu(). Title(Equals("Copy to clipboard")). Select(Contains("Diff of all files")). Confirm(). Tap(func() { t.ExpectToast(Equals("All files diff copied to clipboard")) expectClipboard(t, Contains("diff --git a/dir/file1 b/dir/file1").Contains("+2nd line").DoesNotContain("+1st line"). Contains("diff --git a/dir/file2 b/dir/file2").Contains("+file2")) }) }). Press(keys.Files.CopyFileInfoToClipboard). Tap(func() { t.ExpectPopup().Menu(). Title(Equals("Copy to clipboard")). Select(Contains("Content of selected file")). Confirm(). Tap(func() { t.ExpectToast(Equals("File content copied to clipboard")) expectClipboard(t, Equals("1st line\n2nd line\n")) }) }) t.Views().Commits(). Focus(). Press(keys.Universal.RangeSelectDown). PressEnter() t.Views().CommitFiles(). IsFocused(). Lines( Contains("dir").IsSelected(), Contains("file1"), Contains("file2"), ). NavigateToLine(Contains("file1")). Press(keys.Files.CopyFileInfoToClipboard). Tap(func() { t.ExpectPopup().Menu(). Title(Equals("Copy to clipboard")). Select(Contains("Diff of selected file")). Confirm(). Tap(func() { t.ExpectToast(Equals("File diff copied to clipboard")) expectClipboard(t, Contains("diff --git a/dir/file1 b/dir/file1").Contains("+1st line").Contains("+2nd line")) }) }). Press(keys.Files.CopyFileInfoToClipboard). Tap(func() { t.ExpectPopup().Menu(). Title(Equals("Copy to clipboard")). Select(Contains("Content of selected file")). Confirm(). Tap(func() { t.ExpectToast(Equals("File content copied to clipboard")) expectClipboard(t, Equals("1st line\n2nd line\n")) }) }) }, })
View Source
var Diff = NewIntegrationTest(NewIntegrationTestArgs{ Description: "View the diff of two branches, then view the reverse diff", ExtraCmdArgs: []string{}, Skip: false, SetupConfig: func(config *config.AppConfig) {}, SetupRepo: func(shell *Shell) { shell.NewBranch("branch-a") shell.CreateFileAndAdd("file1", "first line") shell.Commit("first commit") shell.NewBranch("branch-b") shell.UpdateFileAndAdd("file1", "first line\nsecond line") shell.Commit("update") shell.Checkout("branch-a") }, Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Branches(). Focus(). TopLines( Contains("branch-a"), Contains("branch-b"), ). Press(keys.Universal.DiffingMenu) t.ExpectPopup().Menu().Title(Equals("Diffing")).Select(Contains(`Diff branch-a`)).Confirm() t.Views().Branches(). IsFocused(). Tap(func() { t.Views().Information().Content(Contains("Showing output for: git diff --stat -p branch-a branch-a")) }). SelectNextItem(). Tap(func() { t.Views().Information().Content(Contains("Showing output for: git diff --stat -p branch-a branch-b")) t.Views().Main().Content(Contains("+second line")) }). PressEnter() t.Views().SubCommits(). IsFocused(). SelectedLine(Contains("update")). Tap(func() { t.Views().Main().Content(Contains("+second line")) }). PressEnter() t.Views().CommitFiles(). IsFocused(). SelectedLine(Contains("file1")). Tap(func() { t.Views().Main().Content(Contains("+second line")) }). PressEscape() t.Views().SubCommits().PressEscape() t.Views().Branches(). IsFocused(). Press(keys.Universal.DiffingMenu) t.ExpectPopup().Menu().Title(Equals("Diffing")).Select(Contains("Reverse diff direction")).Confirm() t.Views().Information().Content(Contains("Showing output for: git diff --stat -p branch-a branch-b -R")) t.Views().Main().Content(Contains("-second line")) }, })
View Source
var DiffAndApplyPatch = NewIntegrationTest(NewIntegrationTestArgs{ Description: "Create a patch from the diff between two branches and apply the patch.", ExtraCmdArgs: []string{}, Skip: false, SetupConfig: func(config *config.AppConfig) {}, SetupRepo: func(shell *Shell) { shell.NewBranch("branch-a") shell.CreateFileAndAdd("file1", "first line\n") shell.Commit("first commit") shell.NewBranch("branch-b") shell.UpdateFileAndAdd("file1", "first line\nsecond line\n") shell.Commit("update") shell.Checkout("branch-a") }, Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Branches(). Focus(). Lines( Contains("branch-a"), Contains("branch-b"), ). Press(keys.Universal.DiffingMenu) t.ExpectPopup().Menu().Title(Equals("Diffing")).Select(Equals("Diff branch-a")).Confirm() t.Views().Information().Content(Contains("Showing output for: git diff --stat -p branch-a branch-a")) t.Views().Branches(). IsFocused(). SelectNextItem(). Tap(func() { t.Views().Information().Content(Contains("Showing output for: git diff --stat -p branch-a branch-b")) t.Views().Main().Content(Contains("+second line")) }). PressEnter() t.Views().SubCommits(). IsFocused(). SelectedLine(Contains("update")). Tap(func() { t.Views().Main().Content(Contains("+second line")) }). PressEnter() t.Views().CommitFiles(). IsFocused(). SelectedLine(Contains("file1")). Tap(func() { t.Views().Main().Content(Contains("+second line")) }). PressPrimaryAction(). Press(keys.Universal.DiffingMenu). Tap(func() { t.ExpectPopup().Menu().Title(Equals("Diffing")).Select(Contains("Exit diff mode")).Confirm() t.Views().Information().Content(Contains("Building patch")) }). Press(keys.Universal.CreatePatchOptionsMenu) t.ExpectPopup().Menu().Title(Equals("Patch options")).Select(MatchesRegexp("Apply patch$")).Confirm() t.Views().Files(). Focus(). SelectedLine(Contains("file1")) t.Views().Main().Content(Contains("+second line")) }, })
View Source
var DiffCommits = NewIntegrationTest(NewIntegrationTestArgs{ Description: "View the diff between two commits", ExtraCmdArgs: []string{}, Skip: false, SetupConfig: func(config *config.AppConfig) {}, SetupRepo: func(shell *Shell) { shell.CreateFileAndAdd("file1", "first line\n") shell.Commit("first commit") shell.UpdateFileAndAdd("file1", "first line\nsecond line\n") shell.Commit("second commit") shell.UpdateFileAndAdd("file1", "first line\nsecond line\nthird line\n") shell.Commit("third commit") }, Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Commits(). Focus(). Lines( Contains("third commit").IsSelected(), Contains("second commit"), Contains("first commit"), ). Press(keys.Universal.DiffingMenu). Tap(func() { t.ExpectPopup().Menu().Title(Equals("Diffing")).Select(MatchesRegexp(`Diff \w+`)).Confirm() t.Views().Information().Content(Contains("Showing output for: git diff")) }). SelectNextItem(). SelectNextItem(). SelectedLine(Contains("first commit")). Tap(func() { t.Views().Main().Content(Contains("-second line\n-third line")) }). Press(keys.Universal.DiffingMenu). Tap(func() { t.ExpectPopup().Menu().Title(Equals("Diffing")).Select(Contains("Reverse diff direction")).Confirm() t.Views().Main().Content(Contains("+second line\n+third line")) }). PressEnter() t.Views().CommitFiles(). IsFocused(). SelectedLine(Contains("file1")) t.Views().Main().Content(Contains("+second line\n+third line")) }, })
View Source
var DiffNonStickyRange = NewIntegrationTest(NewIntegrationTestArgs{ Description: "View the combined diff of multiple commits using a range selection", ExtraCmdArgs: []string{}, Skip: false, SetupConfig: func(config *config.AppConfig) {}, SetupRepo: func(shell *Shell) { shell.EmptyCommit("initial commit") shell.CreateFileAndAdd("file1", "first line\n") shell.Commit("first commit") shell.UpdateFileAndAdd("file1", "first line\nsecond line\n") shell.Commit("second commit") shell.UpdateFileAndAdd("file1", "first line\nsecond line\nthird line\n") shell.Commit("third commit") }, Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Commits(). Focus(). Lines( Contains("third commit").IsSelected(), Contains("second commit"), Contains("first commit"), Contains("initial commit"), ). Press(keys.Universal.RangeSelectDown). Press(keys.Universal.RangeSelectDown). Tap(func() { t.Views().Main().Content(Contains("Showing diff for range "). Contains("+first line\n+second line\n+third line")) }). PressEnter() t.Views().CommitFiles(). IsFocused(). SelectedLine(Contains("file1")) t.Views().Main().Content(Contains("+first line\n+second line\n+third line")) }, })
View Source
var IgnoreWhitespace = NewIntegrationTest(NewIntegrationTestArgs{ Description: "Toggle whitespace in the diff", ExtraCmdArgs: []string{}, Skip: false, SetupConfig: func(config *config.AppConfig) {}, SetupRepo: func(shell *Shell) { shell.CreateFileAndAdd("myfile", initialFileContent) shell.Commit("initial commit") shell.UpdateFile("myfile", updatedFileContent) }, Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Main().ContainsLines( Contains(`-first-line`), Contains(`-old-second-line`), Contains(`-third-line`), Contains(`+ first-line`), Contains(`+ new-second-line`), Contains(`+ third-line`), ) t.Views().Files(). IsFocused(). Press(keys.Universal.ToggleWhitespaceInDiffView) t.Views().Main().ContainsLines( Contains(` first-line`), Contains(`-old-second-line`), Contains(`+ new-second-line`), Contains(` third-line`), ) t.Views().Files(). IsFocused(). Press(keys.Universal.ToggleWhitespaceInDiffView) t.Views().Main().ContainsLines( Contains(`-first-line`), Contains(`-old-second-line`), Contains(`-third-line`), Contains(`+ first-line`), Contains(`+ new-second-line`), Contains(`+ third-line`), ) }, })
View Source
var RenameSimilarityThresholdChange = NewIntegrationTest(NewIntegrationTestArgs{ Description: "Change the rename similarity threshold while in the commits panel", ExtraCmdArgs: []string{}, Skip: false, SetupConfig: func(config *config.AppConfig) {}, SetupRepo: func(shell *Shell) { shell.CreateFileAndAdd("original", "one\ntwo\nthree\nfour\nfive\n") shell.Commit("add original") shell.DeleteFileAndAdd("original") shell.CreateFileAndAdd("renamed", "one\ntwo\nthree\nfour\nfive\nsix\nseven\neight\nnine\nten\n") shell.Commit("change name and contents") }, Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Commits().Focus() t.Views().Main(). ContainsLines( Contains("2 files changed, 10 insertions(+), 5 deletions(-)"), ) t.Views().Commits(). Press(keys.Universal.DecreaseRenameSimilarityThreshold). Tap(func() { t.ExpectToast(Equals("Changed rename similarity threshold to 45%")) }) t.Views().Main(). ContainsLines( Contains("original => renamed"), Contains("1 file changed, 5 insertions(+)"), ) t.Views().Commits(). Press(keys.Universal.FocusMainView) t.Views().Main(). Press(keys.Universal.IncreaseRenameSimilarityThreshold). Tap(func() { t.ExpectToast(Equals("Changed rename similarity threshold to 50%")) }). ContainsLines( Contains("2 files changed, 10 insertions(+), 5 deletions(-)"), ) }, })
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.