commit

package
v0.0.0-...-00ab8b8 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2024 License: MIT Imports: 3 Imported by: 0

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 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 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.UserConfig.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 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(
				Contains("?? myfile").IsSelected(),
				Contains("?? myfile2"),
			).
			PressPrimaryAction().
			Lines(
				Contains("A  myfile").IsSelected(),
				Contains("?? myfile2"),
			).
			SelectNextItem().
			PressPrimaryAction().
			Lines(
				Contains("A  myfile"),
				Contains("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(
				Contains("A myfile"),
				Contains("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 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().
			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().
			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(testConfig *config.AppConfig) {
		testConfig.UserConfig.Git.CommitPrefixes = map[string]config.CommitPrefixConfig{"repo": {Pattern: "^\\w+\\/(\\w+-\\w+).*", Replace: "[$1]: "}}
	},
	SetupRepo: func(shell *Shell) {
		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()

		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.CommitChanges)

		t.ExpectPopup().CommitMessagePanel().
			Title(Equals("Commit summary")).
			InitialText(Equals("WIP foo")).
			Type(" bar").
			Cancel()

		t.Views().Files().
			IsFocused().
			Press(keys.Files.CommitChanges)

		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 CommitWithPrefix = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Commit with defined config commitPrefix",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupConfig: func(testConfig *config.AppConfig) {
		testConfig.UserConfig.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]: ")).
			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 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 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(
				Contains("dir1").IsSelected(),
				Contains("subd1"),
				Contains("subfile0"),
				Contains("d1_file0"),
				Contains("dir2"),
				Contains("d2_file1"),
				Contains("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(
				Contains("dir1/subd1"),
				Contains("subfile0"),
				Contains("dir2"),
				Contains("d2_file1").IsSelected(),
				Contains("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(
				Contains("dir2").IsSelected(),
				Contains("d2_file1"),
				Contains("d2_file2"),
				Contains("d2_file3"),
				Contains("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(
				Contains("dir1").IsSelected(),
				Contains("subd1"),
				Contains("file2ToRemove"),
				Contains("fileToRemove"),
				Contains("multiLineFile"),
			).
			NavigateToLine(Contains("multiLineFile")).
			PressEnter()

		t.Views().PatchBuilding().
			IsFocused().
			SelectedLine(
				Contains("+this file has"),
			).
			PressPrimaryAction().
			PressEscape()

		t.Views().CommitFiles().
			IsFocused().
			Lines(
				Contains("dir1"),
				Contains("subd1"),
				Contains("file2ToRemove"),
				Contains("fileToRemove"),
				Contains("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 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 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.AppState.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 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.Views().Files().
			IsFocused().
			Press(keys.Files.CommitChanges)

		t.ExpectPopup().CommitMessagePanel().
			Content(Equals("my commit message")).
			SwitchToDescription().
			Content(Equals("first paragraph\n\nsecond paragraph"))
	},
})
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 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().Menu().
			Title(Equals("Select parent commit for merge")).
			Lines(
				Contains("first change"),
				Contains("second-change-branch unrelated change"),
				Contains("Cancel"),
			).
			Select(Contains("first change")).
			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 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().
			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().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().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().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().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().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().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().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 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().
			SelectedLine(Contains("myfile")).
			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("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().
			SelectedLine(Contains("myfile")).
			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().InitialText(Contains("WIP")).Type(commitMessage).Confirm()

		t.Views().Commits().
			Lines(
				Contains("WIP" + 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().
			SelectedLine(Contains("myfile")).
			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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL