1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-08-08 22:36:49 +02:00

add helper functions for popups in tests

This commit is contained in:
Jesse Duffield
2022-12-24 17:48:57 +11:00
parent aedfce2845
commit b623ecf898
40 changed files with 380 additions and 402 deletions

View File

@@ -20,24 +20,14 @@ var Basic = NewIntegrationTest(NewIntegrationTestArgs{
assert *Assert,
keys config.KeybindingConfig,
) {
viewBisectOptions := func() {
input.PressKeys(keys.Commits.ViewBisectOptions)
assert.InMenu()
}
markCommitAsBad := func() {
viewBisectOptions()
assert.SelectedLine(Contains("bad"))
input.Confirm()
input.Press(keys.Commits.ViewBisectOptions)
input.Menu(Equals("Bisect"), MatchesRegexp(`mark .* as bad`))
}
markCommitAsGood := func() {
viewBisectOptions()
assert.SelectedLine(Contains("bad"))
input.NextItem()
assert.SelectedLine(Contains("good"))
input.Confirm()
input.Press(keys.Commits.ViewBisectOptions)
input.Menu(Equals("Bisect"), MatchesRegexp(`mark .* as good`))
}
assert.AtLeastOneCommit()
@@ -46,7 +36,7 @@ var Basic = NewIntegrationTest(NewIntegrationTestArgs{
assert.SelectedLine(Contains("commit 10"))
input.NavigateToListItemContainingText("commit 09")
input.NavigateToListItem(Contains("commit 09"))
markCommitAsBad()
@@ -55,11 +45,11 @@ var Basic = NewIntegrationTest(NewIntegrationTestArgs{
assert.CurrentViewName("commits")
assert.SelectedLine(Contains("<-- bad"))
input.NavigateToListItemContainingText("commit 02")
input.NavigateToListItem(Contains("commit 02"))
markCommitAsGood()
// lazygit will land us in the comit between our good and bad commits.
// lazygit will land us in the commit between our good and bad commits.
assert.CurrentViewName("commits")
assert.SelectedLine(Contains("commit 05"))
assert.SelectedLine(Contains("<-- current"))
@@ -72,12 +62,8 @@ var Basic = NewIntegrationTest(NewIntegrationTestArgs{
markCommitAsGood()
assert.InAlert()
assert.CurrentViewContent(Contains("Bisect complete!"))
// commit 5 is the culprit because we marked 4 as good and 5 as bad.
assert.CurrentViewContent(Contains("commit 05"))
assert.CurrentViewContent(Contains("Do you want to reset"))
input.Confirm()
input.Alert(Equals("Bisect complete"), MatchesRegexp("(?s)commit 05.*Do you want to reset"))
assert.CurrentViewName("commits")
assert.CurrentViewContent(Contains("commit 04"))

View File

@@ -24,20 +24,6 @@ var FromOtherBranch = NewIntegrationTest(NewIntegrationTestArgs{
assert *Assert,
keys config.KeybindingConfig,
) {
viewBisectOptions := func() {
input.PressKeys(keys.Commits.ViewBisectOptions)
assert.InMenu()
}
markCommitAsGood := func() {
viewBisectOptions()
assert.SelectedLine(Contains("bad"))
input.NextItem()
assert.SelectedLine(Contains("good"))
input.Confirm()
}
assert.ViewContent("information", Contains("bisecting"))
assert.AtLeastOneCommit()
@@ -51,13 +37,10 @@ var FromOtherBranch = NewIntegrationTest(NewIntegrationTestArgs{
assert.SelectedLine(Contains("<-- current"))
assert.SelectedLine(Contains("commit 07"))
markCommitAsGood()
input.Press(keys.Commits.ViewBisectOptions)
input.Menu(Equals("Bisect"), MatchesRegexp(`mark .* as good`))
assert.InAlert()
assert.CurrentViewContent(Contains("Bisect complete!"))
assert.CurrentViewContent(Contains("commit 08"))
assert.CurrentViewContent(Contains("Do you want to reset"))
input.Confirm()
input.Alert(Equals("Bisect complete"), MatchesRegexp(`(?s)commit 08.*Do you want to reset`))
assert.ViewContent("information", NotContains("bisecting"))

View File

@@ -24,14 +24,11 @@ var CheckoutByName = NewIntegrationTest(NewIntegrationTestArgs{
assert.SelectedLine(Contains("master"))
input.NextItem()
assert.SelectedLine(Contains("@"))
input.PressKeys(keys.Branches.CheckoutBranchByName)
assert.InPrompt()
assert.CurrentViewTitle(Equals("Branch name:"))
input.Type("new-branch")
input.Confirm()
assert.InAlert()
assert.CurrentViewContent(Equals("Branch not found. Create a new branch named new-branch?"))
input.Confirm()
input.Press(keys.Branches.CheckoutBranchByName)
input.Prompt(Equals("Branch name:"), "new-branch")
input.Alert(Equals("Branch not found"), Equals("Branch not found. Create a new branch named new-branch?"))
assert.CurrentViewName("localBranches")
assert.SelectedLine(Contains("new-branch"))

View File

@@ -21,18 +21,15 @@ var Delete = NewIntegrationTest(NewIntegrationTestArgs{
assert.CurrentViewName("localBranches")
assert.SelectedLine(Contains("branch-two"))
input.PressKeys(keys.Universal.Remove)
assert.InAlert()
assert.CurrentViewContent(Contains("You cannot delete the checked out branch!"))
input.Confirm()
input.Press(keys.Universal.Remove)
input.Alert(Equals("Error"), Contains("You cannot delete the checked out branch!"))
input.NextItem()
assert.SelectedLine(Contains("branch-one"))
input.PressKeys(keys.Universal.Remove)
assert.InConfirm()
assert.CurrentViewContent(Contains("Are you sure you want to delete the branch 'branch-one'?"))
input.Confirm()
input.Press(keys.Universal.Remove)
input.AcceptConfirmation(Equals("Delete Branch"), Contains("Are you sure you want to delete the branch 'branch-one'?"))
assert.CurrentViewName("localBranches")
assert.SelectedLine(Contains("master"))
assert.CurrentViewContent(NotContains("branch-one"))

View File

@@ -21,30 +21,26 @@ var Rebase = NewIntegrationTest(NewIntegrationTestArgs{
assert.SelectedLine(Contains("first-change-branch"))
input.NextItem()
assert.SelectedLine(Contains("second-change-branch"))
input.PressKeys(keys.Branches.RebaseBranch)
input.Press(keys.Branches.RebaseBranch)
assert.InConfirm()
assert.CurrentViewContent(Contains("Are you sure you want to rebase 'first-change-branch' on top of 'second-change-branch'?"))
input.Confirm()
input.AcceptConfirmation(Equals("Rebasing"), Contains("Are you sure you want to rebase 'first-change-branch' on top of 'second-change-branch'?"))
assert.InConfirm()
assert.CurrentViewContent(Contains("Conflicts!"))
input.Confirm()
input.AcceptConfirmation(Equals("Auto-merge failed"), Contains("Conflicts!"))
assert.CurrentViewName("files")
assert.SelectedLine(Contains("file"))
// not using Confirm() convenience method because I suspect we might change this
// keybinding to something more bespoke
input.PressKeys(keys.Universal.Confirm)
input.Press(keys.Universal.Confirm)
assert.CurrentViewName("mergeConflicts")
input.PrimaryAction()
assert.ViewContent("information", Contains("rebasing"))
assert.InConfirm()
assert.CurrentViewContent(Contains("all merge conflicts resolved. Continue?"))
input.Confirm()
input.AcceptConfirmation(Equals("continue"), Contains("all merge conflicts resolved. Continue?"))
assert.ViewContent("information", NotContains("rebasing"))
// this proves we actually have integrated the changes from second-change-branch

View File

@@ -24,17 +24,13 @@ var RebaseAndDrop = NewIntegrationTest(NewIntegrationTestArgs{
assert.SelectedLine(Contains("first-change-branch"))
input.NextItem()
assert.SelectedLine(Contains("second-change-branch"))
input.PressKeys(keys.Branches.RebaseBranch)
input.Press(keys.Branches.RebaseBranch)
assert.InConfirm()
assert.CurrentViewContent(Contains("Are you sure you want to rebase 'first-change-branch' on top of 'second-change-branch'?"))
input.Confirm()
input.AcceptConfirmation(Equals("Rebasing"), Contains("Are you sure you want to rebase 'first-change-branch' on top of 'second-change-branch'?"))
assert.ViewContent("information", Contains("rebasing"))
assert.InConfirm()
assert.CurrentViewContent(Contains("Conflicts!"))
input.Confirm()
input.AcceptConfirmation(Equals("Auto-merge failed"), Contains("Conflicts!"))
assert.CurrentViewName("files")
assert.SelectedLine(Contains("file"))
@@ -42,22 +38,22 @@ var RebaseAndDrop = NewIntegrationTest(NewIntegrationTestArgs{
input.SwitchToCommitsWindow()
assert.SelectedLine(Contains("pick")) // this means it's a rebasing commit
input.NextItem()
input.PressKeys(keys.Universal.Remove)
input.Press(keys.Universal.Remove)
// this is the commit name
assert.SelectedLine(Contains("to remove"))
// the commit has been marked to drop once we continue the rebase.
assert.SelectedLine(Contains("drop"))
input.SwitchToFilesWindow()
// not using Confirm() convenience method because I suspect we might change this
// keybinding to something more bespoke
input.PressKeys(keys.Universal.Confirm)
input.Press(keys.Universal.Confirm)
assert.CurrentViewName("mergeConflicts")
input.PrimaryAction()
assert.InConfirm()
assert.CurrentViewContent(Contains("all merge conflicts resolved. Continue?"))
input.Confirm()
input.AcceptConfirmation(Equals("continue"), Contains("all merge conflicts resolved. Continue?"))
assert.ViewContent("information", NotContains("rebasing"))

View File

@@ -28,17 +28,9 @@ var Reset = NewIntegrationTest(NewIntegrationTestArgs{
input.NextItem()
assert.SelectedLine(Contains("other-branch"))
input.PressKeys(keys.Commits.ViewResetOptions)
assert.InMenu()
assert.CurrentViewTitle(Contains("reset to other-branch"))
input.Press(keys.Commits.ViewResetOptions)
assert.SelectedLine(Contains("soft reset"))
input.NextItem()
assert.SelectedLine(Contains("mixed reset"))
input.NextItem()
assert.SelectedLine(Contains("hard reset"))
input.Confirm()
input.Menu(Contains("reset to other-branch"), Contains("hard reset"))
// ensure that we've returned from the menu before continuing
assert.CurrentViewName("localBranches")

View File

@@ -24,18 +24,11 @@ var Suggestions = NewIntegrationTest(NewIntegrationTestArgs{
input.SwitchToBranchesWindow()
assert.CurrentViewName("localBranches")
input.PressKeys(keys.Branches.CheckoutBranchByName)
assert.CurrentViewName("confirmation")
input.Type("branch-to")
input.PressKeys(keys.Universal.TogglePanel)
assert.CurrentViewName("suggestions")
input.Press(keys.Branches.CheckoutBranchByName)
// we expect the first suggestion to be the branch we want because it most
// closely matches what we typed in
assert.SelectedLine(Contains("branch-to-checkout"))
input.Confirm()
input.Typeahead(Equals("Branch name:"), "branch-to", Contains("branch-to-checkout"))
assert.CurrentBranchName("branch-to-checkout")
},

View File

@@ -35,23 +35,21 @@ var CherryPick = NewIntegrationTest(NewIntegrationTestArgs{
assert.CurrentViewName("subCommits")
assert.SelectedLine(Contains("four"))
input.PressKeys(keys.Commits.CherryPickCopy)
input.Press(keys.Commits.CherryPickCopy)
assert.ViewContent("information", Contains("1 commit copied"))
input.NextItem()
assert.SelectedLine(Contains("three"))
input.PressKeys(keys.Commits.CherryPickCopy)
input.Press(keys.Commits.CherryPickCopy)
assert.ViewContent("information", Contains("2 commits copied"))
input.SwitchToCommitsWindow()
assert.CurrentViewName("commits")
assert.SelectedLine(Contains("two"))
input.PressKeys(keys.Commits.PasteCommits)
assert.InAlert()
assert.CurrentViewContent(Contains("Are you sure you want to cherry-pick the copied commits onto this branch?"))
input.Press(keys.Commits.PasteCommits)
input.Alert(Equals("Cherry-Pick"), Contains("Are you sure you want to cherry-pick the copied commits onto this branch?"))
input.Confirm()
assert.CurrentViewName("commits")
assert.SelectedLine(Contains("four"))
input.NextItem()
@@ -60,7 +58,7 @@ var CherryPick = NewIntegrationTest(NewIntegrationTestArgs{
assert.SelectedLine(Contains("two"))
assert.ViewContent("information", Contains("2 commits copied"))
input.PressKeys(keys.Universal.Return)
input.Press(keys.Universal.Return)
assert.ViewContent("information", NotContains("commits copied"))
},
})

View File

@@ -26,42 +26,36 @@ var CherryPickConflicts = NewIntegrationTest(NewIntegrationTestArgs{
assert.CurrentViewName("subCommits")
assert.SelectedLine(Contains("second-change-branch unrelated change"))
input.PressKeys(keys.Commits.CherryPickCopy)
input.Press(keys.Commits.CherryPickCopy)
assert.ViewContent("information", Contains("1 commit copied"))
input.NextItem()
assert.SelectedLine(Contains("second change"))
input.PressKeys(keys.Commits.CherryPickCopy)
input.Press(keys.Commits.CherryPickCopy)
assert.ViewContent("information", Contains("2 commits copied"))
input.SwitchToCommitsWindow()
assert.CurrentViewName("commits")
assert.SelectedLine(Contains("first change"))
input.PressKeys(keys.Commits.PasteCommits)
assert.InAlert()
assert.CurrentViewContent(Contains("Are you sure you want to cherry-pick the copied commits onto this branch?"))
input.Press(keys.Commits.PasteCommits)
input.Alert(Equals("Cherry-Pick"), Contains("Are you sure you want to cherry-pick the copied commits onto this branch?"))
input.Confirm()
assert.CurrentViewContent(Contains("Conflicts!"))
input.Confirm()
input.AcceptConfirmation(Equals("Auto-merge failed"), Contains("Conflicts!"))
assert.CurrentViewName("files")
assert.SelectedLine(Contains("file"))
// not using Confirm() convenience method because I suspect we might change this
// keybinding to something more bespoke
input.PressKeys(keys.Universal.Confirm)
input.Press(keys.Universal.Confirm)
assert.CurrentViewName("mergeConflicts")
// picking 'Second change'
input.NextItem()
input.PrimaryAction()
assert.InConfirm()
assert.CurrentViewContent(Contains("all merge conflicts resolved. Continue?"))
input.Confirm()
input.AcceptConfirmation(Equals("continue"), Contains("all merge conflicts resolved. Continue?"))
assert.CurrentViewName("files")
assert.WorkingTreeFileCount(0)
@@ -81,7 +75,7 @@ var CherryPickConflicts = NewIntegrationTest(NewIntegrationTestArgs{
assert.SelectedLine(Contains("first change"))
assert.ViewContent("information", Contains("2 commits copied"))
input.PressKeys(keys.Universal.Return)
input.Press(keys.Universal.Return)
assert.ViewContent("information", NotContains("commits copied"))
},
})

View File

@@ -20,8 +20,9 @@ var Commit = NewIntegrationTest(NewIntegrationTestArgs{
input.PrimaryAction()
input.NextItem()
input.PrimaryAction()
input.PressKeys(keys.Files.CommitChanges)
input.Press(keys.Files.CommitChanges)
assert.InCommitMessagePanel()
commitMessage := "my commit message"
input.Type(commitMessage)
input.Confirm()

View File

@@ -17,11 +17,12 @@ var CommitMultiline = NewIntegrationTest(NewIntegrationTestArgs{
assert.CommitCount(0)
input.PrimaryAction()
input.PressKeys(keys.Files.CommitChanges)
input.Press(keys.Files.CommitChanges)
assert.InCommitMessagePanel()
input.Type("first line")
input.PressKeys(keys.Universal.AppendNewline)
input.PressKeys(keys.Universal.AppendNewline)
input.Press(keys.Universal.AppendNewline)
input.Press(keys.Universal.AppendNewline)
input.Type("third line")
input.Confirm()

View File

@@ -23,13 +23,10 @@ var NewBranch = NewIntegrationTest(NewIntegrationTestArgs{
assert.CurrentViewName("commits")
input.NextItem()
input.PressKeys(keys.Universal.New)
assert.CurrentViewName("confirmation")
input.Press(keys.Universal.New)
branchName := "my-branch-name"
input.Type(branchName)
input.Confirm()
input.Prompt(Contains("New Branch Name"), branchName)
assert.CommitCount(2)
assert.HeadCommitMessage(Contains("commit 2"))

View File

@@ -20,18 +20,13 @@ var Revert = NewIntegrationTest(NewIntegrationTestArgs{
input.SwitchToCommitsWindow()
input.PressKeys(keys.Commits.RevertCommit)
assert.InConfirm()
assert.CurrentViewTitle(Equals("Revert commit"))
assert.CurrentViewContent(MatchesRegexp("Are you sure you want to revert \\w+?"))
input.Confirm()
input.Press(keys.Commits.RevertCommit)
input.AcceptConfirmation(Equals("Revert commit"), MatchesRegexp(`Are you sure you want to revert \w+?`))
assert.CommitCount(2)
assert.HeadCommitMessage(Contains("Revert \"first commit\""))
input.PreviousItem()
assert.MainViewContent(Contains("-myfile content"))
assert.FileSystemPathNotPresent("myfile")
input.Wait(10)
},
})

View File

@@ -18,11 +18,28 @@ var Staged = NewIntegrationTest(NewIntegrationTestArgs{
Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
assert.CommitCount(0)
assert.CurrentViewName("files")
assert.SelectedLine(Contains("myfile"))
// stage the file
input.PrimaryAction()
input.Confirm()
input.PrimaryAction()
input.PressKeys(keys.Files.CommitChanges)
input.Enter()
assert.CurrentViewName("stagingSecondary")
// we start with both lines having been staged
assert.ViewContent("stagingSecondary", Contains("+myfile content"))
assert.ViewContent("stagingSecondary", Contains("+with a second line"))
assert.ViewContent("staging", NotContains("+myfile content"))
assert.ViewContent("staging", NotContains("+with a second line"))
// unstage the selected line
input.PrimaryAction()
// the line should have been moved to the main view
assert.ViewContent("stagingSecondary", NotContains("+myfile content"))
assert.ViewContent("stagingSecondary", Contains("+with a second line"))
assert.ViewContent("staging", Contains("+myfile content"))
assert.ViewContent("staging", NotContains("+with a second line"))
input.Press(keys.Files.CommitChanges)
commitMessage := "my commit message"
input.Type(commitMessage)
input.Confirm()
@@ -30,5 +47,7 @@ var Staged = NewIntegrationTest(NewIntegrationTestArgs{
assert.CommitCount(1)
assert.HeadCommitMessage(Equals(commitMessage))
assert.CurrentWindowName("stagingSecondary")
// TODO: assert that the staging panel has been refreshed (it currently does not get correctly refreshed)
},
})

View File

@@ -18,17 +18,38 @@ var StagedWithoutHooks = NewIntegrationTest(NewIntegrationTestArgs{
Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
assert.CommitCount(0)
// stage the file
assert.CurrentViewName("files")
assert.SelectedLine(Contains("myfile"))
input.PrimaryAction()
input.Confirm()
input.PrimaryAction()
input.PressKeys(keys.Files.CommitChangesWithoutHook)
input.Enter()
assert.CurrentViewName("stagingSecondary")
// we start with both lines having been staged
assert.ViewContent("stagingSecondary", Contains("+myfile content"))
assert.ViewContent("stagingSecondary", Contains("+with a second line"))
assert.ViewContent("staging", NotContains("+myfile content"))
assert.ViewContent("staging", NotContains("+with a second line"))
commitMessage := "my commit message"
// unstage the selected line
input.PrimaryAction()
// the line should have been moved to the main view
assert.ViewContent("stagingSecondary", NotContains("+myfile content"))
assert.ViewContent("stagingSecondary", Contains("+with a second line"))
assert.ViewContent("staging", Contains("+myfile content"))
assert.ViewContent("staging", NotContains("+with a second line"))
input.Press(keys.Files.CommitChangesWithoutHook)
assert.InCommitMessagePanel()
assert.CurrentViewContent(Contains("WIP"))
commitMessage := ": my commit message"
input.Type(commitMessage)
input.Confirm()
assert.CommitCount(1)
assert.HeadCommitMessage(Equals("WIP" + commitMessage))
assert.CurrentWindowName("stagingSecondary")
assert.CurrentViewName("stagingSecondary")
// TODO: assert that the staging panel has been refreshed (it currently does not get correctly refreshed)
},
})

View File

@@ -5,6 +5,8 @@ import (
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
// TODO: find out why we can't use assert.SelectedLine() on the staging/stagingSecondary views.
var Unstaged = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Staging a couple files, going in the unstaged files menu, staging a line and committing",
ExtraCmdArgs: "",
@@ -18,10 +20,18 @@ var Unstaged = NewIntegrationTest(NewIntegrationTestArgs{
Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
assert.CommitCount(0)
input.Confirm()
assert.CurrentViewName("files")
assert.SelectedLine(Contains("myfile"))
input.Enter()
assert.CurrentViewName("staging")
assert.ViewContent("stagingSecondary", NotContains("+myfile content"))
// stage the first line
input.PrimaryAction()
input.PressKeys(keys.Files.CommitChanges)
assert.ViewContent("staging", NotContains("+myfile content"))
assert.ViewContent("stagingSecondary", Contains("+myfile content"))
input.Press(keys.Files.CommitChanges)
assert.InCommitMessagePanel()
commitMessage := "my commit message"
input.Type(commitMessage)
input.Confirm()
@@ -29,5 +39,7 @@ var Unstaged = NewIntegrationTest(NewIntegrationTestArgs{
assert.CommitCount(1)
assert.HeadCommitMessage(Equals(commitMessage))
assert.CurrentWindowName("staging")
// TODO: assert that the staging panel has been refreshed (it currently does not get correctly refreshed)
},
})

View File

@@ -1,33 +0,0 @@
package commit
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var UnstagedWithoutHooks = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Staging a couple files, going in the unstaged files menu, staging a line and committing without pre-commit hooks",
ExtraCmdArgs: "",
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(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
assert.CommitCount(0)
input.Confirm()
input.PrimaryAction()
input.PressKeys(keys.Files.CommitChangesWithoutHook)
commitMessage := "my commit message"
input.Type(commitMessage)
input.Confirm()
assert.CommitCount(1)
assert.HeadCommitMessage(Equals("WIP" + commitMessage))
assert.CurrentWindowName("staging")
},
})

View File

@@ -29,7 +29,7 @@ var Basic = NewIntegrationTest(NewIntegrationTestArgs{
) {
assert.WorkingTreeFileCount(0)
input.PressKeys("a")
input.Press("a")
assert.WorkingTreeFileCount(1)
assert.SelectedLine(Contains("myfile"))
},

View File

@@ -63,23 +63,13 @@ var FormPrompts = NewIntegrationTest(NewIntegrationTestArgs{
) {
assert.WorkingTreeFileCount(0)
input.PressKeys("a")
input.Press("a")
assert.InPrompt()
assert.CurrentViewTitle(Equals("Enter a file name"))
input.Type("my file")
input.Confirm()
input.Prompt(Equals("Enter a file name"), "my file")
assert.InMenu()
assert.CurrentViewTitle(Equals("Choose file content"))
assert.SelectedLine(Contains("foo"))
input.NextItem()
assert.SelectedLine(Contains("bar"))
input.Confirm()
input.Menu(Equals("Choose file content"), Contains("bar"))
assert.InConfirm()
assert.CurrentViewTitle(Equals("Are you sure?"))
input.Confirm()
input.AcceptConfirmation(Equals("Are you sure?"), Equals("Are you REALLY sure you want to make this file? Up to you buddy."))
assert.WorkingTreeFileCount(1)
assert.SelectedLine(Contains("my file"))

View File

@@ -51,19 +51,11 @@ var MenuFromCommand = NewIntegrationTest(NewIntegrationTestArgs{
assert.WorkingTreeFileCount(0)
input.SwitchToBranchesWindow()
input.PressKeys("a")
input.Press("a")
assert.InMenu()
assert.CurrentViewTitle(Equals("Choose commit message"))
assert.SelectedLine(Equals("baz"))
input.NextItem()
assert.SelectedLine(Equals("bar"))
input.Confirm()
input.Menu(Equals("Choose commit message"), Contains("bar"))
assert.InPrompt()
assert.CurrentViewTitle(Equals("Description"))
input.Type(" my branch")
input.Confirm()
input.Prompt(Equals("Description"), " my branch")
input.SwitchToFilesWindow()

View File

@@ -47,22 +47,19 @@ var MenuFromCommandsOutput = NewIntegrationTest(NewIntegrationTestArgs{
assert *Assert,
keys config.KeybindingConfig,
) {
assert.CurrentBranchName("feature/bar")
assert.WorkingTreeFileCount(0)
input.SwitchToBranchesWindow()
input.PressKeys("a")
input.Press("a")
assert.InPrompt()
assert.CurrentViewTitle(Equals("Which git command do you want to run?"))
assert.SelectedLine(Equals("branch"))
input.Confirm()
assert.InMenu()
assert.CurrentViewTitle(Equals("Branch:"))
input.NextItem()
input.NextItem()
assert.SelectedLine(Equals("master"))
input.Confirm()
input.Menu(Equals("Branch:"), Equals("master"))
assert.CurrentBranchName("master")
},

View File

@@ -61,23 +61,13 @@ var MultiplePrompts = NewIntegrationTest(NewIntegrationTestArgs{
) {
assert.WorkingTreeFileCount(0)
input.PressKeys("a")
input.Press("a")
assert.InPrompt()
assert.CurrentViewTitle(Equals("Enter a file name"))
input.Type("myfile")
input.Confirm()
input.Prompt(Equals("Enter a file name"), "myfile")
assert.InMenu()
assert.CurrentViewTitle(Equals("Choose file content"))
assert.SelectedLine(Contains("foo"))
input.NextItem()
assert.SelectedLine(Contains("bar"))
input.Confirm()
input.Menu(Equals("Choose file content"), Contains("bar"))
assert.InConfirm()
assert.CurrentViewTitle(Equals("Are you sure?"))
input.Confirm()
input.AcceptConfirmation(Equals("Are you sure?"), Equals("Are you REALLY sure you want to make this file? Up to you buddy."))
assert.WorkingTreeFileCount(1)
assert.SelectedLine(Contains("myfile"))

View File

@@ -26,11 +26,8 @@ var Diff = NewIntegrationTest(NewIntegrationTestArgs{
assert.CurrentViewName("localBranches")
assert.SelectedLine(Contains("branch-a"))
input.PressKeys(keys.Universal.DiffingMenu)
assert.InMenu()
assert.CurrentViewTitle(Equals("Diffing"))
assert.SelectedLine(Contains("diff branch-a"))
input.Confirm()
input.Press(keys.Universal.DiffingMenu)
input.Menu(Equals("Diffing"), Contains(`diff branch-a`))
assert.CurrentViewName("localBranches")
@@ -48,14 +45,12 @@ var Diff = NewIntegrationTest(NewIntegrationTestArgs{
assert.SelectedLine(Contains("file1"))
assert.MainViewContent(Contains("+second line"))
input.PressKeys(keys.Universal.Return)
input.PressKeys(keys.Universal.Return)
input.Press(keys.Universal.Return)
input.Press(keys.Universal.Return)
assert.CurrentViewName("localBranches")
input.PressKeys(keys.Universal.DiffingMenu)
assert.InMenu()
input.NavigateToListItemContainingText("reverse diff direction")
input.Confirm()
input.Press(keys.Universal.DiffingMenu)
input.Menu(Equals("Diffing"), Contains("reverse diff direction"))
assert.ViewContent("information", Contains("showing output for: git diff branch-a branch-b -R"))
assert.MainViewContent(Contains("-second line"))
},

View File

@@ -26,11 +26,9 @@ var DiffAndApplyPatch = NewIntegrationTest(NewIntegrationTestArgs{
assert.CurrentViewName("localBranches")
assert.SelectedLine(Contains("branch-a"))
input.PressKeys(keys.Universal.DiffingMenu)
assert.InMenu()
assert.CurrentViewTitle(Equals("Diffing"))
assert.SelectedLine(Contains("diff branch-a"))
input.Confirm()
input.Press(keys.Universal.DiffingMenu)
input.Menu(Equals("Diffing"), Equals("diff branch-a"))
assert.CurrentViewName("localBranches")
@@ -51,20 +49,14 @@ var DiffAndApplyPatch = NewIntegrationTest(NewIntegrationTestArgs{
// add the file to the patch
input.PrimaryAction()
input.PressKeys(keys.Universal.DiffingMenu)
assert.InMenu()
assert.CurrentViewTitle(Equals("Diffing"))
input.NavigateToListItemContainingText("exit diff mode")
input.Confirm()
input.Press(keys.Universal.DiffingMenu)
input.Menu(Equals("Diffing"), Contains("exit diff mode"))
assert.ViewContent("information", NotContains("building patch"))
input.PressKeys(keys.Universal.CreatePatchOptionsMenu)
assert.InMenu()
assert.CurrentViewTitle(Equals("Patch Options"))
// including the keybinding 'a' here to distinguish the menu item from the 'apply patch in reverse' item
input.NavigateToListItemContainingText("a apply patch")
input.Confirm()
input.Press(keys.Universal.CreatePatchOptionsMenu)
// adding the regex '$' here to distinguish the menu item from the 'apply patch in reverse' item
input.Menu(Equals("Patch Options"), MatchesRegexp("apply patch$"))
input.SwitchToFilesWindow()

View File

@@ -24,11 +24,9 @@ var DiffCommits = NewIntegrationTest(NewIntegrationTestArgs{
assert.SelectedLine(Contains("third commit"))
input.PressKeys(keys.Universal.DiffingMenu)
assert.InMenu()
assert.CurrentViewTitle(Equals("Diffing"))
assert.SelectedLine(Contains("diff"))
input.Confirm()
input.Press(keys.Universal.DiffingMenu)
input.Menu(Equals("Diffing"), MatchesRegexp(`diff \w+`))
assert.NotInPopup()
assert.ViewContent("information", Contains("showing output for: git diff"))
@@ -40,10 +38,9 @@ var DiffCommits = NewIntegrationTest(NewIntegrationTestArgs{
assert.MainViewContent(Contains("-second line\n-third line"))
input.PressKeys(keys.Universal.DiffingMenu)
assert.InMenu()
input.NavigateToListItemContainingText("reverse diff direction")
input.Confirm()
input.Press(keys.Universal.DiffingMenu)
input.Menu(Equals("Diffing"), Contains("reverse diff direction"))
assert.NotInPopup()
assert.MainViewContent(Contains("+second line\n+third line"))

View File

@@ -75,47 +75,47 @@ var DiscardChanges = NewIntegrationTest(NewIntegrationTestArgs{
assert.CommitCount(3)
type statusFile struct {
status string
path string
status string
label string
menuTitle string
}
discardOneByOne := func(files []statusFile) {
for _, file := range files {
assert.SelectedLine(Contains(file.status + " " + file.path))
input.PressKeys(keys.Universal.Remove)
assert.InMenu()
assert.CurrentViewContent(Contains("discard all changes"))
input.Confirm()
assert.SelectedLine(Contains(file.status + " " + file.label))
input.Press(keys.Universal.Remove)
input.Menu(Equals(file.menuTitle), Contains("discard all changes"))
}
}
discardOneByOne([]statusFile{
{"UA", "added-them-changed-us.txt"},
{"AA", "both-added.txt"},
{"DD", "both-deleted.txt"},
{"UU", "both-modded.txt"},
{"AU", "changed-them-added-us.txt"},
{"UD", "deleted-them.txt"},
{"DU", "deleted-us.txt"},
{status: "UA", label: "added-them-changed-us.txt", menuTitle: "added-them-changed-us.txt"},
{status: "AA", label: "both-added.txt", menuTitle: "both-added.txt"},
{status: "DD", label: "both-deleted.txt", menuTitle: "both-deleted.txt"},
{status: "UU", label: "both-modded.txt", menuTitle: "both-modded.txt"},
{status: "AU", label: "changed-them-added-us.txt", menuTitle: "changed-them-added-us.txt"},
{status: "UD", label: "deleted-them.txt", menuTitle: "deleted-them.txt"},
{status: "DU", label: "deleted-us.txt", menuTitle: "deleted-us.txt"},
})
assert.InConfirm()
assert.CurrentViewTitle(Contains("continue"))
assert.CurrentViewContent(Contains("all merge conflicts resolved. Continue?"))
input.PressKeys(keys.Universal.Return)
input.Press(keys.Universal.Return)
discardOneByOne([]statusFile{
{"MD", "change-delete.txt"},
{"D ", "delete-change.txt"},
{"D ", "deleted-staged.txt"},
{" D", "deleted.txt"},
{"MM", "double-modded.txt"},
{"M ", "modded-staged.txt"},
{" M", "modded.txt"},
{"R ", "renamed.txt → renamed2.txt"},
{"AM", "added-changed.txt"},
{"A ", "new-staged.txt"},
{"??", "new.txt"},
{status: "MD", label: "change-delete.txt", menuTitle: "change-delete.txt"},
{status: "D ", label: "delete-change.txt", menuTitle: "delete-change.txt"},
{status: "D ", label: "deleted-staged.txt", menuTitle: "deleted-staged.txt"},
{status: " D", label: "deleted.txt", menuTitle: "deleted.txt"},
{status: "MM", label: "double-modded.txt", menuTitle: "double-modded.txt"},
{status: "M ", label: "modded-staged.txt", menuTitle: "modded-staged.txt"},
{status: " M", label: "modded.txt", menuTitle: "modded.txt"},
// the menu title only includes the new file
{status: "R ", label: "renamed.txt → renamed2.txt", menuTitle: "renamed2.txt"},
{status: "AM", label: "added-changed.txt", menuTitle: "added-changed.txt"},
{status: "A ", label: "new-staged.txt", menuTitle: "new-staged.txt"},
{status: "??", label: "new.txt", menuTitle: "new.txt"},
})
assert.WorkingTreeFileCount(0)

View File

@@ -36,8 +36,8 @@ var AmendMerge = NewIntegrationTest(NewIntegrationTestArgs{
mergeCommitMessage := "Merge branch 'feature-branch' into development-branch"
assert.HeadCommitMessage(Contains(mergeCommitMessage))
input.PressKeys(keys.Commits.AmendToCommit)
input.ProceedWhenAsked(Contains("Are you sure you want to amend this commit with your staged files?"))
input.Press(keys.Commits.AmendToCommit)
input.AcceptConfirmation(Equals("Amend Commit"), Contains("Are you sure you want to amend this commit with your staged files?"))
// assuring we haven't added a brand new commit
assert.CommitCount(3)

View File

@@ -18,20 +18,20 @@ var One = NewIntegrationTest(NewIntegrationTestArgs{
input.SwitchToCommitsWindow()
assert.CurrentViewName("commits")
input.NavigateToListItemContainingText("commit 02")
input.PressKeys(keys.Universal.Edit)
input.NavigateToListItem(Contains("commit 02"))
input.Press(keys.Universal.Edit)
assert.SelectedLine(Contains("YOU ARE HERE"))
input.PreviousItem()
input.PressKeys(keys.Commits.MarkCommitAsFixup)
input.Press(keys.Commits.MarkCommitAsFixup)
assert.SelectedLine(Contains("fixup"))
input.PreviousItem()
input.PressKeys(keys.Universal.Remove)
input.Press(keys.Universal.Remove)
assert.SelectedLine(Contains("drop"))
input.PreviousItem()
input.PressKeys(keys.Commits.SquashDown)
input.Press(keys.Commits.SquashDown)
assert.SelectedLine(Contains("squash"))
input.ContinueRebase()

View File

@@ -11,15 +11,12 @@ var ConfirmOnQuit = NewIntegrationTest(NewIntegrationTestArgs{
Skip: false,
SetupConfig: func(config *config.AppConfig) {
config.UserConfig.ConfirmOnQuit = true
config.UserConfig.Gui.Theme.ActiveBorderColor = []string{"red"}
},
SetupRepo: func(shell *Shell) {},
Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
assert.CommitCount(0)
input.PressKeys(keys.Universal.Quit)
assert.InConfirm()
assert.CurrentViewContent(Contains("Are you sure you want to quit?"))
input.Confirm()
input.Press(keys.Universal.Quit)
input.AcceptConfirmation(Equals(""), Contains("Are you sure you want to quit?"))
},
})

View File

@@ -25,12 +25,9 @@ var Rename = NewIntegrationTest(NewIntegrationTestArgs{
assert.SelectedLine(Equals("On master: bar"))
input.NextItem()
assert.SelectedLine(Equals("On master: foo"))
input.PressKeys(keys.Stash.RenameStash)
assert.InPrompt()
assert.CurrentViewTitle(Equals("Rename stash: stash@{1}"))
input.Press(keys.Stash.RenameStash)
input.Type(" baz")
input.Confirm()
input.Prompt(Equals("Rename stash: stash@{1}"), " baz")
assert.SelectedLine(Equals("On master: foo baz"))
},

View File

@@ -19,15 +19,12 @@ var Stash = NewIntegrationTest(NewIntegrationTestArgs{
assert.StashCount(0)
assert.WorkingTreeFileCount(1)
input.PressKeys(keys.Files.ViewStashOptions)
assert.InMenu()
input.Press(keys.Files.ViewStashOptions)
input.PressKeys("a")
assert.InPrompt()
assert.CurrentViewTitle(Equals("Stash changes"))
input.Menu(Equals("Stash options"), MatchesRegexp("stash all changes$"))
input.Prompt(Equals("Stash changes"), "my stashed file")
input.Type("my stashed file")
input.Confirm()
assert.StashCount(1)
assert.WorkingTreeFileCount(0)
},

View File

@@ -20,15 +20,12 @@ var StashIncludingUntrackedFiles = NewIntegrationTest(NewIntegrationTestArgs{
assert.StashCount(0)
assert.WorkingTreeFileCount(2)
input.PressKeys(keys.Files.ViewStashOptions)
assert.InMenu()
input.Press(keys.Files.ViewStashOptions)
input.PressKeys("U")
assert.InPrompt()
assert.CurrentViewTitle(Equals("Stash changes"))
input.Menu(Equals("Stash options"), Contains("stash all changes including untracked files"))
input.Prompt(Equals("Stash changes"), "my stashed file")
input.Type("my stashed file")
input.Confirm()
assert.StashCount(1)
assert.WorkingTreeFileCount(0)
},

View File

@@ -45,7 +45,6 @@ var tests = []*components.IntegrationTest{
commit.Staged,
commit.Unstaged,
commit.StagedWithoutHooks,
commit.UnstagedWithoutHooks,
custom_commands.Basic,
custom_commands.FormPrompts,
custom_commands.MenuFromCommand,