Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var AddCoAuthor = NewIntegrationTest(NewIntegrationTestArgs{ Description: "Add co-author on a commit", ExtraCmdArgs: []string{}, Skip: false, SetupConfig: func(config *config.AppConfig) {}, SetupRepo: func(shell *Shell) { shell.EmptyCommit("initial commit") }, Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Commits(). Focus(). Lines( Contains("initial commit").IsSelected(), ). Press(keys.Commits.ResetCommitAuthor). Tap(func() { t.ExpectPopup().Menu(). Title(Equals("Amend commit attribute")). Select(Contains("Add co-author")). Confirm() t.ExpectPopup().Prompt(). Title(Contains("Add co-author")). Type("John Smith <jsmith@gmail.com>"). Confirm() }) t.Views().Main().ContainsLines( Equals(" initial commit"), Equals(" "), Equals(" Co-authored-by: John Smith <jsmith@gmail.com>"), ) }, })
View Source
var AddCoAuthorRange = NewIntegrationTest(NewIntegrationTestArgs{ Description: "Add co-author on a range of commits", ExtraCmdArgs: []string{}, Skip: false, SetupConfig: func(config *config.AppConfig) {}, SetupRepo: func(shell *Shell) { shell.EmptyCommit("fourth commit") shell.EmptyCommit("third commit") shell.EmptyCommit("second commit") shell.EmptyCommit("first commit") }, Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Commits(). Focus(). Lines( Contains("first commit").IsSelected(), Contains("second commit"), Contains("third commit"), Contains("fourth commit"), ). SelectNextItem(). Press(keys.Universal.ToggleRangeSelect). SelectNextItem(). Lines( Contains("first commit"), Contains("second commit").IsSelected(), Contains("third commit").IsSelected(), Contains("fourth commit"), ). Press(keys.Commits.ResetCommitAuthor). Tap(func() { t.ExpectPopup().Menu(). Title(Equals("Amend commit attribute")). Select(Contains("Add co-author")). Confirm() t.ExpectPopup().Prompt(). Title(Contains("Add co-author")). Type("John Smith <jsmith@gmail.com>"). Confirm() }). PressEscape(). SelectNextItem() t.Views().Main().Content( Contains("fourth commit"). DoesNotContain("Co-authored-by: John Smith <jsmith@gmail.com>"), ) t.Views().Commits(). IsFocused(). SelectPreviousItem(). Lines( Contains("first commit"), Contains("second commit"), Contains("third commit").IsSelected(), Contains("fourth commit"), ) t.Views().Main().ContainsLines( Equals(" third commit"), Equals(" "), Equals(" Co-authored-by: John Smith <jsmith@gmail.com>"), ) t.Views().Commits(). IsFocused(). SelectPreviousItem(). Lines( Contains("first commit"), Contains("second commit").IsSelected(), Contains("third commit"), Contains("fourth commit"), ) t.Views().Main().ContainsLines( Equals(" second commit"), Equals(" "), Equals(" Co-authored-by: John Smith <jsmith@gmail.com>"), ) t.Views().Commits(). IsFocused(). SelectPreviousItem(). Lines( Contains("first commit").IsSelected(), Contains("second commit"), Contains("third commit"), Contains("fourth commit"), ) t.Views().Main().Content( Contains("first commit"). DoesNotContain("Co-authored-by: John Smith <jsmith@gmail.com>"), ) }, })
View Source
var AddCoAuthorWhileCommitting = NewIntegrationTest(NewIntegrationTestArgs{ Description: "Add co-author while typing the commit message", ExtraCmdArgs: []string{}, Skip: false, SetupConfig: func(config *config.AppConfig) { }, SetupRepo: func(shell *Shell) { shell.CreateFile("file", "file content") }, Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Files(). IsFocused(). PressPrimaryAction(). Press(keys.Files.CommitChanges) t.ExpectPopup().CommitMessagePanel(). Type("Subject"). SwitchToDescription(). Type("Here's my message."). AddCoAuthor("John Doe <john@doe.com>"). Content(Equals("Here's my message.\n\nCo-authored-by: John Doe <john@doe.com>")). AddCoAuthor("Jane Smith <jane@smith.com>"). Content(Equals("Here's my message.\n\nCo-authored-by: John Doe <john@doe.com>\nCo-authored-by: Jane Smith <jane@smith.com>")). SwitchToSummary(). Confirm() t.Views().Commits(). Lines( Contains("Subject"), ). Focus(). Tap(func() { t.Views().Main().ContainsLines( Equals(" Subject"), Equals(" "), Equals(" Here's my message."), Equals(" "), Equals(" Co-authored-by: John Doe <john@doe.com>"), Equals(" Co-authored-by: Jane Smith <jane@smith.com>"), ) }) }, })
View Source
var Amend = NewIntegrationTest(NewIntegrationTestArgs{ Description: "Amends the last commit from the files panel", ExtraCmdArgs: []string{}, Skip: false, SetupConfig: func(config *config.AppConfig) {}, SetupRepo: func(shell *Shell) { shell.CreateFileAndAdd("myfile", "myfile content\n") shell.Commit("first commit") shell.UpdateFileAndAdd("myfile", "myfile content\nmore content\n") }, Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Commits(). Lines( Contains("first commit"), ) t.Views().Files(). Focus(). Press(keys.Commits.AmendToCommit) t.ExpectPopup().Confirmation().Title( Equals("Amend last commit")). Content(Contains("Are you sure you want to amend last commit?")). Confirm() t.Views().Commits(). Focus(). Lines( Contains("first commit"), ) t.Views().Main().Content(Contains("+myfile content").Contains("+more content")) }, })
View Source
var AmendWhenThereAreConflictsAndAmend = NewIntegrationTest(NewIntegrationTestArgs{ Description: "Amends the last commit from the files panel while a rebase is stopped due to conflicts, and amends the commit", ExtraCmdArgs: []string{}, Skip: false, SetupConfig: func(config *config.AppConfig) {}, SetupRepo: func(shell *Shell) { setupForAmendTests(shell) }, Run: func(t *TestDriver, keys config.KeybindingConfig) { doTheRebaseForAmendTests(t, keys) t.Views().Files(). Press(keys.Commits.AmendToCommit) t.ExpectPopup().Menu(). Title(Equals("Amend commit")). Select(Equals("Yes, amend previous commit")). Confirm() t.Views().Files().IsEmpty() t.Views().Commits(). Focus(). Lines( Contains("--- Pending rebase todos ---"), Contains("pick").Contains("commit three"), Contains("pick").Contains("<-- CONFLICT --- file1 changed in branch"), Contains("--- Commits ---"), Contains("commit two"), Contains("file1 changed in master"), Contains("base commit"), ) checkCommitContainsChange(t, "commit two", "+branch") }, })
View Source
var AmendWhenThereAreConflictsAndCancel = NewIntegrationTest(NewIntegrationTestArgs{ Description: "Amends the last commit from the files panel while a rebase is stopped due to conflicts, and cancels the confirmation", ExtraCmdArgs: []string{}, Skip: false, SetupConfig: func(config *config.AppConfig) {}, SetupRepo: func(shell *Shell) { setupForAmendTests(shell) }, Run: func(t *TestDriver, keys config.KeybindingConfig) { doTheRebaseForAmendTests(t, keys) t.Views().Files(). Press(keys.Commits.AmendToCommit) t.ExpectPopup().Menu(). Title(Equals("Amend commit")). Select(Equals("Cancel")). Confirm() t.Views().Files(). Lines( Contains("M file1"), ) t.Views().Commits(). Focus(). Lines( Contains("--- Pending rebase todos ---"), Contains("pick").Contains("commit three"), Contains("pick").Contains("<-- CONFLICT --- file1 changed in branch"), Contains("--- Commits ---"), Contains("commit two"), Contains("file1 changed in master"), Contains("base commit"), ) }, })
View Source
var AmendWhenThereAreConflictsAndContinue = NewIntegrationTest(NewIntegrationTestArgs{ Description: "Amends the last commit from the files panel while a rebase is stopped due to conflicts, and continues the rebase", ExtraCmdArgs: []string{}, Skip: false, SetupConfig: func(config *config.AppConfig) {}, SetupRepo: func(shell *Shell) { setupForAmendTests(shell) }, Run: func(t *TestDriver, keys config.KeybindingConfig) { doTheRebaseForAmendTests(t, keys) t.Views().Files(). Press(keys.Commits.AmendToCommit) t.ExpectPopup().Menu(). Title(Equals("Amend commit")). Select(Equals("No, continue rebase")). Confirm() t.Views().Files().IsEmpty() t.Views().Commits(). Focus(). Lines( Contains("commit three"), Contains("file1 changed in branch"), Contains("commit two"), Contains("file1 changed in master"), Contains("base commit"), ) checkCommitContainsChange(t, "file1 changed in branch", "+branch") }, })
View Source
var AutoWrapMessage = NewIntegrationTest(NewIntegrationTestArgs{ Description: "Commit, and test how the commit message body is auto-wrapped", ExtraCmdArgs: []string{}, Skip: false, SetupConfig: func(config *config.AppConfig) { config.GetUserConfig().Git.Commit.AutoWrapWidth = 20 }, SetupRepo: func(shell *Shell) { shell.CreateFile("file", "file content") }, Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Commits(). IsEmpty() t.Views().Files(). IsFocused(). PressPrimaryAction(). Press(keys.Files.CommitChanges) t.ExpectPopup().CommitMessagePanel(). Type("subject"). SwitchToDescription(). Type("Lorem ipsum dolor sit amet, consectetur adipiscing elit."). Content(Equals("Lorem ipsum dolor \nsit amet, \nconsectetur \nadipiscing elit.")). SwitchToSummary(). Confirm() t.Views().Commits(). Lines( Contains("subject"), ). Focus(). Tap(func() { t.Views().Main().Content(Contains( "subject\n \n Lorem ipsum dolor\n sit amet,\n consectetur\n adipiscing elit.")) }). Press(keys.Commits.RenameCommit) t.ExpectPopup().CommitMessagePanel(). InitialText(Equals("subject")). SwitchToDescription(). Content(Equals("Lorem ipsum dolor \nsit amet, \nconsectetur \nadipiscing elit.")). GoToBeginning(). Type("More text. "). Content(Equals("More text. Lorem \nipsum dolor sit \namet, consectetur \nadipiscing elit.")) }, })
View Source
var Checkout = NewIntegrationTest(NewIntegrationTestArgs{ Description: "Checkout a commit as a detached head, or checkout an existing branch at a commit", ExtraCmdArgs: []string{}, Skip: false, SetupConfig: func(config *config.AppConfig) {}, SetupRepo: func(shell *Shell) { shell.EmptyCommit("one") shell.EmptyCommit("two") shell.NewBranch("branch1") shell.NewBranch("branch2") shell.EmptyCommit("three") shell.EmptyCommit("four") }, Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Commits(). Focus(). Lines( Contains("four").IsSelected(), Contains("three"), Contains("two"), Contains("one"), ). PressPrimaryAction() t.ExpectPopup().Menu(). Title(Contains("Checkout branch or commit")). Lines( MatchesRegexp("Checkout commit [a-f0-9]+ as detached head").IsSelected(), Contains("Checkout branch"), Contains("Cancel"), ). Select(Contains("Checkout branch")). Tooltip(Contains("Disabled: No branches found at selected commit.")). Select(MatchesRegexp("Checkout commit [a-f0-9]+ as detached head")). Confirm() t.Views().Branches().Lines( Contains("* (HEAD detached at"), Contains("branch2"), Contains("branch1"), Contains("master"), ) t.Views().Commits(). NavigateToLine(Contains("two")). PressPrimaryAction() t.ExpectPopup().Menu(). Title(Contains("Checkout branch or commit")). Lines( MatchesRegexp("Checkout commit [a-f0-9]+ as detached head").IsSelected(), Contains("Checkout branch 'branch1'"), Contains("Checkout branch 'master'"), Contains("Cancel"), ). Select(Contains("Checkout branch 'master'")). Confirm() t.Views().Branches().Lines( Contains("master"), Contains("branch2"), Contains("branch1"), ) }, })
View Source
var CheckoutFileFromCommit = NewIntegrationTest(NewIntegrationTestArgs{ Description: "Checkout a file from a commit", ExtraCmdArgs: []string{}, Skip: false, SetupConfig: func(config *config.AppConfig) {}, SetupRepo: func(shell *Shell) { shell.CreateFileAndAdd("file.txt", "one\n") shell.Commit("one") shell.CreateFileAndAdd("file.txt", "two\n") shell.Commit("two") shell.CreateFileAndAdd("file.txt", "three\n") shell.Commit("three") shell.CreateFileAndAdd("file.txt", "four\n") shell.Commit("four") }, Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Commits(). Focus(). Lines( Contains("four").IsSelected(), Contains("three"), Contains("two"), Contains("one"), ). NavigateToLine(Contains("three")). Tap(func() { t.Views().Main().ContainsLines( Contains("-two"), Contains("+three"), ) }). PressEnter() t.Views().CommitFiles(). IsFocused(). Lines( Equals("M file.txt"), ). Press(keys.CommitFiles.CheckoutCommitFile) t.Views().Files(). Lines( Equals("M file.txt"), ) t.FileSystem().FileContent("file.txt", Equals("three\n")) }, })
View Source
var CheckoutFileFromRangeSelectionOfCommits = NewIntegrationTest(NewIntegrationTestArgs{ Description: "Checkout a file from a range selection of commits", ExtraCmdArgs: []string{}, Skip: false, SetupConfig: func(config *config.AppConfig) {}, SetupRepo: func(shell *Shell) { shell.CreateFileAndAdd("file.txt", "one\n") shell.Commit("one") shell.CreateFileAndAdd("file.txt", "two\n") shell.Commit("two") shell.CreateFileAndAdd("file.txt", "three\n") shell.Commit("three") shell.CreateFileAndAdd("file.txt", "four\n") shell.Commit("four") }, Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Commits(). Focus(). Lines( Contains("four").IsSelected(), Contains("three"), Contains("two"), Contains("one"), ). NavigateToLine(Contains("three")). Press(keys.Universal.RangeSelectDown). Tap(func() { t.Views().Main().ContainsLines( Contains("-one"), Contains("+three"), ) }). PressEnter() t.Views().CommitFiles(). IsFocused(). Lines( Equals("M file.txt"), ). Press(keys.CommitFiles.CheckoutCommitFile) t.Views().Files(). Lines( Equals("M file.txt"), ) t.FileSystem().FileContent("file.txt", Equals("three\n")) }, })
View Source
var Commit = NewIntegrationTest(NewIntegrationTestArgs{ Description: "Staging a couple files and committing", ExtraCmdArgs: []string{}, Skip: false, SetupConfig: func(config *config.AppConfig) {}, SetupRepo: func(shell *Shell) { shell.CreateFile("myfile", "myfile content") shell.CreateFile("myfile2", "myfile2 content") }, Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Commits(). IsEmpty() t.Views().Files(). IsFocused(). Lines( Equals("▼ /").IsSelected(), Equals(" ?? myfile"), Equals(" ?? myfile2"), ). SelectNextItem(). PressPrimaryAction(). Lines( Equals("▼ /"), Equals(" A myfile").IsSelected(), Equals(" ?? myfile2"), ). SelectNextItem(). PressPrimaryAction(). Lines( Equals("▼ /"), Equals(" A myfile"), Equals(" A myfile2").IsSelected(), ). Press(keys.Files.CommitChanges) commitMessage := "my commit message" t.ExpectPopup().CommitMessagePanel().Type(commitMessage).Confirm() t.Views().Files(). IsEmpty() t.Views().Commits(). Focus(). Lines( Contains(commitMessage).IsSelected(), ). PressEnter() t.Views().CommitFiles(). IsFocused(). Lines( Equals("▼ /"), Equals(" A myfile"), Equals(" A myfile2"), ) }, })
View Source
var CommitMultiline = NewIntegrationTest(NewIntegrationTestArgs{ Description: "Commit with a multi-line commit message", ExtraCmdArgs: []string{}, Skip: false, SetupConfig: func(config *config.AppConfig) {}, SetupRepo: func(shell *Shell) { shell.CreateFile("myfile", "myfile content") }, Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Commits(). IsEmpty() t.Views().Files(). IsFocused(). PressPrimaryAction(). Press(keys.Files.CommitChanges) t.ExpectPopup().CommitMessagePanel(). Type("first line"). SwitchToDescription(). AddNewline(). AddNewline(). Type("fourth line"). SwitchToSummary(). Confirm() t.Views().Commits(). Lines( Contains("first line"), ) t.Views().Commits().Focus() t.Views().Main().Content(MatchesRegexp("first line\n\\s*\n\\s*fourth line")) }, })
View Source
var CommitSkipHooks = NewIntegrationTest(NewIntegrationTestArgs{ Description: "Commit with skip hook using CommitChangesWithoutHook", ExtraCmdArgs: []string{}, Skip: false, SetupConfig: func(config *config.AppConfig) {}, SetupRepo: func(shell *Shell) { shell.CreateFile(".git/hooks/pre-commit", blockingHook) shell.MakeExecutable(".git/hooks/pre-commit") shell.CreateFile("file.txt", "content") }, Run: func(t *TestDriver, keys config.KeybindingConfig) { checkBlockingHook(t, keys) t.Views().Files(). IsFocused(). PressPrimaryAction(). Lines( Equals("A file.txt"), ). Press(keys.Files.CommitChangesWithoutHook) t.ExpectPopup().CommitMessagePanel(). Title(Equals("Commit summary")). Type("foo bar"). Confirm() t.Views().Commits().Focus() t.Views().Main().Content(Contains("foo bar")) }, })
View Source
var CommitSwitchToEditor = NewIntegrationTest(NewIntegrationTestArgs{ Description: "Commit, then switch from built-in commit message panel to editor", ExtraCmdArgs: []string{}, Skip: false, SetupConfig: func(config *config.AppConfig) {}, SetupRepo: func(shell *Shell) { shell.CreateFile("file1", "file1 content") shell.CreateFile("file2", "file2 content") shell.SetConfig("core.editor", "sh -c 'echo third line >>.git/COMMIT_EDITMSG'") }, Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Commits(). IsEmpty() t.Views().Files(). IsFocused(). Lines( Equals("▼ /").IsSelected(), Equals(" ?? file1"), Equals(" ?? file2"), ). SelectNextItem(). PressPrimaryAction(). Press(keys.Files.CommitChanges) t.ExpectPopup().CommitMessagePanel(). Type("first line"). SwitchToDescription(). Type("second line"). SwitchToSummary(). SwitchToEditor() t.Views().Commits(). Lines( Contains("first line"), ) t.Views().Commits().Focus() t.Views().Main().Content(MatchesRegexp(`first line\n\s*\n\s*second line\n\s*\n\s*third line`)) t.Views().Files(). Focus(). Lines( Equals("?? file2"), ). PressPrimaryAction(). Press(keys.Files.CommitChanges) t.ExpectPopup().CommitMessagePanel(). InitialText(Equals("")) }, })
View Source
var CommitSwitchToEditorSkipHooks = NewIntegrationTest(NewIntegrationTestArgs{ Description: "Commit, then switch from built-in commit message panel to editor", ExtraCmdArgs: []string{}, Skip: false, SetupConfig: func(config *config.AppConfig) {}, SetupRepo: func(shell *Shell) { shell.CreateFile(".git/hooks/pre-commit", blockingHook) shell.MakeExecutable(".git/hooks/pre-commit") shell.CreateFile("file1", "file1 content") shell.CreateFile("file2", "file2 content") shell.SetConfig("core.editor", "sh -c 'echo third line >>.git/COMMIT_EDITMSG'") }, Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Commits(). IsEmpty() checkBlockingHook(t, keys) t.Views().Files(). IsFocused(). Lines( Equals("▼ /").IsSelected(), Equals(" ?? file1"), Equals(" ?? file2"), ). SelectNextItem(). PressPrimaryAction(). Press(keys.Files.CommitChangesWithoutHook) t.ExpectPopup().CommitMessagePanel(). Type("first line"). SwitchToDescription(). Type("second line"). SwitchToSummary(). SwitchToEditor() t.Views().Commits(). Lines( Contains("first line"), ) t.Views().Commits().Focus() t.Views().Main().Content(MatchesRegexp(`first line\n\s*\n\s*second line\n\s*\n\s*third line`)) t.Views().Files(). Focus(). PressPrimaryAction(). Press(keys.Files.CommitChanges) t.ExpectPopup().CommitMessagePanel(). InitialText(Equals("")) }, })
View Source
var CommitWipWithPrefix = NewIntegrationTest(NewIntegrationTestArgs{ Description: "Commit with skip hook and config commitPrefix is defined. Prefix is ignored when creating WIP commits.", ExtraCmdArgs: []string{}, Skip: false, SetupConfig: func(cfg *config.AppConfig) { cfg.GetUserConfig().Git.CommitPrefixes = map[string][]config.CommitPrefixConfig{"repo": {{Pattern: "^\\w+\\/(\\w+-\\w+).*", Replace: "[$1]: "}}} }, SetupRepo: func(shell *Shell) { shell.CreateFile(".git/hooks/pre-commit", blockingHook) shell.MakeExecutable(".git/hooks/pre-commit") shell.NewBranch("feature/TEST-002") shell.CreateFile("test-wip-commit-prefix", "This is foo bar") }, Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Commits(). IsEmpty() checkBlockingHook(t, keys) t.Views().Files(). IsFocused(). PressPrimaryAction(). Press(keys.Files.CommitChangesWithoutHook) t.ExpectPopup().CommitMessagePanel(). Title(Equals("Commit summary")). InitialText(Equals("WIP")). Type(" foo"). Cancel() t.Views().Files(). IsFocused(). Press(keys.Files.CommitChangesWithoutHook) t.ExpectPopup().CommitMessagePanel(). Title(Equals("Commit summary")). InitialText(Equals("WIP foo")). Type(" bar"). Cancel() t.Views().Files(). IsFocused(). Press(keys.Files.CommitChangesWithoutHook) t.ExpectPopup().CommitMessagePanel(). Title(Equals("Commit summary")). InitialText(Equals("WIP foo bar")). Type(". Added something else"). Confirm() t.Views().Commits().Focus() t.Views().Main().Content(Contains("WIP foo bar. Added something else")) }, })
View Source
var CommitWithFallthroughPrefix = NewIntegrationTest(NewIntegrationTestArgs{ Description: "Commit with multiple CommitPrefixConfig", ExtraCmdArgs: []string{}, Skip: false, SetupConfig: func(cfg *config.AppConfig) { cfg.GetUserConfig().Git.CommitPrefix = []config.CommitPrefixConfig{ {Pattern: "^doesntmatch-(\\w+).*", Replace: "[BAD $1]: "}, {Pattern: "^\\w+\\/(\\w+-\\w+).*", Replace: "[GOOD $1]: "}, } cfg.GetUserConfig().Git.CommitPrefixes = map[string][]config.CommitPrefixConfig{ "DifferentProject": {{Pattern: "^otherthatdoesn'tmatch-(\\w+).*", Replace: "[BAD $1]: "}}, } }, SetupRepo: func(shell *Shell) { shell.NewBranch("feature/TEST-001") shell.CreateFile("test-commit-prefix", "This is foo bar") }, Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Commits(). IsEmpty() t.Views().Files(). IsFocused(). PressPrimaryAction(). Press(keys.Files.CommitChanges) t.ExpectPopup().CommitMessagePanel(). Title(Equals("Commit summary")). InitialText(Equals("[GOOD TEST-001]: ")). Type("my commit message"). Cancel() t.Views().Files(). IsFocused(). Press(keys.Files.CommitChanges) t.ExpectPopup().CommitMessagePanel(). Title(Equals("Commit summary")). InitialText(Equals("[GOOD TEST-001]: my commit message")). Type(". Added something else"). Confirm() t.Views().Commits().Focus() t.Views().Main().Content(Contains("[GOOD TEST-001]: my commit message. Added something else")) }, })
View Source
var CommitWithGlobalPrefix = NewIntegrationTest(NewIntegrationTestArgs{ Description: "Commit with defined config commitPrefix", ExtraCmdArgs: []string{}, Skip: false, SetupConfig: func(cfg *config.AppConfig) { cfg.GetUserConfig().Git.CommitPrefix = []config.CommitPrefixConfig{{Pattern: "^\\w+\\/(\\w+-\\w+).*", Replace: "[$1]: "}} }, SetupRepo: func(shell *Shell) { shell.NewBranch("feature/TEST-001") shell.CreateFile("test-commit-prefix", "This is foo bar") }, Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Commits(). IsEmpty() t.Views().Files(). IsFocused(). PressPrimaryAction(). Press(keys.Files.CommitChanges) t.ExpectPopup().CommitMessagePanel(). Title(Equals("Commit summary")). InitialText(Equals("[TEST-001]: ")). Type("my commit message"). Cancel() t.Views().Files(). IsFocused(). Press(keys.Files.CommitChanges) t.ExpectPopup().CommitMessagePanel(). Title(Equals("Commit summary")). InitialText(Equals("[TEST-001]: my commit message")). Type(". Added something else"). Confirm() t.Views().Commits().Focus() t.Views().Main().Content(Contains("[TEST-001]: my commit message. Added something else")) }, })
View Source
var CommitWithNonMatchingBranchName = NewIntegrationTest(NewIntegrationTestArgs{ Description: "Commit with defined config commitPrefixes", ExtraCmdArgs: []string{}, Skip: false, SetupConfig: func(cfg *config.AppConfig) { cfg.GetUserConfig().Git.CommitPrefix = []config.CommitPrefixConfig{{ Pattern: "^\\w+\\/(\\w+-\\w+).*", Replace: "[$1]: ", }} }, SetupRepo: func(shell *Shell) { shell.NewBranch("branchnomatch") shell.CreateFile("test-commit-prefix", "This is foo bar") }, Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Commits(). IsEmpty() t.Views().Files(). IsFocused(). PressPrimaryAction(). Press(keys.Files.CommitChanges) t.ExpectPopup().CommitMessagePanel(). Title(Equals("Commit summary")). InitialText(Equals("")) }, })
View Source
var CommitWithPrefix = NewIntegrationTest(NewIntegrationTestArgs{ Description: "Commit with defined config commitPrefixes", ExtraCmdArgs: []string{}, Skip: false, SetupConfig: func(cfg *config.AppConfig) { cfg.GetUserConfig().Git.CommitPrefixes = map[string][]config.CommitPrefixConfig{ "repo": {{ Pattern: `^\w+/(\w+-\w+).*`, Replace: "[$1]: ", }}, } }, SetupRepo: func(shell *Shell) { shell.NewBranch("feature/TEST-001") shell.CreateFile("test-commit-prefix", "This is foo bar") }, Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Commits(). IsEmpty() t.Views().Files(). IsFocused(). PressPrimaryAction(). Press(keys.Files.CommitChanges) t.ExpectPopup().CommitMessagePanel(). Title(Equals("Commit summary")). InitialText(Equals("[TEST-001]: ")). Cancel() t.Views().Files(). IsFocused(). Press(keys.Files.CommitChanges) t.ExpectPopup().CommitMessagePanel(). Title(Equals("Commit summary")). InitialText(Equals("[TEST-001]: ")). Type("my commit message"). Cancel() t.Views().Files(). IsFocused(). Press(keys.Files.CommitChanges) t.ExpectPopup().CommitMessagePanel(). Title(Equals("Commit summary")). InitialText(Equals("[TEST-001]: my commit message")). Type(". Added something else"). Confirm() t.Views().Commits().Focus() t.Views().Main().Content(Contains("[TEST-001]: my commit message. Added something else")) }, })
View Source
var CopyAuthorToClipboard = NewIntegrationTest(NewIntegrationTestArgs{ Description: "Copy a commit author name to the clipboard", ExtraCmdArgs: []string{}, Skip: false, SetupConfig: func(config *config.AppConfig) { config.GetUserConfig().OS.CopyToClipboardCmd = "printf '%s' {{text}} > clipboard" }, SetupRepo: func(shell *Shell) { shell.SetAuthor("John Doe", "john@doe.com") shell.EmptyCommit("commit") }, Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Commits(). Focus(). Lines( Contains("commit").IsSelected(), ). Press(keys.Commits.CopyCommitAttributeToClipboard) t.ExpectPopup().Menu(). Title(Equals("Copy to clipboard")). Select(Contains("Commit author")). Confirm() t.ExpectToast(Equals("Commit author copied to clipboard")) t.FileSystem().FileContent("clipboard", Equals("John Doe <john@doe.com>")) }, })
View Source
var CopyMessageBodyToClipboard = NewIntegrationTest(NewIntegrationTestArgs{ Description: "Copy a commit message body to the clipboard", ExtraCmdArgs: []string{}, Skip: false, SetupConfig: func(config *config.AppConfig) { config.GetUserConfig().OS.CopyToClipboardCmd = "printf '%s' {{text}} > clipboard" }, SetupRepo: func(shell *Shell) { shell.EmptyCommitWithBody("My Subject", "My awesome commit message body") }, Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Commits(). Focus(). Lines( Contains("My Subject").IsSelected(), ). Press(keys.Commits.CopyCommitAttributeToClipboard) t.ExpectPopup().Menu(). Title(Equals("Copy to clipboard")). Select(Contains("Commit message body")). Confirm() t.ExpectToast(Equals("Commit message body copied to clipboard")) t.FileSystem().FileContent("clipboard", Equals("My awesome commit message body")) }, })
View Source
var CopyTagToClipboard = NewIntegrationTest(NewIntegrationTestArgs{ Description: "Copy a commit tag to the clipboard", ExtraCmdArgs: []string{}, Skip: false, SetupConfig: func(config *config.AppConfig) { config.GetUserConfig().OS.CopyToClipboardCmd = "printf '%s' {{text}} > clipboard" }, SetupRepo: func(shell *Shell) { shell.SetAuthor("John Doe", "john@doe.com") shell.EmptyCommit("commit") shell.CreateLightweightTag("tag1", "HEAD") shell.CreateLightweightTag("tag2", "HEAD") }, Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Commits(). Focus(). Lines( Contains("commit").IsSelected(), ). Press(keys.Commits.CopyCommitAttributeToClipboard) t.ExpectPopup().Menu(). Title(Equals("Copy to clipboard")). Select(Contains("Commit tags")). Confirm() t.ExpectToast(Equals("Commit tags copied to clipboard")) t.FileSystem().FileContent("clipboard", Equals("tag2\ntag1")) }, })
View Source
var CreateAmendCommit = NewIntegrationTest(NewIntegrationTestArgs{ Description: "Create an amend commit for an existing commit", ExtraCmdArgs: []string{}, Skip: false, SetupConfig: func(config *config.AppConfig) {}, SetupRepo: func(shell *Shell) { shell. CreateNCommits(3). CreateFileAndAdd("fixup-file", "fixup content") }, Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Commits(). Focus(). Lines( Contains("commit 03"), Contains("commit 02"), Contains("commit 01"), ). NavigateToLine(Contains("commit 02")). Press(keys.Commits.CreateFixupCommit). Tap(func() { t.ExpectPopup().Menu(). Title(Equals("Create fixup commit")). Select(Contains("amend! commit with changes")). Confirm() t.ExpectPopup().CommitMessagePanel(). Content(Equals("commit 02")). Type(" amended").Confirm() }). Lines( Contains("amend! commit 02"), Contains("commit 03"), Contains("commit 02").IsSelected(), Contains("commit 01"), ) if t.Git().Version().IsAtLeast(2, 32, 0) { t.Views().Commits(). Press(keys.Commits.SquashAboveCommits). Tap(func() { t.ExpectPopup().Menu(). Title(Equals("Apply fixup commits")). Select(Contains("Above the selected commit")). Confirm() }). Lines( Contains("commit 03"), Contains("commit 02 amended").IsSelected(), Contains("commit 01"), ) } }, })
View Source
var CreateFixupCommitInBranchStack = NewIntegrationTest(NewIntegrationTestArgs{ Description: "Create a fixup commit in a stack of branches, verify that it is created at the end of the branch it belongs to", ExtraCmdArgs: []string{}, Skip: false, GitVersion: AtLeast("2.38.0"), SetupConfig: func(config *config.AppConfig) {}, SetupRepo: func(shell *Shell) { shell.NewBranch("branch1") shell.EmptyCommit("branch1 commit 1") shell.EmptyCommit("branch1 commit 2") shell.EmptyCommit("branch1 commit 3") shell.NewBranch("branch2") shell.EmptyCommit("branch2 commit 1") shell.EmptyCommit("branch2 commit 2") shell.CreateFileAndAdd("fixup-file", "fixup content") shell.SetConfig("rebase.updateRefs", "true") }, Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Commits(). Focus(). Lines( Contains("CI ◯ branch2 commit 2"), Contains("CI ◯ branch2 commit 1"), Contains("CI ◯ * branch1 commit 3"), Contains("CI ◯ branch1 commit 2"), Contains("CI ◯ branch1 commit 1"), ). NavigateToLine(Contains("branch1 commit 2")). Press(keys.Commits.CreateFixupCommit). Tap(func() { t.ExpectPopup().Menu(). Title(Equals("Create fixup commit")). Select(Contains("fixup! commit")). Confirm() }). Lines( Contains("CI ◯ branch2 commit 2"), Contains("CI ◯ branch2 commit 1"), Contains("CI ◯ * fixup! branch1 commit 2"), Contains("CI ◯ branch1 commit 3"), Contains("CI ◯ branch1 commit 2"), Contains("CI ◯ branch1 commit 1"), ) }, })
View Source
var CreateTag = NewIntegrationTest(NewIntegrationTestArgs{ Description: "Create a new tag on a commit", ExtraCmdArgs: []string{}, Skip: false, SetupConfig: func(config *config.AppConfig) {}, SetupRepo: func(shell *Shell) { shell.EmptyCommit("one") shell.EmptyCommit("two") }, Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Commits(). Focus(). Lines( Contains("two").IsSelected(), Contains("one"), ). Press(keys.Commits.CreateTag) t.ExpectPopup().CommitMessagePanel(). Title(Equals("Tag name")). Type("new-tag"). Confirm() t.Views().Commits(). Lines( MatchesRegexp(`new-tag.*two`).IsSelected(), MatchesRegexp(`one`), ) t.Views().Tags(). Focus(). Lines( MatchesRegexp(`new-tag.*two`).IsSelected(), ) t.Git(). TagNamesAt("HEAD", []string{"new-tag"}) }, })
View Source
var DisableCopyCommitMessageBody = NewIntegrationTest(NewIntegrationTestArgs{ Description: "Disables copy commit message body when there is no body", ExtraCmdArgs: []string{}, Skip: false, SetupConfig: func(config *config.AppConfig) {}, SetupRepo: func(shell *Shell) { shell.EmptyCommit("commit") }, Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Commits(). Focus(). Lines( Contains("commit").IsSelected(), ). Press(keys.Commits.CopyCommitAttributeToClipboard) t.ExpectPopup().Menu(). Title(Equals("Copy to clipboard")). Select(Contains("Commit message body")). Confirm() t.ExpectToast(Equals("Disabled: Commit has no message body")) }, })
View Source
var DiscardOldFileChanges = NewIntegrationTest(NewIntegrationTestArgs{ Description: "Discarding a range of files from an old commit.", ExtraCmdArgs: []string{}, Skip: false, SetupConfig: func(config *config.AppConfig) {}, SetupRepo: func(shell *Shell) { shell.CreateFileAndAdd("dir1/d1_file0", "file0\n") shell.CreateFileAndAdd("dir1/subd1/subfile0", "file1\n") shell.CreateFileAndAdd("dir2/d2_file1", "d2f1 content\n") shell.CreateFileAndAdd("dir2/d2_file2", "d2f4 content\n") shell.Commit("remove one file from this commit") shell.UpdateFileAndAdd("dir2/d2_file1", "d2f1 content\nsecond line\n") shell.DeleteFileAndAdd("dir2/d2_file2") shell.CreateFileAndAdd("dir2/d2_file3", "d2f3 content\n") shell.CreateFileAndAdd("dir2/d2_file4", "d2f2 content\n") shell.Commit("remove four files from this commit") shell.CreateFileAndAdd("dir1/fileToRemove", "file to remove content\n") shell.CreateFileAndAdd("dir1/multiLineFile", "this file has\ncontent on\nthree lines\n") shell.CreateFileAndAdd("dir1/subd1/file2ToRemove", "file2 to remove content\n") shell.Commit("remove changes in multiple dirs from this commit") }, Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Commits(). Focus(). Lines( Contains("remove changes in multiple dirs from this commit").IsSelected(), Contains("remove four files from this commit"), Contains("remove one file from this commit"), ). NavigateToLine(Contains("remove one file from this commit")). PressEnter() t.Views().CommitFiles(). IsFocused(). Lines( Equals("▼ /").IsSelected(), Equals(" ▼ dir1"), Equals(" ▼ subd1"), Equals(" A subfile0"), Equals(" A d1_file0"), Equals(" ▼ dir2"), Equals(" A d2_file1"), Equals(" A d2_file2"), ). NavigateToLine(Contains("d1_file0")). Press(keys.Universal.Remove) t.ExpectPopup().Confirmation(). Title(Equals("Discard file changes")). Content(Equals("Are you sure you want to remove changes to the selected file(s) from this commit?\n\nThis action will start a rebase, reverting these file changes. Be aware that if subsequent commits depend on these changes, you may need to resolve conflicts.\nNote: This will also reset any active custom patches.")). Confirm() t.Views().CommitFiles(). IsFocused(). Lines( Equals("▼ /"), Equals(" ▼ dir1/subd1"), Equals(" A subfile0"), Equals(" ▼ dir2"), Equals(" A d2_file1").IsSelected(), Equals(" A d2_file2"), ). PressEscape() t.Views().Commits(). Focus(). Lines( Contains("remove changes in multiple dirs from this commit"), Contains("remove four files from this commit"), Contains("remove one file from this commit").IsSelected(), ). NavigateToLine(Contains("remove four files from this commit")). PressEnter() t.Views().CommitFiles(). IsFocused(). Lines( Equals("▼ dir2").IsSelected(), Equals(" M d2_file1"), Equals(" D d2_file2"), Equals(" A d2_file3"), Equals(" A d2_file4"), ). NavigateToLine(Contains("d2_file1")). Press(keys.Universal.ToggleRangeSelect). NavigateToLine(Contains("d2_file4")). Press(keys.Universal.Remove) t.ExpectPopup().Confirmation(). Title(Equals("Discard file changes")). Content(Equals("Are you sure you want to remove changes to the selected file(s) from this commit?\n\nThis action will start a rebase, reverting these file changes. Be aware that if subsequent commits depend on these changes, you may need to resolve conflicts.\nNote: This will also reset any active custom patches.")). Confirm() t.Views().CommitFiles(). IsFocused(). Lines( Contains("(none)"), ). PressEscape() t.Views().Commits(). IsFocused(). Lines( Contains("remove changes in multiple dirs from this commit"), Contains("remove four files from this commit").IsSelected(), Contains("remove one file from this commit"), ). NavigateToLine(Contains("remove changes in multiple dirs from this commit")). PressEnter() t.Views().CommitFiles(). IsFocused(). Lines( Equals("▼ dir1").IsSelected(), Equals(" ▼ subd1"), Equals(" A file2ToRemove"), Equals(" A fileToRemove"), Equals(" A multiLineFile"), ). NavigateToLine(Contains("multiLineFile")). PressEnter() t.Views().PatchBuilding(). IsFocused(). SelectedLine( Contains("+this file has"), ). PressPrimaryAction(). PressEscape() t.Views().CommitFiles(). IsFocused(). Lines( Equals("▼ dir1"), Equals(" ▼ subd1"), Equals(" A file2ToRemove"), Equals(" A fileToRemove"), Equals(" ◐ multiLineFile").IsSelected(), ). NavigateToLine(Contains("dir1")). Press(keys.Universal.ToggleRangeSelect). NavigateToLine(Contains("subd1")). Press(keys.Universal.Remove) t.ExpectPopup().Confirmation(). Title(Equals("Discard file changes")). Content(Equals("Are you sure you want to remove changes to the selected file(s) from this commit?\n\nThis action will start a rebase, reverting these file changes. Be aware that if subsequent commits depend on these changes, you may need to resolve conflicts.\nNote: This will also reset any active custom patches.")). Confirm() t.Views().Information().Content(DoesNotContain("Building patch")) t.Views().CommitFiles(). IsFocused(). Lines( Contains("(none)"), ) }, })
View Source
var FailHooksThenCommitNoHooks = NewIntegrationTest(NewIntegrationTestArgs{ Description: "Verify that commit message can be reused in commit without hook after failing commit with hooks", ExtraCmdArgs: []string{}, Skip: false, SetupConfig: func(config *config.AppConfig) { }, SetupRepo: func(shell *Shell) { shell.CreateFile(".git/hooks/pre-commit", blockingHook) shell.MakeExecutable(".git/hooks/pre-commit") shell.CreateFileAndAdd("one", "one") }, Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Files(). IsFocused(). Lines( Contains("one"), ). Press(keys.Files.CommitChanges). Tap(func() { t.ExpectPopup().CommitMessagePanel().Type("my message").Confirm() t.ExpectPopup().Alert().Title(Equals("Error")).Content(Contains("Git command failed")).Confirm() }). Press(keys.Files.CommitChangesWithoutHook). Tap(func() { t.ExpectPopup().CommitMessagePanel(). InitialText(Equals("my message")). Confirm() t.Views().Commits(). Lines( Contains("my message"), ) }) t.Views().Commits().Focus() t.Views().Main().Content(Contains("my message")) }, })
View Source
var FindBaseCommitForFixup = NewIntegrationTest(NewIntegrationTestArgs{ Description: "Finds the base commit to create a fixup for", ExtraCmdArgs: []string{}, Skip: false, SetupConfig: func(config *config.AppConfig) {}, SetupRepo: func(shell *Shell) { shell.NewBranch("mybranch"). EmptyCommit("1st commit"). CreateFileAndAdd("file1", "file1 content\n"). Commit("2nd commit"). CreateFileAndAdd("file2", "file2 content\n"). Commit("3rd commit"). UpdateFile("file1", "file1 changed content"). UpdateFile("file2", "file2 changed content") }, Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Commits(). Lines( Contains("3rd commit"), Contains("2nd commit"), Contains("1st commit"), ) t.Views().Files(). Focus(). Press(keys.Files.FindBaseCommitForFixup) t.ExpectPopup().Alert(). Title(Equals("Error")). Content( Contains("Multiple base commits found"). Contains("2nd commit"). Contains("3rd commit"), ). Confirm() t.Views().Files(). IsFocused(). NavigateToLine(Contains("file1")). PressPrimaryAction(). Press(keys.Files.FindBaseCommitForFixup) t.Views().Commits(). IsFocused(). Lines( Contains("3rd commit"), Contains("2nd commit").IsSelected(), Contains("1st commit"), ). Press(keys.Commits.AmendToCommit) t.ExpectPopup().Confirmation(). Title(Equals("Amend commit")). Content(Contains("Are you sure you want to amend this commit with your staged files?")). Confirm() t.Views().Files(). Focus(). Press(keys.Files.FindBaseCommitForFixup) t.Views().Commits(). IsFocused(). Lines( Contains("3rd commit").IsSelected(), Contains("2nd commit"), Contains("1st commit"), ) }, })
View Source
var FindBaseCommitForFixupDisregardMainBranch = NewIntegrationTest(NewIntegrationTestArgs{ Description: "Finds the base commit to create a fixup for, disregarding changes to a commit that is already on master", ExtraCmdArgs: []string{}, Skip: false, SetupConfig: func(config *config.AppConfig) {}, SetupRepo: func(shell *Shell) { shell. EmptyCommit("1st commit"). CreateFileAndAdd("file1", "file1 content\n"). Commit("2nd commit"). NewBranch("mybranch"). CreateFileAndAdd("file2", "file2 content\n"). Commit("3rd commit"). EmptyCommit("4th commit"). UpdateFile("file1", "file1 changed content"). UpdateFile("file2", "file2 changed content") }, Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Commits(). Lines( Contains("4th commit").IsSelected(), Contains("3rd commit"), Contains("2nd commit"), Contains("1st commit"), ) t.Views().Files(). Focus(). Press(keys.Files.FindBaseCommitForFixup) t.Views().Commits(). IsFocused(). Lines( Contains("4th commit"), Contains("3rd commit").IsSelected(), Contains("2nd commit"), Contains("1st commit"), ) }, })
View Source
var FindBaseCommitForFixupOnlyAddedLines = NewIntegrationTest(NewIntegrationTestArgs{ Description: "Finds the base commit to create a fixup for, when all staged hunks have only added lines", ExtraCmdArgs: []string{}, Skip: false, SetupConfig: func(config *config.AppConfig) {}, SetupRepo: func(shell *Shell) { shell.NewBranch("mybranch"). EmptyCommit("1st commit"). CreateFileAndAdd("file1", "line A\nline B\nline C\n"). Commit("2nd commit"). UpdateFileAndAdd("file1", "line A\nline B changed\nline C\n"). Commit("3rd commit"). CreateFileAndAdd("file2", "line X\nline Y\nline Z\n"). Commit("4th commit"). UpdateFile("file1", "line A\nline B changed\nline B'\nline C\n"). UpdateFile("file2", "line W\nline X\nline Y\nline Z\n") }, Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Commits(). Lines( Contains("4th commit"), Contains("3rd commit"), Contains("2nd commit"), Contains("1st commit"), ) t.Views().Files(). Focus(). Press(keys.Files.FindBaseCommitForFixup) t.ExpectPopup().Alert(). Title(Equals("Error")). Content( Contains("Multiple base commits found"). Contains("3rd commit"). Contains("4th commit"), ). Confirm() t.Views().Files(). IsFocused(). NavigateToLine(Contains("file1")). PressPrimaryAction(). Press(keys.Files.FindBaseCommitForFixup) t.Views().Commits(). IsFocused(). Lines( Contains("4th commit"), Contains("3rd commit").IsSelected(), Contains("2nd commit"), Contains("1st commit"), ). Press(keys.Commits.AmendToCommit) t.ExpectPopup().Confirmation(). Title(Equals("Amend commit")). Content(Contains("Are you sure you want to amend this commit with your staged files?")). Confirm() t.Views().Files(). Focus(). Press(keys.Files.FindBaseCommitForFixup) t.Views().Commits(). IsFocused(). Lines( Contains("4th commit").IsSelected(), Contains("3rd commit"), Contains("2nd commit"), Contains("1st commit"), ) }, })
View Source
var FindBaseCommitForFixupWarningForAddedLines = NewIntegrationTest(NewIntegrationTestArgs{ Description: "Finds the base commit to create a fixup for, and warns that there are hunks with only added lines", ExtraCmdArgs: []string{}, Skip: false, SetupConfig: func(config *config.AppConfig) {}, SetupRepo: func(shell *Shell) { shell.NewBranch("mybranch"). EmptyCommit("1st commit"). CreateFileAndAdd("file1", "file1 content\n"). Commit("2nd commit"). CreateFileAndAdd("file2", "file2 content\n"). Commit("3rd commit"). UpdateFile("file1", "file1 changed content"). UpdateFile("file2", "file2 content\nadded content") }, Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Commits(). Lines( Contains("3rd commit").IsSelected(), Contains("2nd commit"), Contains("1st commit"), ) t.Views().Files(). Focus(). Press(keys.Files.FindBaseCommitForFixup) t.ExpectPopup().Confirmation(). Title(Equals("Find base commit for fixup")). Content(Contains("There are ranges of only added lines in the diff; be careful to check that these belong in the found base commit.")). Confirm() t.Views().Commits(). IsFocused(). Lines( Contains("3rd commit"), Contains("2nd commit").IsSelected(), Contains("1st commit"), ) }, })
View Source
var Highlight = NewIntegrationTest(NewIntegrationTestArgs{ Description: "Verify that the commit view highlights the correct lines", ExtraCmdArgs: []string{}, Skip: false, SetupConfig: func(config *config.AppConfig) { config.GetAppState().GitLogShowGraph = "always" config.GetUserConfig().Gui.AuthorColors = map[string]string{ "CI": "red", } }, SetupRepo: func(shell *Shell) { shell.EmptyCommit("one") shell.EmptyCommit("two") shell.EmptyCommit("three") }, Run: func(t *TestDriver, keys config.KeybindingConfig) { highlightedColor := "#ffffff" t.Views().Commits(). DoesNotContainColoredText(highlightedColor, "◯"). Focus(). ContainsColoredText(highlightedColor, "◯") t.Views().Files(). Focus() t.Views().Commits(). DoesNotContainColoredText(highlightedColor, "◯") }, })
View Source
var History = NewIntegrationTest(NewIntegrationTestArgs{ Description: "Cycling through commit message history in the commit message panel", ExtraCmdArgs: []string{}, Skip: false, SetupConfig: func(config *config.AppConfig) {}, SetupRepo: func(shell *Shell) { shell.EmptyCommit("initial commit") shell.EmptyCommit("commit 2") shell.EmptyCommit("commit 3") shell.CreateFile("myfile", "myfile content") }, Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Files(). IsFocused(). PressPrimaryAction(). Press(keys.Files.CommitChanges) t.ExpectPopup().CommitMessagePanel(). InitialText(Equals("")). Type("my commit message"). SelectPreviousMessage(). Content(Equals("commit 3")). SelectPreviousMessage(). Content(Equals("commit 2")). SelectPreviousMessage(). Content(Equals("initial commit")). SelectPreviousMessage(). Content(Equals("initial commit")). SelectNextMessage(). Content(Equals("commit 2")). SelectNextMessage(). Content(Equals("commit 3")). SelectNextMessage(). Content(Equals("my commit message")). SelectNextMessage(). Content(Equals("my commit message")). Type(" with extra added"). Confirm() t.Views().Commits(). TopLines( Contains("my commit message with extra added").IsSelected(), ) }, })
View Source
var HistoryComplex = NewIntegrationTest(NewIntegrationTestArgs{ Description: "More complex flow for cycling commit message history", ExtraCmdArgs: []string{}, Skip: false, SetupConfig: func(config *config.AppConfig) {}, SetupRepo: func(shell *Shell) { shell.EmptyCommit("initial commit") shell.EmptyCommit("commit 2") shell.EmptyCommit("commit 3") shell.CreateFileAndAdd("myfile", "myfile content") }, Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Files(). IsFocused(). Press(keys.Files.CommitChanges) t.ExpectPopup().CommitMessagePanel(). InitialText(Equals("")). Type("my commit message"). Cancel() t.Views().Commits(). Focus(). SelectedLine(Contains("commit 3")). Press(keys.Commits.RenameCommit) t.ExpectPopup().CommitMessagePanel(). InitialText(Equals("commit 3")). SelectNextMessage(). Content(Equals("")). Type("reworded message"). SelectPreviousMessage(). Content(Equals("commit 3")). SelectNextMessage(). Content(Equals("reworded message")). Cancel() t.Views().Files(). Focus(). Press(keys.Files.CommitChanges) t.ExpectPopup().CommitMessagePanel(). InitialText(Equals("my commit message")) }, })
View Source
var NewBranch = NewIntegrationTest(NewIntegrationTestArgs{ Description: "Creating a new branch from a commit", ExtraCmdArgs: []string{}, Skip: false, SetupConfig: func(config *config.AppConfig) {}, SetupRepo: func(shell *Shell) { shell. EmptyCommit("commit 1"). EmptyCommit("commit 2"). EmptyCommit("commit 3") }, Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Commits(). Focus(). Lines( Contains("commit 3").IsSelected(), Contains("commit 2"), Contains("commit 1"), ). SelectNextItem(). Press(keys.Universal.New). Tap(func() { branchName := "my-branch-name" t.ExpectPopup().Prompt().Title(Contains("New branch name")).Type(branchName).Confirm() t.Git().CurrentBranchName(branchName) }). Lines( Contains("commit 2"), Contains("commit 1"), ) }, })
View Source
var PasteCommitMessage = NewIntegrationTest(NewIntegrationTestArgs{ Description: "Paste a commit message into the commit message panel", ExtraCmdArgs: []string{}, Skip: false, SetupConfig: func(config *config.AppConfig) { config.GetUserConfig().OS.CopyToClipboardCmd = "printf '%s' {{text}} > ../clipboard" config.GetUserConfig().OS.ReadFromClipboardCmd = "cat ../clipboard" }, SetupRepo: func(shell *Shell) { shell.EmptyCommit("subject\n\nbody 1st line\nbody 2nd line") shell.CreateFileAndAdd("file", "file content") }, Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Commits(). Focus(). ContainsLines( Contains("subject").IsSelected(), ). Press(keys.Commits.CopyCommitAttributeToClipboard) t.ExpectPopup().Menu().Title(Equals("Copy to clipboard")). Select(Contains("Commit message (subject and body)")).Confirm() t.ExpectToast(Equals("Commit message copied to clipboard")) t.Views().Files(). Focus(). Press(keys.Files.CommitChanges) t.ExpectPopup().CommitMessagePanel(). OpenCommitMenu() t.ExpectPopup().Menu().Title(Equals("Commit Menu")). Select(Contains("Paste commit message from clipboard")). Confirm() t.ExpectPopup().CommitMessagePanel(). Content(Equals("subject")). SwitchToDescription(). Content(Equals("body 1st line\nbody 2nd line")) }, })
View Source
var PasteCommitMessageOverExisting = NewIntegrationTest(NewIntegrationTestArgs{ Description: "Paste a commit message into the commit message panel when there is already text in the panel, causing a confirmation", ExtraCmdArgs: []string{}, Skip: false, SetupConfig: func(config *config.AppConfig) { config.GetUserConfig().OS.CopyToClipboardCmd = "printf '%s' {{text}} > ../clipboard" config.GetUserConfig().OS.ReadFromClipboardCmd = "cat ../clipboard" }, SetupRepo: func(shell *Shell) { shell.EmptyCommit("subject\n\nbody 1st line\nbody 2nd line") shell.CreateFileAndAdd("file", "file content") }, Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Commits(). Focus(). ContainsLines( Contains("subject").IsSelected(), ). Press(keys.Commits.CopyCommitAttributeToClipboard) t.ExpectPopup().Menu().Title(Equals("Copy to clipboard")). Select(Contains("Commit message (subject and body)")).Confirm() t.ExpectToast(Equals("Commit message copied to clipboard")) t.Views().Files(). Focus(). Press(keys.Files.CommitChanges) t.ExpectPopup().CommitMessagePanel(). Type("existing message"). OpenCommitMenu() t.ExpectPopup().Menu().Title(Equals("Commit Menu")). Select(Contains("Paste commit message from clipboard")). Confirm() t.ExpectPopup().Alert().Title(Equals("Paste commit message from clipboard")). Content(Equals("Pasting will overwrite the current commit message, continue?")). Confirm() t.ExpectPopup().CommitMessagePanel(). Content(Equals("subject")). SwitchToDescription(). Content(Equals("body 1st line\nbody 2nd line")) }, })
View Source
var PreserveCommitMessage = NewIntegrationTest(NewIntegrationTestArgs{ Description: "Test that the commit message is preserved correctly when canceling the commit message panel", ExtraCmdArgs: []string{}, Skip: false, SetupConfig: func(config *config.AppConfig) {}, SetupRepo: func(shell *Shell) { shell.CreateFileAndAdd("myfile", "myfile content") }, Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Files(). IsFocused(). Press(keys.Files.CommitChanges) t.ExpectPopup().CommitMessagePanel(). InitialText(Equals("")). Type("my commit message"). SwitchToDescription(). Type("first paragraph"). AddNewline(). AddNewline(). Type("second paragraph"). Cancel() t.FileSystem().PathPresent(".git/LAZYGIT_PENDING_COMMIT") t.Views().Files(). IsFocused(). Press(keys.Files.CommitChanges) t.ExpectPopup().CommitMessagePanel(). Content(Equals("my commit message")). SwitchToDescription(). Content(Equals("first paragraph\n\nsecond paragraph")). Clear(). SwitchToSummary(). Clear(). Cancel() t.FileSystem().PathNotPresent(".git/LAZYGIT_PENDING_COMMIT") t.Views().Files(). IsFocused(). Press(keys.Files.CommitChanges) t.ExpectPopup().CommitMessagePanel(). Type("my new commit message"). Confirm() t.FileSystem().PathNotPresent(".git/LAZYGIT_PENDING_COMMIT") }, })
View Source
var ResetAuthor = NewIntegrationTest(NewIntegrationTestArgs{ Description: "Reset author on a commit", ExtraCmdArgs: []string{}, Skip: false, SetupConfig: func(config *config.AppConfig) {}, SetupRepo: func(shell *Shell) { shell.SetConfig("user.email", "Bill@example.com") shell.SetConfig("user.name", "Bill Smith") shell.EmptyCommit("one") shell.SetConfig("user.email", "John@example.com") shell.SetConfig("user.name", "John Smith") }, Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Commits(). Focus(). Lines( Contains("BS").Contains("one").IsSelected(), ). Press(keys.Commits.ResetCommitAuthor). Tap(func() { t.ExpectPopup().Menu(). Title(Equals("Amend commit attribute")). Select(Contains("Reset author")). Confirm() }). Lines( Contains("JS").Contains("one").IsSelected(), ) }, })
View Source
var ResetAuthorRange = NewIntegrationTest(NewIntegrationTestArgs{ Description: "Reset author on a range of commits", ExtraCmdArgs: []string{}, Skip: false, SetupConfig: func(config *config.AppConfig) {}, SetupRepo: func(shell *Shell) { shell.SetConfig("user.email", "Bill@example.com") shell.SetConfig("user.name", "Bill Smith") shell.EmptyCommit("fourth") shell.EmptyCommit("third") shell.EmptyCommit("second") shell.EmptyCommit("first") shell.SetConfig("user.email", "John@example.com") shell.SetConfig("user.name", "John Smith") }, Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Commits(). Focus(). Lines( Contains("BS").Contains("first").IsSelected(), Contains("BS").Contains("second"), Contains("BS").Contains("third"), Contains("BS").Contains("fourth"), ). SelectNextItem(). Press(keys.Universal.ToggleRangeSelect). SelectNextItem(). Press(keys.Commits.ResetCommitAuthor). Tap(func() { t.ExpectPopup().Menu(). Title(Equals("Amend commit attribute")). Select(Contains("Reset author")). Confirm() }). PressEscape(). Lines( Contains("BS").Contains("first"), Contains("JS").Contains("second"), Contains("JS").Contains("third").IsSelected(), Contains("BS").Contains("fourth"), ) }, })
View Source
var Revert = NewIntegrationTest(NewIntegrationTestArgs{ Description: "Reverts a commit", ExtraCmdArgs: []string{}, Skip: false, SetupConfig: func(config *config.AppConfig) {}, SetupRepo: func(shell *Shell) { shell.CreateFile("myfile", "myfile content") shell.GitAddAll() shell.Commit("first commit") }, Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Commits(). Focus(). Lines( Contains("first commit"), ). Press(keys.Commits.RevertCommit). Tap(func() { t.ExpectPopup().Confirmation(). Title(Equals("Revert commit")). Content(MatchesRegexp(`Are you sure you want to revert \w+?`)). Confirm() }). Lines( Contains("Revert \"first commit\"").IsSelected(), Contains("first commit"), ) t.Views().Main().Content(Contains("-myfile content")) t.FileSystem().PathNotPresent("myfile") }, })
View Source
var RevertMerge = NewIntegrationTest(NewIntegrationTestArgs{ Description: "Reverts a merge commit and chooses to revert to the parent commit", ExtraCmdArgs: []string{}, Skip: false, SetupConfig: func(config *config.AppConfig) {}, SetupRepo: func(shell *Shell) { shared.CreateMergeCommit(shell) }, Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Commits().Focus(). TopLines( Contains("Merge branch 'second-change-branch' into first-change-branch").IsSelected(), ). Press(keys.Commits.RevertCommit) t.ExpectPopup().Confirmation(). Title(Equals("Revert commit")). Content(MatchesRegexp(`Are you sure you want to revert \w+?`)). Confirm() t.Views().Commits().IsFocused(). TopLines( Contains("Revert \"Merge branch 'second-change-branch' into first-change-branch\""), Contains("Merge branch 'second-change-branch' into first-change-branch").IsSelected(), ). SelectPreviousItem() t.Views().Main().Content(Contains("-Second Change").Contains("+First Change")) }, })
View Source
var RevertWithConflictMultipleCommits = NewIntegrationTest(NewIntegrationTestArgs{ Description: "Reverts a range of commits, the first of which conflicts", ExtraCmdArgs: []string{}, Skip: false, SetupConfig: func(cfg *config.AppConfig) {}, SetupRepo: func(shell *Shell) { shell.CreateFileAndAdd("myfile", "") shell.Commit("add empty file") shell.CreateFileAndAdd("otherfile", "") shell.Commit("unrelated change") shell.CreateFileAndAdd("myfile", "first line\n") shell.Commit("add first line") shell.UpdateFileAndAdd("myfile", "first line\nsecond line\n") shell.Commit("add second line") }, Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Commits(). Focus(). Lines( Contains("CI ◯ add second line").IsSelected(), Contains("CI ◯ add first line"), Contains("CI ◯ unrelated change"), Contains("CI ◯ add empty file"), ). SelectNextItem(). Press(keys.Universal.RangeSelectDown). Press(keys.Commits.RevertCommit). Tap(func() { t.ExpectPopup().Confirmation(). Title(Equals("Revert commit")). Content(Equals("Are you sure you want to revert the selected commits?")). Confirm() t.ExpectPopup().Menu(). Title(Equals("Conflicts!")). Select(Contains("View conflicts")). Confirm() }). Lines( Contains("--- Pending reverts ---"), Contains("revert").Contains("CI unrelated change"), Contains("revert").Contains("CI <-- CONFLICT --- add first line"), Contains("--- Commits ---"), Contains("CI ◯ add second line"), Contains("CI ◯ add first line"), Contains("CI ◯ unrelated change"), Contains("CI ◯ add empty file"), ) t.Views().Options().Content(Contains("View revert options: m")) t.Views().Information().Content(Contains("Reverting (Reset)")) t.Views().Files().IsFocused(). Lines( Contains("UU myfile").IsSelected(), ). PressEnter() t.Views().MergeConflicts().IsFocused(). SelectNextItem(). PressPrimaryAction() t.ExpectPopup().Alert(). Title(Equals("Continue")). Content(Contains("All merge conflicts resolved. Continue the revert?")). Confirm() t.Views().Commits(). Lines( Contains(`CI ◯ Revert "unrelated change"`), Contains(`CI ◯ Revert "add first line"`), Contains("CI ◯ add second line"), Contains("CI ◯ add first line"), Contains("CI ◯ unrelated change"), Contains("CI ◯ add empty file"), ) }, })
View Source
var RevertWithConflictSingleCommit = NewIntegrationTest(NewIntegrationTestArgs{ Description: "Reverts a commit that conflicts", ExtraCmdArgs: []string{}, Skip: false, SetupConfig: func(config *config.AppConfig) {}, SetupRepo: func(shell *Shell) { shell.CreateFileAndAdd("myfile", "") shell.Commit("add empty file") shell.CreateFileAndAdd("myfile", "first line\n") shell.Commit("add first line") shell.UpdateFileAndAdd("myfile", "first line\nsecond line\n") shell.Commit("add second line") }, Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Commits(). Focus(). Lines( Contains("CI ◯ add second line").IsSelected(), Contains("CI ◯ add first line"), Contains("CI ◯ add empty file"), ). SelectNextItem(). Press(keys.Commits.RevertCommit). Tap(func() { t.ExpectPopup().Confirmation(). Title(Equals("Revert commit")). Content(MatchesRegexp(`Are you sure you want to revert \w+?`)). Confirm() t.ExpectPopup().Menu(). Title(Equals("Conflicts!")). Select(Contains("View conflicts")). Confirm() }). Lines( Contains("--- Pending reverts ---"), Contains("revert").Contains("CI <-- CONFLICT --- add first line"), Contains("--- Commits ---"), Contains("CI ◯ add second line"), Contains("CI ◯ add first line"), Contains("CI ◯ add empty file"), ) t.Views().Options().Content(Contains("View revert options: m")) t.Views().Information().Content(Contains("Reverting (Reset)")) t.Views().Files().IsFocused(). Lines( Contains("UU myfile").IsSelected(), ). PressEnter() t.Views().MergeConflicts().IsFocused(). SelectNextItem(). PressPrimaryAction() t.ExpectPopup().Alert(). Title(Equals("Continue")). Content(Contains("All merge conflicts resolved. Continue the revert?")). Confirm() t.Views().Commits(). Lines( Contains(`CI ◯ Revert "add first line"`), Contains("CI ◯ add second line"), Contains("CI ◯ add first line"), Contains("CI ◯ add empty file"), ) }, })
View Source
var Reword = NewIntegrationTest(NewIntegrationTestArgs{ Description: "Staging a couple files and committing", ExtraCmdArgs: []string{}, Skip: false, SetupConfig: func(config *config.AppConfig) {}, SetupRepo: func(shell *Shell) { shell.CreateFile("myfile", "myfile content") shell.CreateFile("myfile2", "myfile2 content") }, Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Commits(). IsEmpty() t.Views().Files(). IsFocused(). Lines( Equals("▼ /").IsSelected(), Contains("myfile"), Contains("myfile2"), ). SelectNextItem(). PressPrimaryAction(). Press(keys.Files.CommitChanges) commitMessage := "my commit message" t.ExpectPopup().CommitMessagePanel().Type(commitMessage).Confirm() t.Views().Commits(). Lines( Contains(commitMessage), ) t.Views().Files(). IsFocused(). PressPrimaryAction(). Press(keys.Files.CommitChanges) wipCommitMessage := "my commit message wip" t.ExpectPopup().CommitMessagePanel().Type(wipCommitMessage).Close() t.Views().Commits().Focus(). Lines( Contains(commitMessage), ).Press(keys.Commits.RenameCommit) t.ExpectPopup().CommitMessagePanel(). SwitchToDescription(). Type("some description"). SwitchToSummary(). Confirm() t.Views().Main().Content(MatchesRegexp("my commit message\n\\s*some description")) t.Views().Files(). Focus(). Press(keys.Files.CommitChanges) t.ExpectPopup().CommitMessagePanel().Confirm() t.Views().Commits(). Lines( Contains(wipCommitMessage), Contains(commitMessage), ) }, })
View Source
var Search = NewIntegrationTest(NewIntegrationTestArgs{ Description: "Search for a commit", ExtraCmdArgs: []string{}, Skip: false, SetupConfig: func(config *config.AppConfig) {}, SetupRepo: func(shell *Shell) { shell.EmptyCommit("one") shell.EmptyCommit("two") shell.EmptyCommit("three") shell.EmptyCommit("four") }, Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Commits(). Focus(). Lines( Contains("four").IsSelected(), Contains("three"), Contains("two"), Contains("one"), ). Press(keys.Universal.StartSearch). Tap(func() { t.ExpectSearch(). Type("two"). Confirm() t.Views().Search().IsVisible().Content(Contains("matches for 'two' (1 of 1)")) }). Lines( Contains("four"), Contains("three"), Contains("two").IsSelected(), Contains("one"), ). Press(keys.Universal.StartSearch). Tap(func() { t.ExpectSearch(). Clear(). Type("o"). Confirm() t.Views().Search().IsVisible().Content(Contains("matches for 'o' (2 of 3)")) }). Lines( Contains("four"), Contains("three"), Contains("two").IsSelected(), Contains("one"), ). Press("n"). Tap(func() { t.Views().Search().IsVisible().Content(Contains("matches for 'o' (3 of 3)")) }). Lines( Contains("four"), Contains("three"), Contains("two"), Contains("one").IsSelected(), ). Press("n"). Tap(func() { t.Views().Search().IsVisible().Content(Contains("matches for 'o' (1 of 3)")) }). Lines( Contains("four").IsSelected(), Contains("three"), Contains("two"), Contains("one"), ). Press("n"). Tap(func() { t.Views().Search().IsVisible().Content(Contains("matches for 'o' (2 of 3)")) }). Lines( Contains("four"), Contains("three"), Contains("two").IsSelected(), Contains("one"), ). Press("N"). Tap(func() { t.Views().Search().IsVisible().Content(Contains("matches for 'o' (1 of 3)")) }). Lines( Contains("four").IsSelected(), Contains("three"), Contains("two"), Contains("one"), ). Press("N"). Tap(func() { t.Views().Search().IsVisible().Content(Contains("matches for 'o' (3 of 3)")) }). Lines( Contains("four"), Contains("three"), Contains("two"), Contains("one").IsSelected(), ) }, })
View Source
var SetAuthor = NewIntegrationTest(NewIntegrationTestArgs{ Description: "Set author on a commit", ExtraCmdArgs: []string{}, Skip: false, SetupConfig: func(config *config.AppConfig) {}, SetupRepo: func(shell *Shell) { shell.NewBranch("original") shell.SetConfig("user.email", "Bill@example.com") shell.SetConfig("user.name", "Bill Smith") shell.EmptyCommit("one") shell.NewBranch("other") shell.SetConfig("user.email", "John@example.com") shell.SetConfig("user.name", "John Smith") shell.EmptyCommit("two") shell.Checkout("original") }, Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Commits(). Focus(). Lines( Contains("BS").Contains("one").IsSelected(), ) t.Views().Branches(). Focus(). Lines( Contains("original").IsSelected(), Contains("other"), ). NavigateToLine(Contains("other")). PressEnter() t.Views().SubCommits(). IsFocused(). Lines( Contains("JS").Contains("two").IsSelected(), Contains("BS").Contains("one"), ) t.Views().Commits(). Focus(). Press(keys.Commits.ResetCommitAuthor). Tap(func() { t.ExpectPopup().Menu(). Title(Equals("Amend commit attribute")). Select(Contains(" Set author")). Confirm() t.ExpectPopup().Prompt(). Title(Contains("Set author")). SuggestionLines( Contains("Bill Smith"), Contains("John Smith"), ). ConfirmSuggestion(Contains("John Smith")) }). Lines( Contains("JS").Contains("one").IsSelected(), ) }, })
View Source
var SetAuthorRange = NewIntegrationTest(NewIntegrationTestArgs{ Description: "Set author on a range of commits", ExtraCmdArgs: []string{}, Skip: false, SetupConfig: func(config *config.AppConfig) {}, SetupRepo: func(shell *Shell) { shell.SetConfig("user.email", "Bill@example.com") shell.SetConfig("user.name", "Bill Smith") shell.EmptyCommit("fourth") shell.EmptyCommit("third") shell.EmptyCommit("second") shell.EmptyCommit("first") }, Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Commits(). Focus(). Lines( Contains("BS").Contains("first").IsSelected(), Contains("BS").Contains("second"), Contains("BS").Contains("third"), Contains("BS").Contains("fourth"), ) t.Views().Commits(). Focus(). SelectNextItem(). Press(keys.Universal.ToggleRangeSelect). SelectNextItem(). Press(keys.Commits.ResetCommitAuthor). Tap(func() { t.ExpectPopup().Menu(). Title(Equals("Amend commit attribute")). Select(Contains(" Set author")). Confirm() t.ExpectPopup().Prompt(). Title(Contains("Set author")). Type("John Smith <John@example.com>"). Confirm() }). PressEscape(). Lines( Contains("BS").Contains("first"), Contains("JS").Contains("second"), Contains("JS").Contains("third").IsSelected(), Contains("BS").Contains("fourth"), ) }, })
View Source
var StageRangeOfLines = NewIntegrationTest(NewIntegrationTestArgs{ Description: "Staging a range of lines", ExtraCmdArgs: []string{}, Skip: false, SetupConfig: func(config *config.AppConfig) {}, SetupRepo: func(shell *Shell) { shell.CreateFileAndAdd("myfile", "1st\n2nd\n3rd\n4th\n5th\n6th\n") shell.Commit("Add file") shell.UpdateFile("myfile", "1st changed\n2nd changed\n3rd\n4th\n5th changed\n6th\n") }, Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Files(). IsFocused(). PressEnter() t.Views().Staging(). Content( Contains("-1st\n-2nd\n+1st changed\n+2nd changed\n 3rd\n 4th\n-5th\n+5th changed\n 6th"), ). SelectedLine(Equals("-1st")). Press(keys.Universal.ToggleRangeSelect). SelectNextItem(). SelectNextItem(). SelectNextItem(). SelectNextItem(). PressPrimaryAction(). Content( Contains(" 3rd\n 4th\n-5th\n+5th changed\n 6th"), ). SelectedLine(Equals("-5th")) }, })
View Source
var Staged = NewIntegrationTest(NewIntegrationTestArgs{ Description: "Staging a couple files, going in the staged files menu, unstaging a line then committing", ExtraCmdArgs: []string{}, Skip: false, SetupConfig: func(config *config.AppConfig) {}, SetupRepo: func(shell *Shell) { shell. CreateFile("myfile", "myfile content\nwith a second line"). CreateFile("myfile2", "myfile2 content") }, Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Commits(). IsEmpty() t.Views().Files(). IsFocused(). Lines( Equals("▼ /").IsSelected(), Contains("myfile"), Contains("myfile2"), ). SelectNextItem(). PressPrimaryAction(). PressEnter() t.Views().StagingSecondary(). IsFocused(). Tap(func() { t.Views().StagingSecondary().Content(Contains("+myfile content")) t.Views().StagingSecondary().Content(Contains("+with a second line")) t.Views().Staging().Content(DoesNotContain("+myfile content")) t.Views().Staging().Content(DoesNotContain("+with a second line")) }). PressPrimaryAction(). Tap(func() { t.Views().StagingSecondary().Content(DoesNotContain("+myfile content")) t.Views().StagingSecondary().Content(Contains("+with a second line")) t.Views().Staging().Content(Contains("+myfile content")) t.Views().Staging().Content(DoesNotContain("+with a second line")) }). Press(keys.Files.CommitChanges) commitMessage := "my commit message" t.ExpectPopup().CommitMessagePanel().Type(commitMessage).Confirm() t.Views().Commits(). Lines( Contains(commitMessage), ) t.Views().StagingSecondary(). IsEmpty() t.Views().Staging(). IsFocused(). Content(Contains("+myfile content")). Content(DoesNotContain("+with a second line")) }, })
View Source
var StagedWithoutHooks = NewIntegrationTest(NewIntegrationTestArgs{ Description: "Staging a couple files, going in the staged files menu, unstaging a line then committing without pre-commit hooks", ExtraCmdArgs: []string{}, Skip: false, SetupConfig: func(config *config.AppConfig) {}, SetupRepo: func(shell *Shell) { shell.CreateFile(".git/hooks/pre-commit", blockingHook) shell.MakeExecutable(".git/hooks/pre-commit") shell. CreateFile("myfile", "myfile content\nwith a second line"). CreateFile("myfile2", "myfile2 content") }, Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Commits(). IsEmpty() checkBlockingHook(t, keys) t.Views().Files(). IsFocused(). Lines( Equals("▼ /").IsSelected(), Contains("myfile"), Contains("myfile2"), ). SelectNextItem(). PressPrimaryAction(). PressEnter() t.Views().StagingSecondary().Content( Contains("+myfile content").Contains("+with a second line"), ) t.Views().Staging().Content( DoesNotContain("+myfile content").DoesNotContain("+with a second line"), ) t.Views().StagingSecondary(). IsFocused(). PressPrimaryAction(). Tap(func() { t.Views().Staging().Content(Contains("+myfile content").DoesNotContain("+with a second line")) }). Content(DoesNotContain("+myfile content").Contains("+with a second line")). Press(keys.Files.CommitChangesWithoutHook) commitMessage := "my commit message" t.ExpectPopup().CommitMessagePanel().Type(commitMessage).Confirm() t.Views().Commits(). Lines( Contains(commitMessage), ) t.Views().StagingSecondary(). IsEmpty() t.Views().Staging(). IsFocused(). Content(Contains("+myfile content")). Content(DoesNotContain("+with a second line")) }, })
View Source
var Unstaged = NewIntegrationTest(NewIntegrationTestArgs{ Description: "Staging a couple files, going in the unstaged files menu, staging a line and committing", ExtraCmdArgs: []string{}, Skip: false, SetupConfig: func(config *config.AppConfig) {}, SetupRepo: func(shell *Shell) { shell. CreateFile("myfile", "myfile content\nwith a second line"). CreateFile("myfile2", "myfile2 content") }, Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Commits(). IsEmpty() t.Views().Files(). IsFocused(). Lines( Equals("▼ /").IsSelected(), Contains("myfile"), Contains("myfile2"), ). SelectNextItem(). PressEnter() t.Views().Staging(). IsFocused(). Tap(func() { t.Views().StagingSecondary().Content(DoesNotContain("+myfile content")) t.Views().Staging().SelectedLine(Equals("+myfile content")) }). PressPrimaryAction(). Tap(func() { t.Views().Staging().Content(DoesNotContain("+myfile content")). SelectedLine(Equals("+with a second line")) t.Views().StagingSecondary().Content(Contains("+myfile content")) }). Press(keys.Files.CommitChanges) commitMessage := "my commit message" t.ExpectPopup().CommitMessagePanel().Type(commitMessage).Confirm() t.Views().Commits(). Lines( Contains(commitMessage), ) t.Views().Staging().IsFocused() }, })
Functions ¶
This section is empty.
Types ¶
This section is empty.
Source Files
¶
- add_co_author.go
- add_co_author_range.go
- add_co_author_while_committing.go
- amend.go
- amend_when_there_are_conflicts_and_amend.go
- amend_when_there_are_conflicts_and_cancel.go
- amend_when_there_are_conflicts_and_continue.go
- auto_wrap_message.go
- checkout.go
- checkout_file_from_commit.go
- checkout_file_from_range_selection_of_commits.go
- commit.go
- commit_multiline.go
- commit_skip_hooks.go
- commit_switch_to_editor.go
- commit_switch_to_editor_skip_hooks.go
- commit_wip_with_prefix.go
- commit_with_fallthrough_prefix.go
- commit_with_global_prefix.go
- commit_with_non_matching_branch_name.go
- commit_with_prefix.go
- copy_author_to_clipboard.go
- copy_message_body_to_clipboard.go
- copy_tag_to_clipboard.go
- create_amend_commit.go
- create_fixup_commit_in_branch_stack.go
- create_tag.go
- disable_copy_commit_message_body.go
- discard_old_file_changes.go
- fail_hooks_then_commit_no_hooks.go
- find_base_commit_for_fixup.go
- find_base_commit_for_fixup_disregard_main_branch.go
- find_base_commit_for_fixup_only_added_lines.go
- find_base_commit_for_fixup_warning_for_added_lines.go
- highlight.go
- history.go
- history_complex.go
- new_branch.go
- paste_commit_message.go
- paste_commit_message_over_existing.go
- preserve_commit_message.go
- reset_author.go
- reset_author_range.go
- revert.go
- revert_merge.go
- revert_with_conflict_multiple_commits.go
- revert_with_conflict_single_commit.go
- reword.go
- search.go
- set_author.go
- set_author_range.go
- shared.go
- stage_range_of_lines.go
- staged.go
- staged_without_hooks.go
- unstaged.go
Click to show internal directories.
Click to hide internal directories.