mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-13 22:17:05 +02:00
combine assert and input structs, clean up interface
This commit is contained in:
parent
c5c9f5bb94
commit
b166b8f776
@ -48,8 +48,8 @@ Try to do as much setup work as possible in your setup step. For example, if all
|
||||
Use assertions to ensure that lazygit has processed all your keybindings so far. Each time you press a key, something should happen on the screen, so you should assert that that thing has happened. This means we won't get into trouble from keys being entered two quickly because at each stage we ensure the key has been processed. This also makes tests more readable because they help explain what we expect to be happening on-screen. For example:
|
||||
|
||||
```go
|
||||
input.Press(keys.Files.CommitChanges)
|
||||
assert.InCommitMessagePanel()
|
||||
input.press(keys.Files.CommitChanges)
|
||||
input.InCommitMessagePanel()
|
||||
```
|
||||
|
||||
Note that there are some `input` methods that have assertions baked in, such as the `SwitchToView` methods.
|
||||
|
@ -1,14 +1,13 @@
|
||||
package components
|
||||
|
||||
type AlertAsserter struct {
|
||||
assert *Assert
|
||||
input *Input
|
||||
hasCheckedTitle bool
|
||||
hasCheckedContent bool
|
||||
}
|
||||
|
||||
func (self *AlertAsserter) getViewAsserter() *View {
|
||||
return self.assert.Views().ByName("confirmation")
|
||||
return self.input.Views().Confirmation()
|
||||
}
|
||||
|
||||
// asserts that the alert view has the expected title
|
||||
@ -32,17 +31,17 @@ func (self *AlertAsserter) Content(expected *matcher) *AlertAsserter {
|
||||
func (self *AlertAsserter) Confirm() {
|
||||
self.checkNecessaryChecksCompleted()
|
||||
|
||||
self.input.Confirm()
|
||||
self.getViewAsserter().PressEnter()
|
||||
}
|
||||
|
||||
func (self *AlertAsserter) Cancel() {
|
||||
self.checkNecessaryChecksCompleted()
|
||||
|
||||
self.input.Press(self.input.keys.Universal.Return)
|
||||
self.getViewAsserter().PressEscape()
|
||||
}
|
||||
|
||||
func (self *AlertAsserter) checkNecessaryChecksCompleted() {
|
||||
if !self.hasCheckedContent || !self.hasCheckedTitle {
|
||||
self.assert.Fail("You must both check the content and title of a confirmation popup by calling Title()/Content() before calling Confirm()/Cancel().")
|
||||
self.input.Fail("You must both check the content and title of a confirmation popup by calling Title()/Content() before calling Confirm()/Cancel().")
|
||||
}
|
||||
}
|
||||
|
@ -1,38 +0,0 @@
|
||||
package components
|
||||
|
||||
import (
|
||||
integrationTypes "github.com/jesseduffield/lazygit/pkg/integration/types"
|
||||
)
|
||||
|
||||
// through this struct we assert on the state of the lazygit gui
|
||||
|
||||
type Assert struct {
|
||||
input *Input
|
||||
gui integrationTypes.GuiDriver
|
||||
*assertionHelper
|
||||
}
|
||||
|
||||
func NewAssert(gui integrationTypes.GuiDriver) *Assert {
|
||||
return &Assert{gui: gui}
|
||||
}
|
||||
|
||||
// for making assertions on lazygit views
|
||||
func (self *Assert) Views() *Views {
|
||||
return &Views{assert: self, input: self.input}
|
||||
}
|
||||
|
||||
// for making assertions on the lazygit model
|
||||
func (self *Assert) Model() *Model {
|
||||
return &Model{assertionHelper: self.assertionHelper, gui: self.gui}
|
||||
}
|
||||
|
||||
// for making assertions on the file system
|
||||
func (self *Assert) FileSystem() *FileSystem {
|
||||
return &FileSystem{assertionHelper: self.assertionHelper}
|
||||
}
|
||||
|
||||
// for when you just want to fail the test yourself.
|
||||
// This runs callbacks to ensure we render the error after closing the gui.
|
||||
func (self *Assert) Fail(message string) {
|
||||
self.assertionHelper.fail(message)
|
||||
}
|
@ -1,12 +1,11 @@
|
||||
package components
|
||||
|
||||
type CommitMessagePanelAsserter struct {
|
||||
assert *Assert
|
||||
input *Input
|
||||
input *Input
|
||||
}
|
||||
|
||||
func (self *CommitMessagePanelAsserter) getViewAsserter() *View {
|
||||
return self.assert.Views().ByName("commitMessage")
|
||||
return self.input.Views().CommitMessage()
|
||||
}
|
||||
|
||||
// asserts on the text initially present in the prompt
|
||||
@ -17,13 +16,13 @@ func (self *CommitMessagePanelAsserter) InitialText(expected *matcher) *CommitMe
|
||||
}
|
||||
|
||||
func (self *CommitMessagePanelAsserter) Type(value string) *CommitMessagePanelAsserter {
|
||||
self.input.Type(value)
|
||||
self.input.typeContent(value)
|
||||
|
||||
return self
|
||||
}
|
||||
|
||||
func (self *CommitMessagePanelAsserter) AddNewline() *CommitMessagePanelAsserter {
|
||||
self.input.Press(self.input.keys.Universal.AppendNewline)
|
||||
self.input.press(self.input.keys.Universal.AppendNewline)
|
||||
|
||||
return self
|
||||
}
|
||||
@ -33,9 +32,9 @@ func (self *CommitMessagePanelAsserter) Clear() *CommitMessagePanelAsserter {
|
||||
}
|
||||
|
||||
func (self *CommitMessagePanelAsserter) Confirm() {
|
||||
self.input.Confirm()
|
||||
self.getViewAsserter().PressEnter()
|
||||
}
|
||||
|
||||
func (self *CommitMessagePanelAsserter) Cancel() {
|
||||
self.input.Press(self.input.keys.Universal.Return)
|
||||
self.getViewAsserter().PressEscape()
|
||||
}
|
||||
|
@ -1,14 +1,13 @@
|
||||
package components
|
||||
|
||||
type ConfirmationAsserter struct {
|
||||
assert *Assert
|
||||
input *Input
|
||||
hasCheckedTitle bool
|
||||
hasCheckedContent bool
|
||||
}
|
||||
|
||||
func (self *ConfirmationAsserter) getViewAsserter() *View {
|
||||
return self.assert.Views().ByName("confirmation")
|
||||
return self.input.Views().Confirmation()
|
||||
}
|
||||
|
||||
// asserts that the confirmation view has the expected title
|
||||
@ -32,17 +31,17 @@ func (self *ConfirmationAsserter) Content(expected *matcher) *ConfirmationAssert
|
||||
func (self *ConfirmationAsserter) Confirm() {
|
||||
self.checkNecessaryChecksCompleted()
|
||||
|
||||
self.input.Confirm()
|
||||
self.getViewAsserter().PressEnter()
|
||||
}
|
||||
|
||||
func (self *ConfirmationAsserter) Cancel() {
|
||||
self.checkNecessaryChecksCompleted()
|
||||
|
||||
self.input.Press(self.input.keys.Universal.Return)
|
||||
self.getViewAsserter().PressEscape()
|
||||
}
|
||||
|
||||
func (self *ConfirmationAsserter) checkNecessaryChecksCompleted() {
|
||||
if !self.hasCheckedContent || !self.hasCheckedTitle {
|
||||
self.assert.Fail("You must both check the content and title of a confirmation popup by calling Title()/Content() before calling Confirm()/Cancel().")
|
||||
self.input.Fail("You must both check the content and title of a confirmation popup by calling Title()/Content() before calling Confirm()/Cancel().")
|
||||
}
|
||||
}
|
||||
|
@ -8,14 +8,14 @@ import (
|
||||
"github.com/jesseduffield/lazygit/pkg/config"
|
||||
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
||||
integrationTypes "github.com/jesseduffield/lazygit/pkg/integration/types"
|
||||
"github.com/samber/lo"
|
||||
)
|
||||
|
||||
type Input struct {
|
||||
gui integrationTypes.GuiDriver
|
||||
keys config.KeybindingConfig
|
||||
assert *Assert
|
||||
*assertionHelper
|
||||
gui integrationTypes.GuiDriver
|
||||
keys config.KeybindingConfig
|
||||
pushKeyDelay int
|
||||
*assertionHelper
|
||||
}
|
||||
|
||||
func NewInput(gui integrationTypes.GuiDriver, keys config.KeybindingConfig, pushKeyDelay int) *Input {
|
||||
@ -23,119 +23,31 @@ func NewInput(gui integrationTypes.GuiDriver, keys config.KeybindingConfig, push
|
||||
gui: gui,
|
||||
keys: keys,
|
||||
pushKeyDelay: pushKeyDelay,
|
||||
assertionHelper: assert.assertionHelper,
|
||||
assertionHelper: &assertionHelper{gui: gui},
|
||||
}
|
||||
}
|
||||
|
||||
// key is something like 'w' or '<space>'. It's best not to pass a direct value,
|
||||
// but instead to go through the default user config to get a more meaningful key name
|
||||
func (self *Input) Press(keyStrs ...string) {
|
||||
for _, keyStr := range keyStrs {
|
||||
self.press(keyStr)
|
||||
}
|
||||
}
|
||||
|
||||
func (self *Input) press(keyStr string) {
|
||||
self.Wait(self.pushKeyDelay)
|
||||
|
||||
self.gui.PressKey(keyStr)
|
||||
}
|
||||
|
||||
func (self *Input) SwitchToStatusWindow() {
|
||||
self.press(self.keys.Universal.JumpToBlock[0])
|
||||
self.currentWindowName("status")
|
||||
}
|
||||
|
||||
// switch to status window and assert that the status view is on top
|
||||
func (self *Input) SwitchToStatusView() {
|
||||
self.SwitchToStatusWindow()
|
||||
self.assert.Views().Current().Name("status")
|
||||
}
|
||||
|
||||
func (self *Input) switchToFilesWindow() {
|
||||
self.press(self.keys.Universal.JumpToBlock[1])
|
||||
self.currentWindowName("files")
|
||||
}
|
||||
|
||||
// switch to files window and assert that the files view is on top
|
||||
func (self *Input) SwitchToFilesView() {
|
||||
self.switchToFilesWindow()
|
||||
self.assert.Views().Current().Name("files")
|
||||
}
|
||||
|
||||
func (self *Input) SwitchToBranchesWindow() {
|
||||
self.press(self.keys.Universal.JumpToBlock[2])
|
||||
self.currentWindowName("localBranches")
|
||||
}
|
||||
|
||||
// switch to branches window and assert that the branches view is on top
|
||||
func (self *Input) SwitchToBranchesView() {
|
||||
self.SwitchToBranchesWindow()
|
||||
self.assert.Views().Current().Name("localBranches")
|
||||
}
|
||||
|
||||
func (self *Input) SwitchToCommitsWindow() {
|
||||
self.press(self.keys.Universal.JumpToBlock[3])
|
||||
self.currentWindowName("commits")
|
||||
}
|
||||
|
||||
// switch to commits window and assert that the commits view is on top
|
||||
func (self *Input) SwitchToCommitsView() {
|
||||
self.SwitchToCommitsWindow()
|
||||
self.assert.Views().Current().Name("commits")
|
||||
}
|
||||
|
||||
func (self *Input) SwitchToStashWindow() {
|
||||
self.press(self.keys.Universal.JumpToBlock[4])
|
||||
self.currentWindowName("stash")
|
||||
}
|
||||
|
||||
// switch to stash window and assert that the stash view is on top
|
||||
func (self *Input) SwitchToStashView() {
|
||||
self.SwitchToStashWindow()
|
||||
self.assert.Views().Current().Name("stash")
|
||||
}
|
||||
|
||||
func (self *Input) Type(content string) {
|
||||
func (self *Input) typeContent(content string) {
|
||||
for _, char := range content {
|
||||
self.press(string(char))
|
||||
}
|
||||
}
|
||||
|
||||
// i.e. pressing enter
|
||||
func (self *Input) Confirm() {
|
||||
self.press(self.keys.Universal.Confirm)
|
||||
}
|
||||
|
||||
// i.e. same as Confirm
|
||||
func (self *Input) Enter() {
|
||||
self.press(self.keys.Universal.Confirm)
|
||||
}
|
||||
|
||||
// i.e. pressing escape
|
||||
func (self *Input) Cancel() {
|
||||
self.press(self.keys.Universal.Return)
|
||||
}
|
||||
|
||||
// i.e. pressing space
|
||||
func (self *Input) PrimaryAction() {
|
||||
self.press(self.keys.Universal.Select)
|
||||
}
|
||||
|
||||
// i.e. pressing down arrow
|
||||
func (self *Input) NextItem() {
|
||||
self.press(self.keys.Universal.NextItem)
|
||||
}
|
||||
|
||||
// i.e. pressing up arrow
|
||||
func (self *Input) PreviousItem() {
|
||||
self.press(self.keys.Universal.PrevItem)
|
||||
}
|
||||
|
||||
func (self *Input) ContinueMerge() {
|
||||
self.Press(self.keys.Universal.CreateRebaseOptionsMenu)
|
||||
self.assert.Views().Current().SelectedLine(Contains("continue"))
|
||||
self.Confirm()
|
||||
self.Views().current().Press(self.keys.Universal.CreateRebaseOptionsMenu)
|
||||
|
||||
self.ExpectMenu().
|
||||
Title(Equals("Rebase Options")).
|
||||
Select(Contains("continue")).
|
||||
Confirm()
|
||||
}
|
||||
|
||||
func (self *Input) ContinueRebase() {
|
||||
@ -166,7 +78,7 @@ func (self *Input) Log(message string) {
|
||||
// If this changes in future, we'll need to update this code to first attempt to find the item
|
||||
// in the current page and failing that, jump to the top of the view and iterate through all of it,
|
||||
// looking for the item.
|
||||
func (self *Input) NavigateToListItem(matcher *matcher) {
|
||||
func (self *Input) navigateToListItem(matcher *matcher) {
|
||||
self.inListContext()
|
||||
|
||||
currentContext := self.gui.CurrentContext().(types.IListContext)
|
||||
@ -175,7 +87,7 @@ func (self *Input) NavigateToListItem(matcher *matcher) {
|
||||
|
||||
var matchIndex int
|
||||
|
||||
self.assert.assertWithRetries(func() (bool, string) {
|
||||
self.assertWithRetries(func() (bool, string) {
|
||||
matchIndex = -1
|
||||
var matches []string
|
||||
lines := view.ViewBufferLines()
|
||||
@ -198,20 +110,20 @@ func (self *Input) NavigateToListItem(matcher *matcher) {
|
||||
|
||||
selectedLineIdx := view.SelectedLineIdx()
|
||||
if selectedLineIdx == matchIndex {
|
||||
self.assert.Views().Current().SelectedLine(matcher)
|
||||
self.Views().current().SelectedLine(matcher)
|
||||
return
|
||||
}
|
||||
if selectedLineIdx < matchIndex {
|
||||
for i := selectedLineIdx; i < matchIndex; i++ {
|
||||
self.NextItem()
|
||||
self.Views().current().SelectNextItem()
|
||||
}
|
||||
self.assert.Views().Current().SelectedLine(matcher)
|
||||
self.Views().current().SelectedLine(matcher)
|
||||
return
|
||||
} else {
|
||||
for i := selectedLineIdx; i > matchIndex; i-- {
|
||||
self.PreviousItem()
|
||||
self.Views().current().SelectPreviousItem()
|
||||
}
|
||||
self.assert.Views().Current().SelectedLine(matcher)
|
||||
self.Views().current().SelectedLine(matcher)
|
||||
return
|
||||
}
|
||||
}
|
||||
@ -224,10 +136,10 @@ func (self *Input) inListContext() {
|
||||
})
|
||||
}
|
||||
|
||||
func (self *Input) Confirmation() *ConfirmationAsserter {
|
||||
func (self *Input) ExpectConfirmation() *ConfirmationAsserter {
|
||||
self.inConfirm()
|
||||
|
||||
return &ConfirmationAsserter{assert: self.assert, input: self}
|
||||
return &ConfirmationAsserter{input: self}
|
||||
}
|
||||
|
||||
func (self *Input) inConfirm() {
|
||||
@ -237,10 +149,10 @@ func (self *Input) inConfirm() {
|
||||
})
|
||||
}
|
||||
|
||||
func (self *Input) Prompt() *PromptAsserter {
|
||||
func (self *Input) ExpectPrompt() *PromptAsserter {
|
||||
self.inPrompt()
|
||||
|
||||
return &PromptAsserter{assert: self.assert, input: self}
|
||||
return &PromptAsserter{input: self}
|
||||
}
|
||||
|
||||
func (self *Input) inPrompt() {
|
||||
@ -250,10 +162,10 @@ func (self *Input) inPrompt() {
|
||||
})
|
||||
}
|
||||
|
||||
func (self *Input) Alert() *AlertAsserter {
|
||||
func (self *Input) ExpectAlert() *AlertAsserter {
|
||||
self.inAlert()
|
||||
|
||||
return &AlertAsserter{assert: self.assert, input: self}
|
||||
return &AlertAsserter{input: self}
|
||||
}
|
||||
|
||||
func (self *Input) inAlert() {
|
||||
@ -264,10 +176,10 @@ func (self *Input) inAlert() {
|
||||
})
|
||||
}
|
||||
|
||||
func (self *Input) Menu() *MenuAsserter {
|
||||
func (self *Input) ExpectMenu() *MenuAsserter {
|
||||
self.inMenu()
|
||||
|
||||
return &MenuAsserter{assert: self.assert, input: self}
|
||||
return &MenuAsserter{input: self}
|
||||
}
|
||||
|
||||
func (self *Input) inMenu() {
|
||||
@ -276,10 +188,10 @@ func (self *Input) inMenu() {
|
||||
})
|
||||
}
|
||||
|
||||
func (self *Input) CommitMessagePanel() *CommitMessagePanelAsserter {
|
||||
func (self *Input) ExpectCommitMessagePanel() *CommitMessagePanelAsserter {
|
||||
self.inCommitMessagePanel()
|
||||
|
||||
return &CommitMessagePanelAsserter{assert: self.assert, input: self}
|
||||
return &CommitMessagePanelAsserter{input: self}
|
||||
}
|
||||
|
||||
func (self *Input) inCommitMessagePanel() {
|
||||
@ -295,3 +207,31 @@ func (self *Input) currentWindowName(expectedWindowName string) {
|
||||
return actual == expectedWindowName, fmt.Sprintf("Expected current window name to be '%s', but got '%s'", expectedWindowName, actual)
|
||||
})
|
||||
}
|
||||
|
||||
// for making assertions on lazygit views
|
||||
func (self *Input) Views() *Views {
|
||||
return &Views{input: self}
|
||||
}
|
||||
|
||||
// for making assertions on the lazygit model
|
||||
func (self *Input) Model() *Model {
|
||||
return &Model{assertionHelper: self.assertionHelper, gui: self.gui}
|
||||
}
|
||||
|
||||
// for making assertions on the file system
|
||||
func (self *Input) FileSystem() *FileSystem {
|
||||
return &FileSystem{assertionHelper: self.assertionHelper}
|
||||
}
|
||||
|
||||
// for when you just want to fail the test yourself.
|
||||
// This runs callbacks to ensure we render the error after closing the gui.
|
||||
func (self *Input) Fail(message string) {
|
||||
self.assertionHelper.fail(message)
|
||||
}
|
||||
|
||||
func (self *Input) NotInPopup() {
|
||||
self.assertWithRetries(func() (bool, string) {
|
||||
viewName := self.gui.CurrentContext().GetView().Name()
|
||||
return !lo.Contains([]string{"menu", "confirmation", "commitMessage"}, viewName), fmt.Sprintf("Unexpected popup view present: %s view", viewName)
|
||||
})
|
||||
}
|
||||
|
@ -1,13 +1,12 @@
|
||||
package components
|
||||
|
||||
type MenuAsserter struct {
|
||||
assert *Assert
|
||||
input *Input
|
||||
hasCheckedTitle bool
|
||||
}
|
||||
|
||||
func (self *MenuAsserter) getViewAsserter() *View {
|
||||
return self.assert.Views().ByName("menu")
|
||||
return self.input.Views().Menu()
|
||||
}
|
||||
|
||||
// asserts that the popup has the expected title
|
||||
@ -22,23 +21,23 @@ func (self *MenuAsserter) Title(expected *matcher) *MenuAsserter {
|
||||
func (self *MenuAsserter) Confirm() {
|
||||
self.checkNecessaryChecksCompleted()
|
||||
|
||||
self.input.Confirm()
|
||||
self.getViewAsserter().PressEnter()
|
||||
}
|
||||
|
||||
func (self *MenuAsserter) Cancel() {
|
||||
self.checkNecessaryChecksCompleted()
|
||||
|
||||
self.input.Press(self.input.keys.Universal.Return)
|
||||
self.getViewAsserter().PressEscape()
|
||||
}
|
||||
|
||||
func (self *MenuAsserter) Select(option *matcher) *MenuAsserter {
|
||||
self.input.NavigateToListItem(option)
|
||||
self.getViewAsserter().NavigateToListItem(option)
|
||||
|
||||
return self
|
||||
}
|
||||
|
||||
func (self *MenuAsserter) checkNecessaryChecksCompleted() {
|
||||
if !self.hasCheckedTitle {
|
||||
self.assert.Fail("You must check the title of a menu popup by calling Title() before calling Confirm()/Cancel().")
|
||||
self.input.Fail("You must check the title of a menu popup by calling Title() before calling Confirm()/Cancel().")
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ type Model struct {
|
||||
gui integrationTypes.GuiDriver
|
||||
}
|
||||
|
||||
func (self *Model) WorkingTreeFileCount(expectedCount int) {
|
||||
func (self *Model) WorkingTreeFileCount(expectedCount int) *Model {
|
||||
self.assertWithRetries(func() (bool, string) {
|
||||
actualCount := len(self.gui.Model().Files)
|
||||
|
||||
@ -20,9 +20,11 @@ func (self *Model) WorkingTreeFileCount(expectedCount int) {
|
||||
expectedCount, actualCount,
|
||||
)
|
||||
})
|
||||
|
||||
return self
|
||||
}
|
||||
|
||||
func (self *Model) CommitCount(expectedCount int) {
|
||||
func (self *Model) CommitCount(expectedCount int) *Model {
|
||||
self.assertWithRetries(func() (bool, string) {
|
||||
actualCount := len(self.gui.Model().Commits)
|
||||
|
||||
@ -31,9 +33,11 @@ func (self *Model) CommitCount(expectedCount int) {
|
||||
expectedCount, actualCount,
|
||||
)
|
||||
})
|
||||
|
||||
return self
|
||||
}
|
||||
|
||||
func (self *Model) StashCount(expectedCount int) {
|
||||
func (self *Model) StashCount(expectedCount int) *Model {
|
||||
self.assertWithRetries(func() (bool, string) {
|
||||
actualCount := len(self.gui.Model().StashEntries)
|
||||
|
||||
@ -42,17 +46,21 @@ func (self *Model) StashCount(expectedCount int) {
|
||||
expectedCount, actualCount,
|
||||
)
|
||||
})
|
||||
|
||||
return self
|
||||
}
|
||||
|
||||
func (self *Model) AtLeastOneCommit() {
|
||||
func (self *Model) AtLeastOneCommit() *Model {
|
||||
self.assertWithRetries(func() (bool, string) {
|
||||
actualCount := len(self.gui.Model().Commits)
|
||||
|
||||
return actualCount > 0, "Expected at least one commit present"
|
||||
})
|
||||
|
||||
return self
|
||||
}
|
||||
|
||||
func (self *Model) HeadCommitMessage(matcher *matcher) {
|
||||
func (self *Model) HeadCommitMessage(matcher *matcher) *Model {
|
||||
self.assertWithRetries(func() (bool, string) {
|
||||
return len(self.gui.Model().Commits) > 0, "Expected at least one commit to be present"
|
||||
})
|
||||
@ -62,11 +70,15 @@ func (self *Model) HeadCommitMessage(matcher *matcher) {
|
||||
return self.gui.Model().Commits[0].Name
|
||||
},
|
||||
)
|
||||
|
||||
return self
|
||||
}
|
||||
|
||||
func (self *Model) CurrentBranchName(expectedViewName string) {
|
||||
func (self *Model) CurrentBranchName(expectedViewName string) *Model {
|
||||
self.assertWithRetries(func() (bool, string) {
|
||||
actual := self.gui.CheckedOutRef().Name
|
||||
return actual == expectedViewName, fmt.Sprintf("Expected current branch name to be '%s', but got '%s'", expectedViewName, actual)
|
||||
})
|
||||
|
||||
return self
|
||||
}
|
||||
|
@ -1,13 +1,12 @@
|
||||
package components
|
||||
|
||||
type PromptAsserter struct {
|
||||
assert *Assert
|
||||
input *Input
|
||||
hasCheckedTitle bool
|
||||
}
|
||||
|
||||
func (self *PromptAsserter) getViewAsserter() *View {
|
||||
return self.assert.Views().ByName("confirmation")
|
||||
return self.input.Views().Confirmation()
|
||||
}
|
||||
|
||||
// asserts that the popup has the expected title
|
||||
@ -27,7 +26,7 @@ func (self *PromptAsserter) InitialText(expected *matcher) *PromptAsserter {
|
||||
}
|
||||
|
||||
func (self *PromptAsserter) Type(value string) *PromptAsserter {
|
||||
self.input.Type(value)
|
||||
self.input.typeContent(value)
|
||||
|
||||
return self
|
||||
}
|
||||
@ -39,45 +38,47 @@ func (self *PromptAsserter) Clear() *PromptAsserter {
|
||||
func (self *PromptAsserter) Confirm() {
|
||||
self.checkNecessaryChecksCompleted()
|
||||
|
||||
self.input.Confirm()
|
||||
self.getViewAsserter().PressEnter()
|
||||
}
|
||||
|
||||
func (self *PromptAsserter) Cancel() {
|
||||
self.checkNecessaryChecksCompleted()
|
||||
|
||||
self.input.Press(self.input.keys.Universal.Return)
|
||||
self.getViewAsserter().PressEscape()
|
||||
}
|
||||
|
||||
func (self *PromptAsserter) checkNecessaryChecksCompleted() {
|
||||
if !self.hasCheckedTitle {
|
||||
self.assert.Fail("You must check the title of a prompt popup by calling Title() before calling Confirm()/Cancel().")
|
||||
self.input.Fail("You must check the title of a prompt popup by calling Title() before calling Confirm()/Cancel().")
|
||||
}
|
||||
}
|
||||
|
||||
func (self *PromptAsserter) SuggestionLines(matchers ...*matcher) *PromptAsserter {
|
||||
self.assert.Views().ByName("suggestions").Lines(matchers...)
|
||||
self.input.Views().Suggestions().Lines(matchers...)
|
||||
|
||||
return self
|
||||
}
|
||||
|
||||
func (self *PromptAsserter) SuggestionTopLines(matchers ...*matcher) *PromptAsserter {
|
||||
self.assert.Views().ByName("suggestions").TopLines(matchers...)
|
||||
self.input.Views().Suggestions().TopLines(matchers...)
|
||||
|
||||
return self
|
||||
}
|
||||
|
||||
func (self *PromptAsserter) SelectFirstSuggestion() *PromptAsserter {
|
||||
self.input.Press(self.input.keys.Universal.TogglePanel)
|
||||
self.assert.Views().Current().Name("suggestions")
|
||||
self.input.press(self.input.keys.Universal.TogglePanel)
|
||||
self.input.Views().Suggestions().
|
||||
IsFocused().
|
||||
SelectedLineIdx(0)
|
||||
|
||||
return self
|
||||
}
|
||||
|
||||
func (self *PromptAsserter) SelectSuggestion(matcher *matcher) *PromptAsserter {
|
||||
self.input.Press(self.input.keys.Universal.TogglePanel)
|
||||
self.assert.Views().Current().Name("suggestions")
|
||||
|
||||
self.input.NavigateToListItem(matcher)
|
||||
self.input.press(self.input.keys.Universal.TogglePanel)
|
||||
self.input.Views().Suggestions().
|
||||
IsFocused().
|
||||
NavigateToListItem(matcher)
|
||||
|
||||
return self
|
||||
}
|
||||
|
@ -26,7 +26,6 @@ type IntegrationTest struct {
|
||||
run func(
|
||||
shell *Shell,
|
||||
input *Input,
|
||||
assert *Assert,
|
||||
keys config.KeybindingConfig,
|
||||
)
|
||||
}
|
||||
@ -41,7 +40,7 @@ type NewIntegrationTestArgs struct {
|
||||
// takes a config and mutates. The mutated context will end up being passed to the gui
|
||||
SetupConfig func(config *config.AppConfig)
|
||||
// runs the test
|
||||
Run func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig)
|
||||
Run func(shell *Shell, input *Input, keys config.KeybindingConfig)
|
||||
// additional args passed to lazygit
|
||||
ExtraCmdArgs string
|
||||
// for when a test is flakey
|
||||
@ -94,11 +93,10 @@ func (self *IntegrationTest) SetupRepo(shell *Shell) {
|
||||
// I want access to all contexts, the model, the ability to press a key, the ability to log,
|
||||
func (self *IntegrationTest) Run(gui integrationTypes.GuiDriver) {
|
||||
shell := NewShell("/tmp/lazygit-test")
|
||||
assert := NewAssert(gui)
|
||||
keys := gui.Keys()
|
||||
input := NewInput(gui, keys, assert, KeyPressDelay())
|
||||
input := NewInput(gui, keys, KeyPressDelay())
|
||||
|
||||
self.run(shell, input, assert, keys)
|
||||
self.run(shell, input, keys)
|
||||
|
||||
if KeyPressDelay() > 0 {
|
||||
// the dev would want to see the final state if they're running in slow mode
|
||||
|
@ -63,10 +63,10 @@ func (self *fakeGuiDriver) View(viewName string) *gocui.View {
|
||||
func TestAssertionFailure(t *testing.T) {
|
||||
test := NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Description: unitTestDescription,
|
||||
Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
|
||||
input.Press("a")
|
||||
input.Press("b")
|
||||
assert.Model().CommitCount(2)
|
||||
Run: func(shell *Shell, input *Input, keys config.KeybindingConfig) {
|
||||
input.press("a")
|
||||
input.press("b")
|
||||
input.Model().CommitCount(2)
|
||||
},
|
||||
})
|
||||
driver := &fakeGuiDriver{}
|
||||
@ -78,8 +78,8 @@ func TestAssertionFailure(t *testing.T) {
|
||||
func TestManualFailure(t *testing.T) {
|
||||
test := NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Description: unitTestDescription,
|
||||
Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
|
||||
assert.Fail("blah")
|
||||
Run: func(shell *Shell, input *Input, keys config.KeybindingConfig) {
|
||||
input.Fail("blah")
|
||||
},
|
||||
})
|
||||
driver := &fakeGuiDriver{}
|
||||
@ -90,10 +90,10 @@ func TestManualFailure(t *testing.T) {
|
||||
func TestSuccess(t *testing.T) {
|
||||
test := NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Description: unitTestDescription,
|
||||
Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
|
||||
input.Press("a")
|
||||
input.Press("b")
|
||||
assert.Model().CommitCount(0)
|
||||
Run: func(shell *Shell, input *Input, keys config.KeybindingConfig) {
|
||||
input.press("a")
|
||||
input.press("b")
|
||||
input.Model().CommitCount(0)
|
||||
},
|
||||
})
|
||||
driver := &fakeGuiDriver{}
|
||||
|
196
pkg/integration/components/view.go
Normal file
196
pkg/integration/components/view.go
Normal file
@ -0,0 +1,196 @@
|
||||
package components
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/jesseduffield/gocui"
|
||||
)
|
||||
|
||||
type View struct {
|
||||
// context is prepended to any error messages e.g. 'context: "current view"'
|
||||
context string
|
||||
getView func() *gocui.View
|
||||
input *Input
|
||||
}
|
||||
|
||||
// asserts that the view has the expected name. This is typically used in tandem with the CurrentView method i.e.;
|
||||
// input.CurrentView().Name("commits") to assert that the current view is the commits view.
|
||||
func (self *View) Name(expected string) *View {
|
||||
self.input.assertWithRetries(func() (bool, string) {
|
||||
actual := self.getView().Name()
|
||||
return actual == expected, fmt.Sprintf("%s: Expected view name to be '%s', but got '%s'", self.context, expected, actual)
|
||||
})
|
||||
|
||||
return self
|
||||
}
|
||||
|
||||
// asserts that the view has the expected title
|
||||
func (self *View) Title(expected *matcher) *View {
|
||||
self.input.assertWithRetries(func() (bool, string) {
|
||||
actual := self.getView().Title
|
||||
return expected.context(fmt.Sprintf("%s title", self.context)).test(actual)
|
||||
})
|
||||
|
||||
return self
|
||||
}
|
||||
|
||||
// asserts that the view has lines matching the given matchers. So if three matchers
|
||||
// are passed, we only check the first three lines of the view.
|
||||
// This method is convenient when you have a list of commits but you only want to
|
||||
// assert on the first couple of commits.
|
||||
func (self *View) TopLines(matchers ...*matcher) *View {
|
||||
self.input.assertWithRetries(func() (bool, string) {
|
||||
lines := self.getView().BufferLines()
|
||||
return len(lines) >= len(matchers), fmt.Sprintf("unexpected number of lines in view. Expected at least %d, got %d", len(matchers), len(lines))
|
||||
})
|
||||
|
||||
return self.assertLines(matchers...)
|
||||
}
|
||||
|
||||
// asserts that the view has lines matching the given matchers. One matcher must be passed for each line.
|
||||
// If you only care about the top n lines, use the TopLines method instead.
|
||||
func (self *View) Lines(matchers ...*matcher) *View {
|
||||
self.input.assertWithRetries(func() (bool, string) {
|
||||
lines := self.getView().BufferLines()
|
||||
return len(lines) == len(matchers), fmt.Sprintf("unexpected number of lines in view. Expected %d, got %d", len(matchers), len(lines))
|
||||
})
|
||||
|
||||
return self.assertLines(matchers...)
|
||||
}
|
||||
|
||||
func (self *View) assertLines(matchers ...*matcher) *View {
|
||||
view := self.getView()
|
||||
|
||||
for i, matcher := range matchers {
|
||||
checkIsSelected, matcher := matcher.checkIsSelected()
|
||||
|
||||
self.input.matchString(matcher, fmt.Sprintf("Unexpected content in view '%s'.", view.Name()),
|
||||
func() string {
|
||||
return view.BufferLines()[i]
|
||||
},
|
||||
)
|
||||
|
||||
if checkIsSelected {
|
||||
self.input.assertWithRetries(func() (bool, string) {
|
||||
lineIdx := view.SelectedLineIdx()
|
||||
return lineIdx == i, fmt.Sprintf("Unexpected selected line index in view '%s'. Expected %d, got %d", view.Name(), i, lineIdx)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return self
|
||||
}
|
||||
|
||||
// asserts on the content of the view i.e. the stuff within the view's frame.
|
||||
func (self *View) Content(matcher *matcher) *View {
|
||||
self.input.matchString(matcher, fmt.Sprintf("%s: Unexpected content.", self.context),
|
||||
func() string {
|
||||
return self.getView().Buffer()
|
||||
},
|
||||
)
|
||||
|
||||
return self
|
||||
}
|
||||
|
||||
// asserts on the selected line of the view
|
||||
func (self *View) SelectedLine(matcher *matcher) *View {
|
||||
self.input.matchString(matcher, fmt.Sprintf("%s: Unexpected selected line.", self.context),
|
||||
func() string {
|
||||
return self.getView().SelectedLine()
|
||||
},
|
||||
)
|
||||
|
||||
return self
|
||||
}
|
||||
|
||||
// asserts on the index of the selected line. 0 is the first index, representing the line at the top of the view.
|
||||
func (self *View) SelectedLineIdx(expected int) *View {
|
||||
self.input.assertWithRetries(func() (bool, string) {
|
||||
actual := self.getView().SelectedLineIdx()
|
||||
return expected == actual, fmt.Sprintf("%s: Expected selected line index to be %d, got %d", self.context, expected, actual)
|
||||
})
|
||||
|
||||
return self
|
||||
}
|
||||
|
||||
// focus the view (assumes the view is a side-view that can be focused via a keybinding)
|
||||
func (self *View) Focus() *View {
|
||||
// we can easily change focus by switching to the view's window, but this assumes that the desired view
|
||||
// is at the top of that window. So for now we'll switch to the window then assert that the desired
|
||||
// view is on top (i.e. that it's the current view).
|
||||
// If we want to support other views e.g. the tags view, we'll need to add more logic here.
|
||||
viewName := self.getView().Name()
|
||||
|
||||
// using a map rather than a slice because we might add other views which share a window index later
|
||||
windowIndexMap := map[string]int{
|
||||
"status": 0,
|
||||
"files": 1,
|
||||
"localBranches": 2,
|
||||
"commits": 3,
|
||||
"stash": 4,
|
||||
}
|
||||
|
||||
index, ok := windowIndexMap[viewName]
|
||||
if !ok {
|
||||
self.input.fail(fmt.Sprintf("Cannot focus view %s: Focus() method not implemented", viewName))
|
||||
}
|
||||
|
||||
self.input.press(self.input.keys.Universal.JumpToBlock[index])
|
||||
|
||||
// assert that we land in the expected view
|
||||
self.IsFocused()
|
||||
|
||||
return self
|
||||
}
|
||||
|
||||
// asserts that the view is focused
|
||||
func (self *View) IsFocused() *View {
|
||||
self.input.assertWithRetries(func() (bool, string) {
|
||||
expected := self.getView().Name()
|
||||
actual := self.input.gui.CurrentContext().GetView().Name()
|
||||
return actual == expected, fmt.Sprintf("%s: Unexpected view focused. Expected %s, got %s", self.context, expected, actual)
|
||||
})
|
||||
|
||||
return self
|
||||
}
|
||||
|
||||
func (self *View) Press(keyStr string) *View {
|
||||
self.IsFocused()
|
||||
|
||||
self.input.press(keyStr)
|
||||
|
||||
return self
|
||||
}
|
||||
|
||||
// i.e. pressing down arrow
|
||||
func (self *View) SelectNextItem() *View {
|
||||
return self.Press(self.input.keys.Universal.NextItem)
|
||||
}
|
||||
|
||||
// i.e. pressing up arrow
|
||||
func (self *View) SelectPreviousItem() *View {
|
||||
return self.Press(self.input.keys.Universal.PrevItem)
|
||||
}
|
||||
|
||||
// i.e. pressing space
|
||||
func (self *View) PressPrimaryAction() *View {
|
||||
return self.Press(self.input.keys.Universal.Select)
|
||||
}
|
||||
|
||||
// i.e. pressing space
|
||||
func (self *View) PressEnter() *View {
|
||||
return self.Press(self.input.keys.Universal.Confirm)
|
||||
}
|
||||
|
||||
// i.e. pressing escape
|
||||
func (self *View) PressEscape() *View {
|
||||
return self.Press(self.input.keys.Universal.Return)
|
||||
}
|
||||
|
||||
func (self *View) NavigateToListItem(matcher *matcher) *View {
|
||||
self.IsFocused()
|
||||
|
||||
self.input.navigateToListItem(matcher)
|
||||
|
||||
return self
|
||||
}
|
@ -7,15 +7,15 @@ import (
|
||||
)
|
||||
|
||||
type Views struct {
|
||||
assert *Assert
|
||||
input *Input
|
||||
input *Input
|
||||
}
|
||||
|
||||
func (self *Views) Current() *View {
|
||||
// not exporting this because I want the test to always be explicit about what
|
||||
// view it's dealing with.
|
||||
func (self *Views) current() *View {
|
||||
return &View{
|
||||
context: "current view",
|
||||
getView: func() *gocui.View { return self.assert.gui.CurrentContext().GetView() },
|
||||
assert: self.assert,
|
||||
getView: func() *gocui.View { return self.input.gui.CurrentContext().GetView() },
|
||||
input: self.input,
|
||||
}
|
||||
}
|
||||
@ -23,8 +23,7 @@ func (self *Views) Current() *View {
|
||||
func (self *Views) Main() *View {
|
||||
return &View{
|
||||
context: "main view",
|
||||
getView: func() *gocui.View { return self.assert.gui.MainView() },
|
||||
assert: self.assert,
|
||||
getView: func() *gocui.View { return self.input.gui.MainView() },
|
||||
input: self.input,
|
||||
}
|
||||
}
|
||||
@ -32,8 +31,7 @@ func (self *Views) Main() *View {
|
||||
func (self *Views) Secondary() *View {
|
||||
return &View{
|
||||
context: "secondary view",
|
||||
getView: func() *gocui.View { return self.assert.gui.SecondaryView() },
|
||||
assert: self.assert,
|
||||
getView: func() *gocui.View { return self.input.gui.SecondaryView() },
|
||||
input: self.input,
|
||||
}
|
||||
}
|
||||
@ -41,143 +39,83 @@ func (self *Views) Secondary() *View {
|
||||
func (self *Views) ByName(viewName string) *View {
|
||||
return &View{
|
||||
context: fmt.Sprintf("%s view", viewName),
|
||||
getView: func() *gocui.View { return self.assert.gui.View(viewName) },
|
||||
assert: self.assert,
|
||||
getView: func() *gocui.View { return self.input.gui.View(viewName) },
|
||||
input: self.input,
|
||||
}
|
||||
}
|
||||
|
||||
type View struct {
|
||||
// context is prepended to any error messages e.g. 'context: "current view"'
|
||||
context string
|
||||
getView func() *gocui.View
|
||||
assert *Assert
|
||||
input *Input
|
||||
func (self *Views) Commits() *View {
|
||||
return self.ByName("commits")
|
||||
}
|
||||
|
||||
// asserts that the view has the expected name. This is typically used in tandem with the CurrentView method i.e.;
|
||||
// assert.CurrentView().Name("commits") to assert that the current view is the commits view.
|
||||
func (self *View) Name(expected string) *View {
|
||||
self.assert.assertWithRetries(func() (bool, string) {
|
||||
actual := self.getView().Name()
|
||||
return actual == expected, fmt.Sprintf("%s: Expected view name to be '%s', but got '%s'", self.context, expected, actual)
|
||||
})
|
||||
|
||||
return self
|
||||
func (self *Views) Files() *View {
|
||||
return self.ByName("files")
|
||||
}
|
||||
|
||||
// asserts that the view has the expected title
|
||||
func (self *View) Title(expected *matcher) *View {
|
||||
self.assert.assertWithRetries(func() (bool, string) {
|
||||
actual := self.getView().Title
|
||||
return expected.context(fmt.Sprintf("%s title", self.context)).test(actual)
|
||||
})
|
||||
|
||||
return self
|
||||
func (self *Views) Status() *View {
|
||||
return self.ByName("status")
|
||||
}
|
||||
|
||||
// asserts that the view has lines matching the given matchers. So if three matchers
|
||||
// are passed, we only check the first three lines of the view.
|
||||
// This method is convenient when you have a list of commits but you only want to
|
||||
// assert on the first couple of commits.
|
||||
func (self *View) TopLines(matchers ...*matcher) *View {
|
||||
self.assert.assertWithRetries(func() (bool, string) {
|
||||
lines := self.getView().BufferLines()
|
||||
return len(lines) >= len(matchers), fmt.Sprintf("unexpected number of lines in view. Expected at least %d, got %d", len(matchers), len(lines))
|
||||
})
|
||||
|
||||
return self.assertLines(matchers...)
|
||||
func (self *Views) Submodules() *View {
|
||||
return self.ByName("submodules")
|
||||
}
|
||||
|
||||
// asserts that the view has lines matching the given matchers. One matcher must be passed for each line.
|
||||
// If you only care about the top n lines, use the TopLines method instead.
|
||||
func (self *View) Lines(matchers ...*matcher) *View {
|
||||
self.assert.assertWithRetries(func() (bool, string) {
|
||||
lines := self.getView().BufferLines()
|
||||
return len(lines) == len(matchers), fmt.Sprintf("unexpected number of lines in view. Expected %d, got %d", len(matchers), len(lines))
|
||||
})
|
||||
|
||||
return self.assertLines(matchers...)
|
||||
func (self *Views) Information() *View {
|
||||
return self.ByName("information")
|
||||
}
|
||||
|
||||
func (self *View) assertLines(matchers ...*matcher) *View {
|
||||
view := self.getView()
|
||||
|
||||
for i, matcher := range matchers {
|
||||
checkIsSelected, matcher := matcher.checkIsSelected()
|
||||
|
||||
self.assert.matchString(matcher, fmt.Sprintf("Unexpected content in view '%s'.", view.Name()),
|
||||
func() string {
|
||||
return view.BufferLines()[i]
|
||||
},
|
||||
)
|
||||
|
||||
if checkIsSelected {
|
||||
self.assert.assertWithRetries(func() (bool, string) {
|
||||
lineIdx := view.SelectedLineIdx()
|
||||
return lineIdx == i, fmt.Sprintf("Unexpected selected line index in view '%s'. Expected %d, got %d", view.Name(), i, lineIdx)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return self
|
||||
func (self *Views) Branches() *View {
|
||||
return self.ByName("localBranches")
|
||||
}
|
||||
|
||||
// asserts on the content of the view i.e. the stuff within the view's frame.
|
||||
func (self *View) Content(matcher *matcher) *View {
|
||||
self.assert.matchString(matcher, fmt.Sprintf("%s: Unexpected content.", self.context),
|
||||
func() string {
|
||||
return self.getView().Buffer()
|
||||
},
|
||||
)
|
||||
|
||||
return self
|
||||
func (self *Views) RemoteBranches() *View {
|
||||
return self.ByName("remoteBranches")
|
||||
}
|
||||
|
||||
// asserts on the selected line of the view
|
||||
func (self *View) SelectedLine(matcher *matcher) *View {
|
||||
self.assert.matchString(matcher, fmt.Sprintf("%s: Unexpected selected line.", self.context),
|
||||
func() string {
|
||||
return self.getView().SelectedLine()
|
||||
},
|
||||
)
|
||||
|
||||
return self
|
||||
func (self *Views) Tags() *View {
|
||||
return self.ByName("tags")
|
||||
}
|
||||
|
||||
// asserts on the index of the selected line. 0 is the first index, representing the line at the top of the view.
|
||||
func (self *View) SelectedLineIdx(expected int) *View {
|
||||
self.assert.assertWithRetries(func() (bool, string) {
|
||||
actual := self.getView().SelectedLineIdx()
|
||||
return expected == actual, fmt.Sprintf("%s: Expected selected line index to be %d, got %d", self.context, expected, actual)
|
||||
})
|
||||
|
||||
return self
|
||||
func (self *Views) ReflogCommits() *View {
|
||||
return self.ByName("reflogCommits")
|
||||
}
|
||||
|
||||
// func (self *View) Focus() *View {
|
||||
// // we can easily change focus by switching to the view's window, but this assumes that the desired view
|
||||
// // is at the top of that window. So for now we'll switch to the window then assert that the desired
|
||||
// // view is on top (i.e. that it's the current view).
|
||||
// whitelistedViewNames := []string{"status", "files", "localBranches", "commits", "stash"}
|
||||
func (self *Views) SubCommits() *View {
|
||||
return self.ByName("subCommits")
|
||||
}
|
||||
|
||||
// viewName := self.getView().Name()
|
||||
func (self *Views) CommitFiles() *View {
|
||||
return self.ByName("commitFiles")
|
||||
}
|
||||
|
||||
// if !lo.Contains(whitelistedViewNames, self.getView().Name()) {
|
||||
// self.assert.fail(fmt.Sprintf("Cannot focus view %s: Focus() method not implemented", viewName))
|
||||
// }
|
||||
func (self *Views) Stash() *View {
|
||||
return self.ByName("stash")
|
||||
}
|
||||
|
||||
// windowIndexMap := map[string]int{
|
||||
// "status": 0,
|
||||
// "files": 1,
|
||||
// "localBranches": 2,
|
||||
// "commits": 3,
|
||||
// "stash": 4,
|
||||
// }
|
||||
func (self *Views) Staging() *View {
|
||||
return self.ByName("staging")
|
||||
}
|
||||
|
||||
// self.input.switchToFilesWindow()
|
||||
// self.press(self.keys.Universal.JumpToBlock[1])
|
||||
// self.assert.Views().Current().Name(viewName)
|
||||
func (self *Views) StagingSecondary() *View {
|
||||
return self.ByName("stagingSecondary")
|
||||
}
|
||||
|
||||
// return self
|
||||
// }
|
||||
func (self *Views) Menu() *View {
|
||||
return self.ByName("menu")
|
||||
}
|
||||
|
||||
func (self *Views) Confirmation() *View {
|
||||
return self.ByName("confirmation")
|
||||
}
|
||||
|
||||
func (self *Views) CommitMessage() *View {
|
||||
return self.ByName("commitMessage")
|
||||
}
|
||||
|
||||
func (self *Views) Suggestions() *View {
|
||||
return self.ByName("suggestions")
|
||||
}
|
||||
|
||||
func (self *Views) MergeConflicts() *View {
|
||||
return self.ByName("mergeConflicts")
|
||||
}
|
||||
|
@ -17,54 +17,55 @@ var Basic = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Run: func(
|
||||
shell *Shell,
|
||||
input *Input,
|
||||
assert *Assert,
|
||||
keys config.KeybindingConfig,
|
||||
) {
|
||||
markCommitAsBad := func() {
|
||||
input.Press(keys.Commits.ViewBisectOptions)
|
||||
input.Menu().Title(Equals("Bisect")).Select(MatchesRegexp(`mark .* as bad`)).Confirm()
|
||||
input.Views().Commits().
|
||||
Press(keys.Commits.ViewBisectOptions)
|
||||
|
||||
input.ExpectMenu().Title(Equals("Bisect")).Select(MatchesRegexp(`mark .* as bad`)).Confirm()
|
||||
}
|
||||
|
||||
markCommitAsGood := func() {
|
||||
input.Press(keys.Commits.ViewBisectOptions)
|
||||
input.Menu().Title(Equals("Bisect")).Select(MatchesRegexp(`mark .* as good`)).Confirm()
|
||||
input.Views().Commits().
|
||||
Press(keys.Commits.ViewBisectOptions)
|
||||
|
||||
input.ExpectMenu().Title(Equals("Bisect")).Select(MatchesRegexp(`mark .* as good`)).Confirm()
|
||||
}
|
||||
|
||||
assert.Model().AtLeastOneCommit()
|
||||
input.Model().AtLeastOneCommit()
|
||||
|
||||
input.SwitchToCommitsView()
|
||||
|
||||
assert.Views().Current().SelectedLine(Contains("commit 10"))
|
||||
|
||||
input.NavigateToListItem(Contains("commit 09"))
|
||||
input.Views().Commits().
|
||||
Focus().
|
||||
SelectedLine(Contains("commit 10")).
|
||||
NavigateToListItem(Contains("commit 09"))
|
||||
|
||||
markCommitAsBad()
|
||||
|
||||
assert.Views().ByName("information").Content(Contains("bisecting"))
|
||||
input.Views().Information().Content(Contains("bisecting"))
|
||||
|
||||
assert.Views().Current().Name("commits").SelectedLine(Contains("<-- bad"))
|
||||
|
||||
input.NavigateToListItem(Contains("commit 02"))
|
||||
input.Views().Commits().
|
||||
IsFocused().
|
||||
SelectedLine(Contains("<-- bad")).
|
||||
NavigateToListItem(Contains("commit 02"))
|
||||
|
||||
markCommitAsGood()
|
||||
|
||||
// lazygit will land us in the commit between our good and bad commits.
|
||||
assert.Views().Current().
|
||||
Name("commits").
|
||||
input.Views().Commits().IsFocused().
|
||||
SelectedLine(Contains("commit 05").Contains("<-- current"))
|
||||
|
||||
markCommitAsBad()
|
||||
|
||||
assert.Views().Current().
|
||||
Name("commits").
|
||||
input.Views().Commits().IsFocused().
|
||||
SelectedLine(Contains("commit 04").Contains("<-- current"))
|
||||
|
||||
markCommitAsGood()
|
||||
|
||||
// commit 5 is the culprit because we marked 4 as good and 5 as bad.
|
||||
input.Alert().Title(Equals("Bisect complete")).Content(MatchesRegexp("(?s)commit 05.*Do you want to reset")).Confirm()
|
||||
input.ExpectAlert().Title(Equals("Bisect complete")).Content(MatchesRegexp("(?s)commit 05.*Do you want to reset")).Confirm()
|
||||
|
||||
assert.Views().Current().Name("commits").Content(Contains("commit 04"))
|
||||
assert.Views().ByName("information").Content(DoesNotContain("bisecting"))
|
||||
input.Views().Commits().IsFocused().Content(Contains("commit 04"))
|
||||
input.Views().Information().Content(DoesNotContain("bisecting"))
|
||||
},
|
||||
})
|
||||
|
@ -21,33 +21,31 @@ var FromOtherBranch = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Run: func(
|
||||
shell *Shell,
|
||||
input *Input,
|
||||
assert *Assert,
|
||||
keys config.KeybindingConfig,
|
||||
) {
|
||||
assert.Views().ByName("information").Content(Contains("bisecting"))
|
||||
input.Views().Information().Content(Contains("bisecting"))
|
||||
|
||||
assert.Model().AtLeastOneCommit()
|
||||
input.Model().AtLeastOneCommit()
|
||||
|
||||
input.SwitchToCommitsView()
|
||||
input.Views().Commits().
|
||||
Focus().
|
||||
TopLines(
|
||||
MatchesRegexp(`<-- bad.*commit 08`),
|
||||
MatchesRegexp(`<-- current.*commit 07`),
|
||||
MatchesRegexp(`\?.*commit 06`),
|
||||
MatchesRegexp(`<-- good.*commit 05`),
|
||||
).
|
||||
SelectNextItem().
|
||||
Press(keys.Commits.ViewBisectOptions)
|
||||
|
||||
assert.Views().Current().TopLines(
|
||||
MatchesRegexp(`<-- bad.*commit 08`),
|
||||
MatchesRegexp(`<-- current.*commit 07`),
|
||||
MatchesRegexp(`\?.*commit 06`),
|
||||
MatchesRegexp(`<-- good.*commit 05`),
|
||||
)
|
||||
input.ExpectMenu().Title(Equals("Bisect")).Select(MatchesRegexp(`mark .* as good`)).Confirm()
|
||||
|
||||
input.NextItem()
|
||||
input.ExpectAlert().Title(Equals("Bisect complete")).Content(MatchesRegexp("(?s)commit 08.*Do you want to reset")).Confirm()
|
||||
|
||||
input.Press(keys.Commits.ViewBisectOptions)
|
||||
input.Menu().Title(Equals("Bisect")).Select(MatchesRegexp(`mark .* as good`)).Confirm()
|
||||
|
||||
input.Alert().Title(Equals("Bisect complete")).Content(MatchesRegexp("(?s)commit 08.*Do you want to reset")).Confirm()
|
||||
|
||||
assert.Views().ByName("information").Content(DoesNotContain("bisecting"))
|
||||
input.Views().Information().Content(DoesNotContain("bisecting"))
|
||||
|
||||
// back in master branch which just had the one commit
|
||||
assert.Views().Current().Name("commits").Lines(
|
||||
input.Views().Commits().Lines(
|
||||
Contains("only commit on master"),
|
||||
)
|
||||
},
|
||||
|
@ -17,22 +17,21 @@ var CheckoutByName = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Checkout("master").
|
||||
EmptyCommit("blah")
|
||||
},
|
||||
Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
|
||||
input.SwitchToBranchesView()
|
||||
Run: func(shell *Shell, input *Input, keys config.KeybindingConfig) {
|
||||
input.Views().Branches().
|
||||
Focus().
|
||||
Lines(
|
||||
Contains("master"),
|
||||
Contains("@"),
|
||||
).
|
||||
SelectNextItem().
|
||||
Press(keys.Branches.CheckoutBranchByName)
|
||||
|
||||
assert.Views().Current().Lines(
|
||||
Contains("master"),
|
||||
Contains("@"),
|
||||
)
|
||||
input.NextItem()
|
||||
input.ExpectPrompt().Title(Equals("Branch name:")).Type("new-branch").Confirm()
|
||||
|
||||
input.Press(keys.Branches.CheckoutBranchByName)
|
||||
input.ExpectAlert().Title(Equals("Branch not found")).Content(Equals("Branch not found. Create a new branch named new-branch?")).Confirm()
|
||||
|
||||
input.Prompt().Title(Equals("Branch name:")).Type("new-branch").Confirm()
|
||||
|
||||
input.Alert().Title(Equals("Branch not found")).Content(Equals("Branch not found. Create a new branch named new-branch?")).Confirm()
|
||||
|
||||
assert.Views().Current().Name("localBranches").
|
||||
input.Views().Branches().IsFocused().
|
||||
Lines(
|
||||
MatchesRegexp(`\*.*new-branch`),
|
||||
Contains("master"),
|
||||
|
@ -16,27 +16,28 @@ var Delete = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
NewBranch("branch-one").
|
||||
NewBranch("branch-two")
|
||||
},
|
||||
Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
|
||||
input.SwitchToBranchesView()
|
||||
Run: func(shell *Shell, input *Input, keys config.KeybindingConfig) {
|
||||
input.Views().Branches().
|
||||
Focus().
|
||||
Lines(
|
||||
MatchesRegexp(`\*.*branch-two`).IsSelected(),
|
||||
MatchesRegexp(`branch-one`),
|
||||
MatchesRegexp(`master`),
|
||||
).
|
||||
Press(keys.Universal.Remove)
|
||||
|
||||
assert.Views().Current().Lines(
|
||||
MatchesRegexp(`\*.*branch-two`),
|
||||
MatchesRegexp(`branch-one`),
|
||||
MatchesRegexp(`master`),
|
||||
)
|
||||
input.ExpectAlert().Title(Equals("Error")).Content(Contains("You cannot delete the checked out branch!")).Confirm()
|
||||
|
||||
input.Press(keys.Universal.Remove)
|
||||
input.Alert().Title(Equals("Error")).Content(Contains("You cannot delete the checked out branch!")).Confirm()
|
||||
input.Views().Branches().
|
||||
SelectNextItem().
|
||||
Press(keys.Universal.Remove)
|
||||
|
||||
input.NextItem()
|
||||
|
||||
input.Press(keys.Universal.Remove)
|
||||
input.Confirmation().
|
||||
input.ExpectConfirmation().
|
||||
Title(Equals("Delete Branch")).
|
||||
Content(Contains("Are you sure you want to delete the branch 'branch-one'?")).
|
||||
Confirm()
|
||||
|
||||
assert.Views().Current().Name("localBranches").
|
||||
input.Views().Branches().IsFocused().
|
||||
Lines(
|
||||
MatchesRegexp(`\*.*branch-two`),
|
||||
MatchesRegexp(`master`).IsSelected(),
|
||||
|
@ -14,51 +14,51 @@ var Rebase = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
SetupRepo: func(shell *Shell) {
|
||||
shared.MergeConflictsSetup(shell)
|
||||
},
|
||||
Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
|
||||
input.SwitchToBranchesView()
|
||||
|
||||
assert.Views().ByName("localBranches").Lines(
|
||||
Contains("first-change-branch"),
|
||||
Contains("second-change-branch"),
|
||||
Contains("original-branch"),
|
||||
)
|
||||
|
||||
assert.Views().ByName("commits").TopLines(
|
||||
Run: func(shell *Shell, input *Input, keys config.KeybindingConfig) {
|
||||
input.Views().Commits().TopLines(
|
||||
Contains("first change"),
|
||||
Contains("original"),
|
||||
)
|
||||
|
||||
input.NextItem()
|
||||
input.Press(keys.Branches.RebaseBranch)
|
||||
input.Views().Branches().
|
||||
Focus().
|
||||
Lines(
|
||||
Contains("first-change-branch"),
|
||||
Contains("second-change-branch"),
|
||||
Contains("original-branch"),
|
||||
).
|
||||
SelectNextItem().
|
||||
Press(keys.Branches.RebaseBranch)
|
||||
|
||||
input.Confirmation().
|
||||
input.ExpectConfirmation().
|
||||
Title(Equals("Rebasing")).
|
||||
Content(Contains("Are you sure you want to rebase 'first-change-branch' on top of 'second-change-branch'?")).
|
||||
Confirm()
|
||||
input.Confirmation().
|
||||
|
||||
input.ExpectConfirmation().
|
||||
Title(Equals("Auto-merge failed")).
|
||||
Content(Contains("Conflicts!")).
|
||||
Confirm()
|
||||
|
||||
assert.Views().Current().Name("files").SelectedLine(Contains("file"))
|
||||
input.Views().Files().
|
||||
IsFocused().
|
||||
SelectedLine(Contains("file")).
|
||||
PressEnter()
|
||||
|
||||
// not using Confirm() convenience method because I suspect we might change this
|
||||
// keybinding to something more bespoke
|
||||
input.Press(keys.Universal.Confirm)
|
||||
input.Views().MergeConflicts().
|
||||
IsFocused().
|
||||
PressPrimaryAction()
|
||||
|
||||
assert.Views().Current().Name("mergeConflicts")
|
||||
input.PrimaryAction()
|
||||
input.Views().Information().Content(Contains("rebasing"))
|
||||
|
||||
assert.Views().ByName("information").Content(Contains("rebasing"))
|
||||
|
||||
input.Confirmation().
|
||||
input.ExpectConfirmation().
|
||||
Title(Equals("continue")).
|
||||
Content(Contains("all merge conflicts resolved. Continue?")).
|
||||
Confirm()
|
||||
|
||||
assert.Views().ByName("information").Content(DoesNotContain("rebasing"))
|
||||
input.Views().Information().Content(DoesNotContain("rebasing"))
|
||||
|
||||
assert.Views().ByName("commits").TopLines(
|
||||
input.Views().Commits().TopLines(
|
||||
Contains("second-change-branch unrelated change"),
|
||||
Contains("second change"),
|
||||
Contains("original"),
|
||||
|
@ -17,55 +17,51 @@ var RebaseAndDrop = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
shell.EmptyCommit("to remove")
|
||||
shell.EmptyCommit("to keep")
|
||||
},
|
||||
Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
|
||||
input.SwitchToBranchesView()
|
||||
Run: func(shell *Shell, input *Input, keys config.KeybindingConfig) {
|
||||
input.Views().Branches().
|
||||
Focus().
|
||||
Lines(
|
||||
Contains("first-change-branch"),
|
||||
Contains("second-change-branch"),
|
||||
Contains("original-branch"),
|
||||
)
|
||||
|
||||
assert.Views().Current().Lines(
|
||||
Contains("first-change-branch"),
|
||||
Contains("second-change-branch"),
|
||||
Contains("original-branch"),
|
||||
)
|
||||
input.Views().Commits().
|
||||
TopLines(
|
||||
Contains("to keep").IsSelected(),
|
||||
Contains("to remove"),
|
||||
Contains("first change"),
|
||||
Contains("original"),
|
||||
).
|
||||
SelectNextItem().
|
||||
Press(keys.Branches.RebaseBranch)
|
||||
|
||||
assert.Views().ByName("commits").TopLines(
|
||||
Contains("to keep").IsSelected(),
|
||||
Contains("to remove"),
|
||||
Contains("first change"),
|
||||
Contains("original"),
|
||||
)
|
||||
|
||||
input.NextItem()
|
||||
input.Press(keys.Branches.RebaseBranch)
|
||||
|
||||
input.Confirmation().
|
||||
input.ExpectConfirmation().
|
||||
Title(Equals("Rebasing")).
|
||||
Content(Contains("Are you sure you want to rebase 'first-change-branch' on top of 'second-change-branch'?")).
|
||||
Confirm()
|
||||
|
||||
assert.Views().ByName("information").Content(Contains("rebasing"))
|
||||
input.Views().Information().Content(Contains("rebasing"))
|
||||
|
||||
input.Confirmation().
|
||||
input.ExpectConfirmation().
|
||||
Title(Equals("Auto-merge failed")).
|
||||
Content(Contains("Conflicts!")).
|
||||
Confirm()
|
||||
|
||||
assert.Views().Current().
|
||||
Name("files").
|
||||
input.Views().Files().IsFocused().
|
||||
SelectedLine(MatchesRegexp("UU.*file"))
|
||||
|
||||
input.SwitchToCommitsView()
|
||||
assert.Views().Current().
|
||||
input.Views().Commits().
|
||||
Focus().
|
||||
TopLines(
|
||||
MatchesRegexp(`pick.*to keep`).IsSelected(),
|
||||
MatchesRegexp(`pick.*to remove`),
|
||||
MatchesRegexp("YOU ARE HERE.*second-change-branch unrelated change"),
|
||||
MatchesRegexp("second change"),
|
||||
MatchesRegexp("original"),
|
||||
)
|
||||
|
||||
input.NextItem()
|
||||
input.Press(keys.Universal.Remove)
|
||||
|
||||
assert.Views().Current().
|
||||
).
|
||||
SelectNextItem().
|
||||
Press(keys.Universal.Remove).
|
||||
TopLines(
|
||||
MatchesRegexp(`pick.*to keep`),
|
||||
MatchesRegexp(`drop.*to remove`).IsSelected(),
|
||||
@ -74,23 +70,22 @@ var RebaseAndDrop = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
MatchesRegexp("original"),
|
||||
)
|
||||
|
||||
input.SwitchToFilesView()
|
||||
input.Views().Files().
|
||||
Focus().
|
||||
PressEnter()
|
||||
|
||||
// not using Confirm() convenience method because I suspect we might change this
|
||||
// keybinding to something more bespoke
|
||||
input.Press(keys.Universal.Confirm)
|
||||
input.Views().MergeConflicts().
|
||||
IsFocused().
|
||||
PressPrimaryAction()
|
||||
|
||||
assert.Views().Current().Name("mergeConflicts")
|
||||
input.PrimaryAction()
|
||||
|
||||
input.Confirmation().
|
||||
input.ExpectConfirmation().
|
||||
Title(Equals("continue")).
|
||||
Content(Contains("all merge conflicts resolved. Continue?")).
|
||||
Confirm()
|
||||
|
||||
assert.Views().ByName("information").Content(DoesNotContain("rebasing"))
|
||||
input.Views().Information().Content(DoesNotContain("rebasing"))
|
||||
|
||||
assert.Views().ByName("commits").TopLines(
|
||||
input.Views().Commits().TopLines(
|
||||
Contains("to keep"),
|
||||
Contains("second-change-branch unrelated change").IsSelected(),
|
||||
Contains("second change"),
|
||||
|
@ -20,32 +20,31 @@ var Reset = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
shell.Checkout("current-branch")
|
||||
shell.EmptyCommit("current-branch commit")
|
||||
},
|
||||
Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
|
||||
assert.Views().ByName("commits").Lines(
|
||||
Run: func(shell *Shell, input *Input, keys config.KeybindingConfig) {
|
||||
input.Views().Commits().Lines(
|
||||
Contains("current-branch commit"),
|
||||
Contains("root commit"),
|
||||
)
|
||||
|
||||
input.SwitchToBranchesView()
|
||||
input.Views().Branches().
|
||||
Focus().
|
||||
Lines(
|
||||
Contains("current-branch"),
|
||||
Contains("other-branch"),
|
||||
).
|
||||
SelectNextItem().
|
||||
Press(keys.Commits.ViewResetOptions)
|
||||
|
||||
assert.Views().Current().Lines(
|
||||
Contains("current-branch"),
|
||||
Contains("other-branch"),
|
||||
)
|
||||
input.NextItem()
|
||||
|
||||
input.Press(keys.Commits.ViewResetOptions)
|
||||
|
||||
input.Menu().Title(Contains("reset to other-branch")).Select(Contains("hard reset")).Confirm()
|
||||
input.ExpectMenu().Title(Contains("reset to other-branch")).Select(Contains("hard reset")).Confirm()
|
||||
|
||||
// ensure that we've returned from the menu before continuing
|
||||
assert.Views().Current().Name("localBranches")
|
||||
input.Views().Branches().IsFocused()
|
||||
|
||||
// assert that we now have the expected commits in the commit panel
|
||||
input.SwitchToCommitsView()
|
||||
assert.Views().Current().Lines(
|
||||
Contains("other-branch commit"),
|
||||
Contains("root commit"),
|
||||
)
|
||||
input.Views().Commits().
|
||||
Lines(
|
||||
Contains("other-branch commit"),
|
||||
Contains("root commit"),
|
||||
)
|
||||
},
|
||||
})
|
||||
|
@ -20,20 +20,20 @@ var Suggestions = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
NewBranch("other-new-branch-2").
|
||||
NewBranch("other-new-branch-3")
|
||||
},
|
||||
Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
|
||||
input.SwitchToBranchesView()
|
||||
|
||||
input.Press(keys.Branches.CheckoutBranchByName)
|
||||
Run: func(shell *Shell, input *Input, keys config.KeybindingConfig) {
|
||||
input.Views().Branches().
|
||||
Focus().
|
||||
Press(keys.Branches.CheckoutBranchByName)
|
||||
|
||||
// we expect the first suggestion to be the branch we want because it most
|
||||
// closely matches what we typed in
|
||||
input.Prompt().
|
||||
input.ExpectPrompt().
|
||||
Title(Equals("Branch name:")).
|
||||
Type("branch-to").
|
||||
SuggestionTopLines(Contains("branch-to-checkout")).
|
||||
SelectFirstSuggestion().
|
||||
Confirm()
|
||||
|
||||
assert.Model().CurrentBranchName("branch-to-checkout")
|
||||
input.Model().CurrentBranchName("branch-to-checkout")
|
||||
},
|
||||
})
|
||||
|
@ -23,56 +23,65 @@ var CherryPick = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
EmptyCommit("four").
|
||||
Checkout("first-branch")
|
||||
},
|
||||
Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
|
||||
input.SwitchToBranchesView()
|
||||
Run: func(shell *Shell, input *Input, keys config.KeybindingConfig) {
|
||||
input.Views().Branches().
|
||||
Focus().
|
||||
Lines(
|
||||
Contains("first-branch"),
|
||||
Contains("second-branch"),
|
||||
Contains("master"),
|
||||
).
|
||||
SelectNextItem().
|
||||
PressEnter()
|
||||
|
||||
assert.Views().Current().Lines(
|
||||
Contains("first-branch"),
|
||||
Contains("second-branch"),
|
||||
Contains("master"),
|
||||
)
|
||||
input.Views().SubCommits().
|
||||
IsFocused().
|
||||
Lines(
|
||||
Contains("four").IsSelected(),
|
||||
Contains("three"),
|
||||
Contains("base"),
|
||||
).
|
||||
// copy commits 'four' and 'three'
|
||||
Press(keys.Commits.CherryPickCopy)
|
||||
|
||||
input.NextItem()
|
||||
input.Views().Information().Content(Contains("1 commit copied"))
|
||||
|
||||
input.Enter()
|
||||
input.Views().SubCommits().
|
||||
SelectNextItem().
|
||||
Press(keys.Commits.CherryPickCopy)
|
||||
|
||||
assert.Views().Current().Name("subCommits").Lines(
|
||||
Contains("four"),
|
||||
Contains("three"),
|
||||
Contains("base"),
|
||||
)
|
||||
input.Views().Information().Content(Contains("2 commits copied"))
|
||||
|
||||
// copy commits 'four' and 'three'
|
||||
input.Press(keys.Commits.CherryPickCopy)
|
||||
assert.Views().ByName("information").Content(Contains("1 commit copied"))
|
||||
input.NextItem()
|
||||
input.Press(keys.Commits.CherryPickCopy)
|
||||
assert.Views().ByName("information").Content(Contains("2 commits copied"))
|
||||
input.Views().Commits().
|
||||
Focus().
|
||||
Lines(
|
||||
Contains("two").IsSelected(),
|
||||
Contains("one"),
|
||||
Contains("base"),
|
||||
).
|
||||
Press(keys.Commits.PasteCommits)
|
||||
|
||||
input.SwitchToCommitsView()
|
||||
|
||||
assert.Views().Current().Lines(
|
||||
Contains("two"),
|
||||
Contains("one"),
|
||||
Contains("base"),
|
||||
)
|
||||
|
||||
input.Press(keys.Commits.PasteCommits)
|
||||
input.Alert().
|
||||
input.ExpectAlert().
|
||||
Title(Equals("Cherry-Pick")).
|
||||
Content(Contains("Are you sure you want to cherry-pick the copied commits onto this branch?")).
|
||||
Confirm()
|
||||
|
||||
assert.Views().Current().Name("commits").Lines(
|
||||
Contains("four"),
|
||||
Contains("three"),
|
||||
Contains("two"),
|
||||
Contains("one"),
|
||||
Contains("base"),
|
||||
)
|
||||
input.Views().Commits().
|
||||
IsFocused().
|
||||
Lines(
|
||||
Contains("four"),
|
||||
Contains("three"),
|
||||
Contains("two"),
|
||||
Contains("one"),
|
||||
Contains("base"),
|
||||
)
|
||||
|
||||
assert.Views().ByName("information").Content(Contains("2 commits copied"))
|
||||
input.Press(keys.Universal.Return)
|
||||
assert.Views().ByName("information").Content(DoesNotContain("commits copied"))
|
||||
// we need to manually exit out of cherrry pick mode
|
||||
input.Views().Information().Content(Contains("2 commits copied"))
|
||||
|
||||
input.Views().Commits().
|
||||
PressEscape()
|
||||
|
||||
input.Views().Information().Content(DoesNotContain("commits copied"))
|
||||
},
|
||||
})
|
||||
|
@ -14,81 +14,86 @@ var CherryPickConflicts = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
SetupRepo: func(shell *Shell) {
|
||||
shared.MergeConflictsSetup(shell)
|
||||
},
|
||||
Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
|
||||
input.SwitchToBranchesView()
|
||||
assert.Views().Current().Lines(
|
||||
Contains("first-change-branch"),
|
||||
Contains("second-change-branch"),
|
||||
Contains("original-branch"),
|
||||
)
|
||||
Run: func(shell *Shell, input *Input, keys config.KeybindingConfig) {
|
||||
input.Views().Branches().
|
||||
Focus().
|
||||
Lines(
|
||||
Contains("first-change-branch"),
|
||||
Contains("second-change-branch"),
|
||||
Contains("original-branch"),
|
||||
).
|
||||
SelectNextItem().
|
||||
PressEnter()
|
||||
|
||||
input.NextItem()
|
||||
input.Views().SubCommits().
|
||||
IsFocused().
|
||||
TopLines(
|
||||
Contains("second-change-branch unrelated change"),
|
||||
Contains("second change"),
|
||||
).
|
||||
Press(keys.Commits.CherryPickCopy)
|
||||
|
||||
input.Enter()
|
||||
input.Views().Information().Content(Contains("1 commit copied"))
|
||||
|
||||
assert.Views().Current().Name("subCommits").TopLines(
|
||||
Contains("second-change-branch unrelated change"),
|
||||
Contains("second change"),
|
||||
)
|
||||
input.Views().SubCommits().
|
||||
SelectNextItem().
|
||||
Press(keys.Commits.CherryPickCopy)
|
||||
|
||||
input.Press(keys.Commits.CherryPickCopy)
|
||||
assert.Views().ByName("information").Content(Contains("1 commit copied"))
|
||||
input.Views().Information().Content(Contains("2 commits copied"))
|
||||
|
||||
input.NextItem()
|
||||
input.Press(keys.Commits.CherryPickCopy)
|
||||
assert.Views().ByName("information").Content(Contains("2 commits copied"))
|
||||
input.Views().Commits().
|
||||
Focus().
|
||||
TopLines(
|
||||
Contains("first change"),
|
||||
).
|
||||
Press(keys.Commits.PasteCommits)
|
||||
|
||||
input.SwitchToCommitsView()
|
||||
input.ExpectAlert().Title(Equals("Cherry-Pick")).Content(Contains("Are you sure you want to cherry-pick the copied commits onto this branch?")).Confirm()
|
||||
|
||||
assert.Views().Current().TopLines(
|
||||
Contains("first change"),
|
||||
)
|
||||
|
||||
input.Press(keys.Commits.PasteCommits)
|
||||
input.Alert().Title(Equals("Cherry-Pick")).Content(Contains("Are you sure you want to cherry-pick the copied commits onto this branch?")).Confirm()
|
||||
|
||||
input.Confirmation().
|
||||
input.ExpectConfirmation().
|
||||
Title(Equals("Auto-merge failed")).
|
||||
Content(Contains("Conflicts!")).
|
||||
Confirm()
|
||||
|
||||
assert.Views().Current().Name("files")
|
||||
assert.Views().Current().SelectedLine(Contains("file"))
|
||||
input.Views().Files().
|
||||
IsFocused().
|
||||
SelectedLine(Contains("file")).
|
||||
PressEnter()
|
||||
|
||||
// not using Confirm() convenience method because I suspect we might change this
|
||||
// keybinding to something more bespoke
|
||||
input.Press(keys.Universal.Confirm)
|
||||
input.Views().MergeConflicts().
|
||||
IsFocused().
|
||||
// picking 'Second change'
|
||||
SelectNextItem().
|
||||
PressPrimaryAction()
|
||||
|
||||
assert.Views().Current().Name("mergeConflicts")
|
||||
// picking 'Second change'
|
||||
input.NextItem()
|
||||
input.PrimaryAction()
|
||||
|
||||
input.Confirmation().
|
||||
input.ExpectConfirmation().
|
||||
Title(Equals("continue")).
|
||||
Content(Contains("all merge conflicts resolved. Continue?")).
|
||||
Confirm()
|
||||
|
||||
assert.Views().Current().Name("files")
|
||||
assert.Model().WorkingTreeFileCount(0)
|
||||
input.Model().WorkingTreeFileCount(0)
|
||||
|
||||
input.SwitchToCommitsView()
|
||||
input.Views().Commits().
|
||||
Focus().
|
||||
TopLines(
|
||||
Contains("second-change-branch unrelated change"),
|
||||
Contains("second change"),
|
||||
Contains("first change"),
|
||||
).
|
||||
SelectNextItem()
|
||||
|
||||
assert.Views().Current().TopLines(
|
||||
Contains("second-change-branch unrelated change"),
|
||||
Contains("second change"),
|
||||
Contains("first change"),
|
||||
)
|
||||
input.NextItem()
|
||||
// because we picked 'Second change' when resolving the conflict,
|
||||
// we now see this commit as having replaced First Change with Second Change,
|
||||
// as opposed to replacing 'Original' with 'Second change'
|
||||
assert.Views().Main().
|
||||
input.Views().Main().
|
||||
Content(Contains("-First Change")).
|
||||
Content(Contains("+Second Change"))
|
||||
|
||||
assert.Views().ByName("information").Content(Contains("2 commits copied"))
|
||||
input.Press(keys.Universal.Return)
|
||||
assert.Views().ByName("information").Content(DoesNotContain("commits copied"))
|
||||
input.Views().Information().Content(Contains("2 commits copied"))
|
||||
|
||||
input.Views().Commits().
|
||||
PressEscape()
|
||||
|
||||
input.Views().Information().Content(DoesNotContain("commits copied"))
|
||||
},
|
||||
})
|
||||
|
@ -14,19 +14,21 @@ var Commit = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
shell.CreateFile("myfile", "myfile content")
|
||||
shell.CreateFile("myfile2", "myfile2 content")
|
||||
},
|
||||
Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
|
||||
assert.Model().CommitCount(0)
|
||||
Run: func(shell *Shell, input *Input, keys config.KeybindingConfig) {
|
||||
input.Model().CommitCount(0)
|
||||
|
||||
input.PrimaryAction()
|
||||
input.NextItem()
|
||||
input.PrimaryAction()
|
||||
input.Press(keys.Files.CommitChanges)
|
||||
input.Views().Files().
|
||||
IsFocused().
|
||||
PressPrimaryAction(). // stage file
|
||||
SelectNextItem().
|
||||
PressPrimaryAction(). // stage other file
|
||||
Press(keys.Files.CommitChanges)
|
||||
|
||||
commitMessage := "my commit message"
|
||||
|
||||
input.CommitMessagePanel().Type(commitMessage).Confirm()
|
||||
input.ExpectCommitMessagePanel().Type(commitMessage).Confirm()
|
||||
|
||||
assert.Model().CommitCount(1)
|
||||
assert.Model().HeadCommitMessage(Equals(commitMessage))
|
||||
input.Model().CommitCount(1)
|
||||
input.Model().HeadCommitMessage(Equals(commitMessage))
|
||||
},
|
||||
})
|
||||
|
@ -13,18 +13,20 @@ var CommitMultiline = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
SetupRepo: func(shell *Shell) {
|
||||
shell.CreateFile("myfile", "myfile content")
|
||||
},
|
||||
Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
|
||||
assert.Model().CommitCount(0)
|
||||
Run: func(shell *Shell, input *Input, keys config.KeybindingConfig) {
|
||||
input.Model().CommitCount(0)
|
||||
|
||||
input.PrimaryAction()
|
||||
input.Press(keys.Files.CommitChanges)
|
||||
input.Views().Files().
|
||||
IsFocused().
|
||||
PressPrimaryAction().
|
||||
Press(keys.Files.CommitChanges)
|
||||
|
||||
input.CommitMessagePanel().Type("first line").AddNewline().AddNewline().Type("third line").Confirm()
|
||||
input.ExpectCommitMessagePanel().Type("first line").AddNewline().AddNewline().Type("third line").Confirm()
|
||||
|
||||
assert.Model().CommitCount(1)
|
||||
assert.Model().HeadCommitMessage(Equals("first line"))
|
||||
input.Model().CommitCount(1)
|
||||
input.Model().HeadCommitMessage(Equals("first line"))
|
||||
|
||||
input.SwitchToCommitsView()
|
||||
assert.Views().Main().Content(MatchesRegexp("first line\n\\s*\n\\s*third line"))
|
||||
input.Views().Commits().Focus()
|
||||
input.Views().Main().Content(MatchesRegexp("first line\n\\s*\n\\s*third line"))
|
||||
},
|
||||
})
|
||||
|
@ -16,25 +16,25 @@ var NewBranch = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
EmptyCommit("commit 2").
|
||||
EmptyCommit("commit 3")
|
||||
},
|
||||
Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
|
||||
assert.Model().CommitCount(3)
|
||||
Run: func(shell *Shell, input *Input, keys config.KeybindingConfig) {
|
||||
input.Model().CommitCount(3)
|
||||
|
||||
input.SwitchToCommitsView()
|
||||
assert.Views().Current().Lines(
|
||||
Contains("commit 3"),
|
||||
Contains("commit 2"),
|
||||
Contains("commit 1"),
|
||||
)
|
||||
input.NextItem()
|
||||
|
||||
input.Press(keys.Universal.New)
|
||||
input.Views().Commits().
|
||||
Focus().
|
||||
Lines(
|
||||
Contains("commit 3"),
|
||||
Contains("commit 2"),
|
||||
Contains("commit 1"),
|
||||
).
|
||||
SelectNextItem().
|
||||
Press(keys.Universal.New)
|
||||
|
||||
branchName := "my-branch-name"
|
||||
input.Prompt().Title(Equals("New Branch Name")).Type(branchName).Confirm()
|
||||
input.ExpectPrompt().Title(Contains("New Branch Name")).Type(branchName).Confirm()
|
||||
|
||||
assert.Model().CurrentBranchName(branchName)
|
||||
input.Model().CurrentBranchName(branchName)
|
||||
|
||||
assert.Views().ByName("commits").Lines(
|
||||
input.Views().Commits().Lines(
|
||||
Contains("commit 2"),
|
||||
Contains("commit 1"),
|
||||
)
|
||||
|
@ -15,28 +15,28 @@ var Revert = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
shell.GitAddAll()
|
||||
shell.Commit("first commit")
|
||||
},
|
||||
Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
|
||||
assert.Model().CommitCount(1)
|
||||
Run: func(shell *Shell, input *Input, keys config.KeybindingConfig) {
|
||||
input.Model().CommitCount(1)
|
||||
|
||||
input.SwitchToCommitsView()
|
||||
input.Views().Commits().
|
||||
Focus().
|
||||
Lines(
|
||||
Contains("first commit"),
|
||||
).
|
||||
Press(keys.Commits.RevertCommit)
|
||||
|
||||
assert.Views().Current().Lines(
|
||||
Contains("first commit"),
|
||||
)
|
||||
|
||||
input.Press(keys.Commits.RevertCommit)
|
||||
input.Confirmation().
|
||||
input.ExpectConfirmation().
|
||||
Title(Equals("Revert commit")).
|
||||
Content(MatchesRegexp(`Are you sure you want to revert \w+?`)).
|
||||
Confirm()
|
||||
|
||||
assert.Views().Current().Name("commits").
|
||||
input.Views().Commits().IsFocused().
|
||||
Lines(
|
||||
Contains("Revert \"first commit\"").IsSelected(),
|
||||
Contains("first commit"),
|
||||
)
|
||||
|
||||
assert.Views().Main().Content(Contains("-myfile content"))
|
||||
assert.FileSystem().PathNotPresent("myfile")
|
||||
input.Views().Main().Content(Contains("-myfile content"))
|
||||
input.FileSystem().PathNotPresent("myfile")
|
||||
},
|
||||
})
|
||||
|
@ -15,38 +15,41 @@ var Staged = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
CreateFile("myfile", "myfile content\nwith a second line").
|
||||
CreateFile("myfile2", "myfile2 content")
|
||||
},
|
||||
Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
|
||||
assert.Model().CommitCount(0)
|
||||
Run: func(shell *Shell, input *Input, keys config.KeybindingConfig) {
|
||||
input.Model().CommitCount(0)
|
||||
|
||||
assert.Views().Current().Name("files")
|
||||
assert.Views().Current().SelectedLine(Contains("myfile"))
|
||||
// stage the file
|
||||
input.PrimaryAction()
|
||||
input.Enter()
|
||||
assert.Views().Current().Name("stagingSecondary")
|
||||
input.Views().Files().
|
||||
IsFocused().
|
||||
SelectedLine(Contains("myfile")).
|
||||
PressPrimaryAction(). // stage the file
|
||||
PressEnter()
|
||||
|
||||
input.Views().StagingSecondary().IsFocused()
|
||||
// we start with both lines having been staged
|
||||
assert.Views().ByName("stagingSecondary").Content(Contains("+myfile content"))
|
||||
assert.Views().ByName("stagingSecondary").Content(Contains("+with a second line"))
|
||||
assert.Views().ByName("staging").Content(DoesNotContain("+myfile content"))
|
||||
assert.Views().ByName("staging").Content(DoesNotContain("+with a second line"))
|
||||
input.Views().StagingSecondary().Content(Contains("+myfile content"))
|
||||
input.Views().StagingSecondary().Content(Contains("+with a second line"))
|
||||
input.Views().Staging().Content(DoesNotContain("+myfile content"))
|
||||
input.Views().Staging().Content(DoesNotContain("+with a second line"))
|
||||
|
||||
// unstage the selected line
|
||||
input.PrimaryAction()
|
||||
input.Views().StagingSecondary().
|
||||
PressPrimaryAction()
|
||||
|
||||
// the line should have been moved to the main view
|
||||
assert.Views().ByName("stagingSecondary").Content(DoesNotContain("+myfile content"))
|
||||
assert.Views().ByName("stagingSecondary").Content(Contains("+with a second line"))
|
||||
assert.Views().ByName("staging").Content(Contains("+myfile content"))
|
||||
assert.Views().ByName("staging").Content(DoesNotContain("+with a second line"))
|
||||
input.Views().StagingSecondary().Content(DoesNotContain("+myfile content"))
|
||||
input.Views().StagingSecondary().Content(Contains("+with a second line"))
|
||||
input.Views().Staging().Content(Contains("+myfile content"))
|
||||
input.Views().Staging().Content(DoesNotContain("+with a second line"))
|
||||
|
||||
input.Views().StagingSecondary().
|
||||
Press(keys.Files.CommitChanges)
|
||||
|
||||
input.Press(keys.Files.CommitChanges)
|
||||
commitMessage := "my commit message"
|
||||
input.Type(commitMessage)
|
||||
input.Confirm()
|
||||
input.ExpectCommitMessagePanel().Type(commitMessage).Confirm()
|
||||
|
||||
assert.Model().CommitCount(1)
|
||||
assert.Model().HeadCommitMessage(Equals(commitMessage))
|
||||
assert.Views().Current().Name("stagingSecondary")
|
||||
input.Model().CommitCount(1)
|
||||
input.Model().HeadCommitMessage(Equals(commitMessage))
|
||||
input.Views().StagingSecondary().IsFocused()
|
||||
|
||||
// TODO: assert that the staging panel has been refreshed (it currently does not get correctly refreshed)
|
||||
},
|
||||
|
@ -15,38 +15,41 @@ var StagedWithoutHooks = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
CreateFile("myfile", "myfile content\nwith a second line").
|
||||
CreateFile("myfile2", "myfile2 content")
|
||||
},
|
||||
Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
|
||||
assert.Model().CommitCount(0)
|
||||
Run: func(shell *Shell, input *Input, keys config.KeybindingConfig) {
|
||||
input.Model().CommitCount(0)
|
||||
|
||||
// stage the file
|
||||
assert.Views().Current().Name("files")
|
||||
assert.Views().Current().SelectedLine(Contains("myfile"))
|
||||
input.PrimaryAction()
|
||||
input.Enter()
|
||||
assert.Views().Current().Name("stagingSecondary")
|
||||
input.Views().Files().
|
||||
IsFocused().
|
||||
SelectedLine(Contains("myfile")).
|
||||
PressPrimaryAction().
|
||||
PressEnter()
|
||||
|
||||
// we start with both lines having been staged
|
||||
assert.Views().ByName("stagingSecondary").Content(
|
||||
input.Views().StagingSecondary().Content(
|
||||
Contains("+myfile content").Contains("+with a second line"),
|
||||
)
|
||||
assert.Views().ByName("staging").Content(
|
||||
input.Views().Staging().Content(
|
||||
DoesNotContain("+myfile content").DoesNotContain("+with a second line"),
|
||||
)
|
||||
|
||||
// unstage the selected line
|
||||
input.PrimaryAction()
|
||||
input.Views().StagingSecondary().
|
||||
IsFocused().
|
||||
PressPrimaryAction()
|
||||
|
||||
// the line should have been moved to the main view
|
||||
assert.Views().ByName("stagingSecondary").Content(DoesNotContain("+myfile content").Contains("+with a second line"))
|
||||
assert.Views().ByName("staging").Content(Contains("+myfile content").DoesNotContain("+with a second line"))
|
||||
|
||||
input.Press(keys.Files.CommitChangesWithoutHook)
|
||||
input.Views().Staging().Content(Contains("+myfile content").DoesNotContain("+with a second line"))
|
||||
input.Views().StagingSecondary().
|
||||
Content(DoesNotContain("+myfile content").Contains("+with a second line")).
|
||||
Press(keys.Files.CommitChangesWithoutHook)
|
||||
|
||||
commitMessage := ": my commit message"
|
||||
input.CommitMessagePanel().InitialText(Contains("WIP")).Type(commitMessage).Confirm()
|
||||
input.ExpectCommitMessagePanel().InitialText(Contains("WIP")).Type(commitMessage).Confirm()
|
||||
|
||||
assert.Model().CommitCount(1)
|
||||
assert.Model().HeadCommitMessage(Equals("WIP" + commitMessage))
|
||||
assert.Views().Current().Name("stagingSecondary")
|
||||
input.Model().CommitCount(1)
|
||||
input.Model().HeadCommitMessage(Equals("WIP" + commitMessage))
|
||||
input.Views().StagingSecondary().IsFocused()
|
||||
|
||||
// TODO: assert that the staging panel has been refreshed (it currently does not get correctly refreshed)
|
||||
},
|
||||
|
@ -5,7 +5,7 @@ import (
|
||||
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||
)
|
||||
|
||||
// TODO: find out why we can't use assert.SelectedLine() on the staging/stagingSecondary views.
|
||||
// TODO: find out why we can't use input.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",
|
||||
@ -17,26 +17,35 @@ var Unstaged = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
CreateFile("myfile", "myfile content\nwith a second line").
|
||||
CreateFile("myfile2", "myfile2 content")
|
||||
},
|
||||
Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
|
||||
assert.Model().CommitCount(0)
|
||||
Run: func(shell *Shell, input *Input, keys config.KeybindingConfig) {
|
||||
input.Model().CommitCount(0)
|
||||
|
||||
input.Views().Files().
|
||||
IsFocused().
|
||||
SelectedLine(Contains("myfile")).
|
||||
PressEnter()
|
||||
|
||||
input.Views().Staging().
|
||||
IsFocused()
|
||||
|
||||
input.Views().StagingSecondary().Content(DoesNotContain("+myfile content"))
|
||||
|
||||
assert.Views().Current().Name("files").SelectedLine(Contains("myfile"))
|
||||
input.Enter()
|
||||
assert.Views().Current().Name("staging")
|
||||
assert.Views().ByName("stagingSecondary").Content(DoesNotContain("+myfile content"))
|
||||
// stage the first line
|
||||
input.PrimaryAction()
|
||||
assert.Views().ByName("staging").Content(DoesNotContain("+myfile content"))
|
||||
assert.Views().ByName("stagingSecondary").Content(Contains("+myfile content"))
|
||||
input.Views().Staging().
|
||||
PressPrimaryAction()
|
||||
|
||||
input.Press(keys.Files.CommitChanges)
|
||||
input.Views().Staging().Content(DoesNotContain("+myfile content"))
|
||||
input.Views().StagingSecondary().Content(Contains("+myfile content"))
|
||||
|
||||
input.Views().Staging().
|
||||
Press(keys.Files.CommitChanges)
|
||||
|
||||
commitMessage := "my commit message"
|
||||
input.CommitMessagePanel().Type(commitMessage).Confirm()
|
||||
input.ExpectCommitMessagePanel().Type(commitMessage).Confirm()
|
||||
|
||||
assert.Model().CommitCount(1)
|
||||
assert.Model().HeadCommitMessage(Equals(commitMessage))
|
||||
assert.Views().Current().Name("staging")
|
||||
input.Model().CommitCount(1)
|
||||
input.Model().HeadCommitMessage(Equals(commitMessage))
|
||||
input.Views().Staging().IsFocused()
|
||||
|
||||
// TODO: assert that the staging panel has been refreshed (it currently does not get correctly refreshed)
|
||||
},
|
||||
|
@ -18,10 +18,9 @@ var RemoteNamedStar = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Run: func(
|
||||
shell *Shell,
|
||||
input *Input,
|
||||
assert *Assert,
|
||||
keys config.KeybindingConfig,
|
||||
) {
|
||||
// here we're just asserting that we haven't panicked upon starting lazygit
|
||||
assert.Model().AtLeastOneCommit()
|
||||
input.Model().AtLeastOneCommit()
|
||||
},
|
||||
})
|
||||
|
@ -24,15 +24,15 @@ var Basic = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Run: func(
|
||||
shell *Shell,
|
||||
input *Input,
|
||||
assert *Assert,
|
||||
keys config.KeybindingConfig,
|
||||
) {
|
||||
assert.Model().WorkingTreeFileCount(0)
|
||||
input.Model().WorkingTreeFileCount(0)
|
||||
|
||||
input.Press("a")
|
||||
|
||||
assert.Views().ByName("files").Lines(
|
||||
Contains("myfile"),
|
||||
)
|
||||
input.Views().Files().
|
||||
IsFocused().
|
||||
Press("a").
|
||||
Lines(
|
||||
Contains("myfile"),
|
||||
)
|
||||
},
|
||||
})
|
||||
|
@ -58,24 +58,25 @@ var FormPrompts = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Run: func(
|
||||
shell *Shell,
|
||||
input *Input,
|
||||
assert *Assert,
|
||||
keys config.KeybindingConfig,
|
||||
) {
|
||||
assert.Model().WorkingTreeFileCount(0)
|
||||
input.Model().WorkingTreeFileCount(0)
|
||||
|
||||
input.Press("a")
|
||||
input.Views().Files().
|
||||
IsFocused().
|
||||
Press("a")
|
||||
|
||||
input.Prompt().Title(Equals("Enter a file name")).Type("my file").Confirm()
|
||||
input.ExpectPrompt().Title(Equals("Enter a file name")).Type("my file").Confirm()
|
||||
|
||||
input.Menu().Title(Equals("Choose file content")).Select(Contains("bar")).Confirm()
|
||||
input.ExpectMenu().Title(Equals("Choose file content")).Select(Contains("bar")).Confirm()
|
||||
|
||||
input.Confirmation().
|
||||
input.ExpectConfirmation().
|
||||
Title(Equals("Are you sure?")).
|
||||
Content(Equals("Are you REALLY sure you want to make this file? Up to you buddy.")).
|
||||
Confirm()
|
||||
|
||||
assert.Model().WorkingTreeFileCount(1)
|
||||
assert.Views().Current().SelectedLine(Contains("my file"))
|
||||
assert.Views().Main().Content(Contains(`"BAR"`))
|
||||
input.Model().WorkingTreeFileCount(1)
|
||||
input.Views().Files().SelectedLine(Contains("my file"))
|
||||
input.Views().Main().Content(Contains(`"BAR"`))
|
||||
},
|
||||
})
|
||||
|
@ -45,22 +45,20 @@ var MenuFromCommand = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Run: func(
|
||||
shell *Shell,
|
||||
input *Input,
|
||||
assert *Assert,
|
||||
keys config.KeybindingConfig,
|
||||
) {
|
||||
assert.Model().WorkingTreeFileCount(0)
|
||||
input.SwitchToBranchesView()
|
||||
input.Model().WorkingTreeFileCount(0)
|
||||
input.Views().Branches().
|
||||
Focus().
|
||||
Press("a")
|
||||
|
||||
input.Press("a")
|
||||
input.ExpectMenu().Title(Equals("Choose commit message")).Select(Contains("bar")).Confirm()
|
||||
|
||||
input.Menu().Title(Equals("Choose commit message")).Select(Contains("bar")).Confirm()
|
||||
input.ExpectPrompt().Title(Equals("Description")).Type(" my branch").Confirm()
|
||||
|
||||
input.Prompt().Title(Equals("Description")).Type(" my branch").Confirm()
|
||||
input.Model().WorkingTreeFileCount(1)
|
||||
|
||||
input.SwitchToFilesView()
|
||||
|
||||
assert.Model().WorkingTreeFileCount(1)
|
||||
assert.Views().Current().SelectedLine(Contains("output.txt"))
|
||||
assert.Views().Main().Content(Contains("bar Branch: #feature/foo my branch feature/foo"))
|
||||
input.Views().Files().Focus().SelectedLine(Contains("output.txt"))
|
||||
input.Views().Main().Content(Contains("bar Branch: #feature/foo my branch feature/foo"))
|
||||
},
|
||||
})
|
||||
|
@ -44,23 +44,22 @@ var MenuFromCommandsOutput = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Run: func(
|
||||
shell *Shell,
|
||||
input *Input,
|
||||
assert *Assert,
|
||||
keys config.KeybindingConfig,
|
||||
) {
|
||||
assert.Model().CurrentBranchName("feature/bar")
|
||||
input.Model().CurrentBranchName("feature/bar")
|
||||
input.Model().WorkingTreeFileCount(0)
|
||||
|
||||
assert.Model().WorkingTreeFileCount(0)
|
||||
input.SwitchToBranchesView()
|
||||
input.Views().Branches().
|
||||
Focus().
|
||||
Press("a")
|
||||
|
||||
input.Press("a")
|
||||
|
||||
input.Prompt().
|
||||
input.ExpectPrompt().
|
||||
Title(Equals("Which git command do you want to run?")).
|
||||
InitialText(Equals("branch")).
|
||||
Confirm()
|
||||
|
||||
input.Menu().Title(Equals("Branch:")).Select(Equals("master")).Confirm()
|
||||
input.ExpectMenu().Title(Equals("Branch:")).Select(Equals("master")).Confirm()
|
||||
|
||||
assert.Model().CurrentBranchName("master")
|
||||
input.Model().CurrentBranchName("master")
|
||||
},
|
||||
})
|
||||
|
@ -56,24 +56,25 @@ var MultiplePrompts = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Run: func(
|
||||
shell *Shell,
|
||||
input *Input,
|
||||
assert *Assert,
|
||||
keys config.KeybindingConfig,
|
||||
) {
|
||||
assert.Model().WorkingTreeFileCount(0)
|
||||
input.Model().WorkingTreeFileCount(0)
|
||||
|
||||
input.Press("a")
|
||||
input.Views().Files().
|
||||
IsFocused().
|
||||
Press("a")
|
||||
|
||||
input.Prompt().Title(Equals("Enter a file name")).Type("myfile").Confirm()
|
||||
input.ExpectPrompt().Title(Equals("Enter a file name")).Type("myfile").Confirm()
|
||||
|
||||
input.Menu().Title(Equals("Choose file content")).Select(Contains("bar")).Confirm()
|
||||
input.ExpectMenu().Title(Equals("Choose file content")).Select(Contains("bar")).Confirm()
|
||||
|
||||
input.Confirmation().
|
||||
input.ExpectConfirmation().
|
||||
Title(Equals("Are you sure?")).
|
||||
Content(Equals("Are you REALLY sure you want to make this file? Up to you buddy.")).
|
||||
Confirm()
|
||||
|
||||
assert.Model().WorkingTreeFileCount(1)
|
||||
assert.Views().Current().SelectedLine(Contains("myfile"))
|
||||
assert.Views().Main().Content(Contains("BAR"))
|
||||
input.Model().WorkingTreeFileCount(1)
|
||||
input.Views().Files().SelectedLine(Contains("myfile"))
|
||||
input.Views().Main().Content(Contains("BAR"))
|
||||
},
|
||||
})
|
||||
|
@ -21,38 +21,55 @@ var Diff = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
|
||||
shell.Checkout("branch-a")
|
||||
},
|
||||
Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
|
||||
input.SwitchToBranchesView()
|
||||
Run: func(shell *Shell, input *Input, keys config.KeybindingConfig) {
|
||||
input.Views().Branches().
|
||||
Focus().
|
||||
TopLines(
|
||||
Contains("branch-a"),
|
||||
Contains("branch-b"),
|
||||
).
|
||||
Press(keys.Universal.DiffingMenu)
|
||||
|
||||
assert.Views().Current().TopLines(
|
||||
Contains("branch-a"),
|
||||
Contains("branch-b"),
|
||||
)
|
||||
input.Press(keys.Universal.DiffingMenu)
|
||||
input.Menu().Title(Equals("Diffing")).Select(Contains(`diff branch-a`)).Confirm()
|
||||
input.ExpectMenu().Title(Equals("Diffing")).Select(Contains(`diff branch-a`)).Confirm()
|
||||
|
||||
assert.Views().Current().Name("localBranches")
|
||||
input.Views().Branches().
|
||||
IsFocused()
|
||||
|
||||
assert.Views().ByName("information").Content(Contains("showing output for: git diff branch-a branch-a"))
|
||||
input.NextItem()
|
||||
assert.Views().ByName("information").Content(Contains("showing output for: git diff branch-a branch-b"))
|
||||
assert.Views().Main().Content(Contains("+second line"))
|
||||
input.Views().Information().Content(Contains("showing output for: git diff branch-a branch-a"))
|
||||
|
||||
input.Enter()
|
||||
assert.Views().Current().Name("subCommits")
|
||||
assert.Views().Main().Content(Contains("+second line"))
|
||||
assert.Views().Current().SelectedLine(Contains("update"))
|
||||
input.Enter()
|
||||
assert.Views().Current().Name("commitFiles").SelectedLine(Contains("file1"))
|
||||
assert.Views().Main().Content(Contains("+second line"))
|
||||
input.Views().Branches().
|
||||
SelectNextItem()
|
||||
|
||||
input.Press(keys.Universal.Return)
|
||||
input.Press(keys.Universal.Return)
|
||||
assert.Views().Current().Name("localBranches")
|
||||
input.Views().Information().Content(Contains("showing output for: git diff branch-a branch-b"))
|
||||
input.Views().Main().Content(Contains("+second line"))
|
||||
|
||||
input.Press(keys.Universal.DiffingMenu)
|
||||
input.Menu().Title(Equals("Diffing")).Select(Contains("reverse diff direction")).Confirm()
|
||||
assert.Views().ByName("information").Content(Contains("showing output for: git diff branch-a branch-b -R"))
|
||||
assert.Views().Main().Content(Contains("-second line"))
|
||||
input.Views().Branches().
|
||||
PressEnter()
|
||||
|
||||
input.Views().SubCommits().
|
||||
IsFocused().
|
||||
SelectedLine(Contains("update"))
|
||||
|
||||
input.Views().Main().Content(Contains("+second line"))
|
||||
|
||||
input.Views().SubCommits().
|
||||
PressEnter()
|
||||
|
||||
input.Views().CommitFiles().
|
||||
IsFocused().
|
||||
SelectedLine(Contains("file1"))
|
||||
|
||||
input.Views().Main().Content(Contains("+second line"))
|
||||
|
||||
input.Views().CommitFiles().PressEscape()
|
||||
input.Views().SubCommits().PressEscape()
|
||||
|
||||
input.Views().Branches().
|
||||
IsFocused().
|
||||
Press(keys.Universal.DiffingMenu)
|
||||
|
||||
input.ExpectMenu().Title(Equals("Diffing")).Select(Contains("reverse diff direction")).Confirm()
|
||||
input.Views().Information().Content(Contains("showing output for: git diff branch-a branch-b -R"))
|
||||
input.Views().Main().Content(Contains("-second line"))
|
||||
},
|
||||
})
|
||||
|
@ -21,48 +21,62 @@ var DiffAndApplyPatch = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
|
||||
shell.Checkout("branch-a")
|
||||
},
|
||||
Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
|
||||
input.SwitchToBranchesView()
|
||||
assert.Views().Current().Lines(
|
||||
Contains("branch-a"),
|
||||
Contains("branch-b"),
|
||||
)
|
||||
Run: func(shell *Shell, input *Input, keys config.KeybindingConfig) {
|
||||
input.Views().Branches().
|
||||
Focus().
|
||||
Lines(
|
||||
Contains("branch-a"),
|
||||
Contains("branch-b"),
|
||||
).
|
||||
Press(keys.Universal.DiffingMenu)
|
||||
|
||||
input.Press(keys.Universal.DiffingMenu)
|
||||
input.ExpectMenu().Title(Equals("Diffing")).Select(Equals("diff branch-a")).Confirm()
|
||||
|
||||
input.Menu().Title(Equals("Diffing")).Select(Equals("diff branch-a")).Confirm()
|
||||
input.Views().Information().Content(Contains("showing output for: git diff branch-a branch-a"))
|
||||
|
||||
assert.Views().Current().Name("localBranches")
|
||||
input.Views().Branches().
|
||||
IsFocused().
|
||||
SelectNextItem()
|
||||
|
||||
assert.Views().ByName("information").Content(Contains("showing output for: git diff branch-a branch-a"))
|
||||
input.NextItem()
|
||||
assert.Views().ByName("information").Content(Contains("showing output for: git diff branch-a branch-b"))
|
||||
assert.Views().Main().Content(Contains("+second line"))
|
||||
input.Views().Information().Content(Contains("showing output for: git diff branch-a branch-b"))
|
||||
input.Views().Main().Content(Contains("+second line"))
|
||||
|
||||
input.Enter()
|
||||
assert.Views().Current().Name("subCommits")
|
||||
assert.Views().Main().Content(Contains("+second line"))
|
||||
assert.Views().Current().SelectedLine(Contains("update"))
|
||||
input.Enter()
|
||||
assert.Views().Current().Name("commitFiles")
|
||||
assert.Views().Current().SelectedLine(Contains("file1"))
|
||||
assert.Views().Main().Content(Contains("+second line"))
|
||||
input.Views().Branches().
|
||||
PressEnter()
|
||||
|
||||
// add the file to the patch
|
||||
input.PrimaryAction()
|
||||
input.Views().SubCommits().
|
||||
IsFocused().
|
||||
SelectedLine(Contains("update"))
|
||||
|
||||
input.Press(keys.Universal.DiffingMenu)
|
||||
input.Menu().Title(Equals("Diffing")).Select(Contains("exit diff mode")).Confirm()
|
||||
input.Views().Main().Content(Contains("+second line"))
|
||||
|
||||
assert.Views().ByName("information").Content(DoesNotContain("building patch"))
|
||||
input.Views().SubCommits().
|
||||
PressEnter()
|
||||
|
||||
input.Views().CommitFiles().
|
||||
IsFocused().
|
||||
SelectedLine(Contains("file1"))
|
||||
|
||||
input.Views().Main().Content(Contains("+second line"))
|
||||
|
||||
input.Views().CommitFiles().
|
||||
PressPrimaryAction(). // add the file to the patch
|
||||
Press(keys.Universal.DiffingMenu)
|
||||
|
||||
input.ExpectMenu().Title(Equals("Diffing")).Select(Contains("exit diff mode")).Confirm()
|
||||
|
||||
input.Views().Information().Content(DoesNotContain("building patch"))
|
||||
|
||||
input.Views().CommitFiles().
|
||||
Press(keys.Universal.CreatePatchOptionsMenu)
|
||||
|
||||
input.Press(keys.Universal.CreatePatchOptionsMenu)
|
||||
// adding the regex '$' here to distinguish the menu item from the 'apply patch in reverse' item
|
||||
input.Menu().Title(Equals("Patch Options")).Select(MatchesRegexp("apply patch$")).Confirm()
|
||||
input.ExpectMenu().Title(Equals("Patch Options")).Select(MatchesRegexp("apply patch$")).Confirm()
|
||||
|
||||
input.SwitchToFilesView()
|
||||
input.Views().Files().
|
||||
Focus().
|
||||
SelectedLine(Contains("file1"))
|
||||
|
||||
assert.Views().Current().SelectedLine(Contains("file1"))
|
||||
assert.Views().Main().Content(Contains("+second line"))
|
||||
input.Views().Main().Content(Contains("+second line"))
|
||||
},
|
||||
})
|
||||
|
@ -18,34 +18,41 @@ var DiffCommits = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
shell.UpdateFileAndAdd("file1", "first line\nsecond line\nthird line\n")
|
||||
shell.Commit("third commit")
|
||||
},
|
||||
Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
|
||||
input.SwitchToCommitsView()
|
||||
Run: func(shell *Shell, input *Input, keys config.KeybindingConfig) {
|
||||
input.Views().Commits().
|
||||
Focus().
|
||||
Lines(
|
||||
Contains("third commit"),
|
||||
Contains("second commit"),
|
||||
Contains("first commit"),
|
||||
).
|
||||
Press(keys.Universal.DiffingMenu)
|
||||
|
||||
assert.Views().Current().Lines(
|
||||
Contains("third commit"),
|
||||
Contains("second commit"),
|
||||
Contains("first commit"),
|
||||
)
|
||||
input.ExpectMenu().Title(Equals("Diffing")).Select(MatchesRegexp(`diff \w+`)).Confirm()
|
||||
|
||||
input.Press(keys.Universal.DiffingMenu)
|
||||
input.Menu().Title(Equals("Diffing")).Select(MatchesRegexp(`diff \w+`)).Confirm()
|
||||
input.Views().Information().Content(Contains("showing output for: git diff"))
|
||||
|
||||
assert.Views().ByName("information").Content(Contains("showing output for: git diff"))
|
||||
input.Views().Commits().
|
||||
SelectNextItem().
|
||||
SelectNextItem().
|
||||
SelectedLine(Contains("first commit"))
|
||||
|
||||
input.NextItem()
|
||||
input.NextItem()
|
||||
assert.Views().Current().SelectedLine(Contains("first commit"))
|
||||
input.Views().Main().Content(Contains("-second line\n-third line"))
|
||||
|
||||
assert.Views().Main().Content(Contains("-second line\n-third line"))
|
||||
input.Views().Commits().
|
||||
Press(keys.Universal.DiffingMenu)
|
||||
|
||||
input.Press(keys.Universal.DiffingMenu)
|
||||
input.Menu().Title(Equals("Diffing")).Select(Contains("reverse diff direction")).Confirm()
|
||||
input.ExpectMenu().Title(Equals("Diffing")).Select(Contains("reverse diff direction")).Confirm()
|
||||
|
||||
assert.Views().Main().Content(Contains("+second line\n+third line"))
|
||||
input.Views().Main().Content(Contains("+second line\n+third line"))
|
||||
|
||||
input.Enter()
|
||||
input.Views().Commits().
|
||||
PressEnter()
|
||||
|
||||
assert.Views().Current().Name("commitFiles").SelectedLine(Contains("file1"))
|
||||
assert.Views().Main().Content(Contains("+second line\n+third line"))
|
||||
input.Views().CommitFiles().
|
||||
IsFocused().
|
||||
SelectedLine(Contains("file1"))
|
||||
|
||||
input.Views().Main().Content(Contains("+second line\n+third line"))
|
||||
},
|
||||
})
|
||||
|
@ -21,10 +21,10 @@ var DirWithUntrackedFile = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
shell.CreateFile("dir/untracked", "bar")
|
||||
shell.UpdateFile("dir/file", "baz")
|
||||
},
|
||||
Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
|
||||
assert.Model().CommitCount(1)
|
||||
Run: func(shell *Shell, input *Input, keys config.KeybindingConfig) {
|
||||
input.Model().CommitCount(1)
|
||||
|
||||
assert.Views().Main().
|
||||
input.Views().Main().
|
||||
Content(DoesNotContain("error: Could not access")).
|
||||
// we show baz because it's a modified file but we don't show bar because it's untracked
|
||||
// (though it would be cool if we could show that too)
|
||||
|
@ -71,8 +71,8 @@ var DiscardChanges = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
shell.RunShellCommand(`echo "renamed\nhaha" > renamed2.txt && git add renamed2.txt`)
|
||||
},
|
||||
|
||||
Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
|
||||
assert.Model().CommitCount(3)
|
||||
Run: func(shell *Shell, input *Input, keys config.KeybindingConfig) {
|
||||
input.Model().CommitCount(3)
|
||||
|
||||
type statusFile struct {
|
||||
status string
|
||||
@ -82,9 +82,12 @@ var DiscardChanges = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
|
||||
discardOneByOne := func(files []statusFile) {
|
||||
for _, file := range files {
|
||||
assert.Views().Current().SelectedLine(Contains(file.status + " " + file.label))
|
||||
input.Press(keys.Universal.Remove)
|
||||
input.Menu().Title(Equals(file.menuTitle)).Select(Contains("discard all changes")).Confirm()
|
||||
input.Views().Files().
|
||||
IsFocused().
|
||||
SelectedLine(Contains(file.status + " " + file.label)).
|
||||
Press(keys.Universal.Remove)
|
||||
|
||||
input.ExpectMenu().Title(Equals(file.menuTitle)).Select(Contains("discard all changes")).Confirm()
|
||||
}
|
||||
}
|
||||
|
||||
@ -98,7 +101,7 @@ var DiscardChanges = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
{status: "DU", label: "deleted-us.txt", menuTitle: "deleted-us.txt"},
|
||||
})
|
||||
|
||||
input.Confirmation().
|
||||
input.ExpectConfirmation().
|
||||
Title(Equals("continue")).
|
||||
Content(Contains("all merge conflicts resolved. Continue?")).
|
||||
Cancel()
|
||||
@ -118,6 +121,6 @@ var DiscardChanges = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
{status: "??", label: "new.txt", menuTitle: "new.txt"},
|
||||
})
|
||||
|
||||
assert.Model().WorkingTreeFileCount(0)
|
||||
input.Model().WorkingTreeFileCount(0)
|
||||
},
|
||||
})
|
||||
|
@ -27,26 +27,27 @@ var AmendMerge = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Merge("feature-branch").
|
||||
CreateFileAndAdd(postMergeFilename, postMergeFileContent)
|
||||
},
|
||||
Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
|
||||
assert.Model().CommitCount(3)
|
||||
|
||||
input.SwitchToCommitsView()
|
||||
Run: func(shell *Shell, input *Input, keys config.KeybindingConfig) {
|
||||
input.Model().CommitCount(3)
|
||||
|
||||
mergeCommitMessage := "Merge branch 'feature-branch' into development-branch"
|
||||
assert.Model().HeadCommitMessage(Contains(mergeCommitMessage))
|
||||
input.Model().HeadCommitMessage(Contains(mergeCommitMessage))
|
||||
|
||||
input.Press(keys.Commits.AmendToCommit)
|
||||
input.Confirmation().
|
||||
input.Views().Commits().
|
||||
Focus().
|
||||
Press(keys.Commits.AmendToCommit)
|
||||
|
||||
input.ExpectConfirmation().
|
||||
Title(Equals("Amend Commit")).
|
||||
Content(Contains("Are you sure you want to amend this commit with your staged files?")).
|
||||
Confirm()
|
||||
|
||||
// assuring we haven't added a brand new commit
|
||||
assert.Model().CommitCount(3)
|
||||
assert.Model().HeadCommitMessage(Contains(mergeCommitMessage))
|
||||
input.Model().CommitCount(3)
|
||||
input.Model().HeadCommitMessage(Contains(mergeCommitMessage))
|
||||
|
||||
// assuring the post-merge file shows up in the merge commit.
|
||||
assert.Views().Main().
|
||||
input.Views().Main().
|
||||
Content(Contains(postMergeFilename)).
|
||||
Content(Contains("++" + postMergeFileContent))
|
||||
},
|
||||
|
@ -14,61 +14,56 @@ var One = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
shell.
|
||||
CreateNCommits(5) // these will appears at commit 05, 04, 04, down to 01
|
||||
},
|
||||
Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
|
||||
input.SwitchToCommitsView()
|
||||
assert.Views().Current().Lines(
|
||||
Contains("commit 05"),
|
||||
Contains("commit 04"),
|
||||
Contains("commit 03"),
|
||||
Contains("commit 02"),
|
||||
Contains("commit 01"),
|
||||
)
|
||||
|
||||
input.NavigateToListItem(Contains("commit 02"))
|
||||
input.Press(keys.Universal.Edit)
|
||||
|
||||
assert.Views().Current().Lines(
|
||||
MatchesRegexp("pick.*commit 05"),
|
||||
MatchesRegexp("pick.*commit 04"),
|
||||
MatchesRegexp("pick.*commit 03"),
|
||||
MatchesRegexp("YOU ARE HERE.*commit 02"),
|
||||
Contains("commit 01"),
|
||||
)
|
||||
|
||||
input.PreviousItem()
|
||||
input.Press(keys.Commits.MarkCommitAsFixup)
|
||||
assert.Views().Current().Lines(
|
||||
MatchesRegexp("pick.*commit 05"),
|
||||
MatchesRegexp("pick.*commit 04"),
|
||||
MatchesRegexp("fixup.*commit 03"),
|
||||
MatchesRegexp("YOU ARE HERE.*commit 02"),
|
||||
Contains("commit 01"),
|
||||
)
|
||||
|
||||
input.PreviousItem()
|
||||
input.Press(keys.Universal.Remove)
|
||||
assert.Views().Current().Lines(
|
||||
MatchesRegexp("pick.*commit 05"),
|
||||
MatchesRegexp("drop.*commit 04"),
|
||||
MatchesRegexp("fixup.*commit 03"),
|
||||
MatchesRegexp("YOU ARE HERE.*commit 02"),
|
||||
Contains("commit 01"),
|
||||
)
|
||||
|
||||
input.PreviousItem()
|
||||
input.Press(keys.Commits.SquashDown)
|
||||
|
||||
assert.Views().Current().Lines(
|
||||
MatchesRegexp("squash.*commit 05"),
|
||||
MatchesRegexp("drop.*commit 04"),
|
||||
MatchesRegexp("fixup.*commit 03"),
|
||||
MatchesRegexp("YOU ARE HERE.*commit 02"),
|
||||
Contains("commit 01"),
|
||||
)
|
||||
Run: func(shell *Shell, input *Input, keys config.KeybindingConfig) {
|
||||
input.Views().Commits().
|
||||
Focus().
|
||||
Lines(
|
||||
Contains("commit 05"),
|
||||
Contains("commit 04"),
|
||||
Contains("commit 03"),
|
||||
Contains("commit 02"),
|
||||
Contains("commit 01"),
|
||||
).
|
||||
NavigateToListItem(Contains("commit 02")).
|
||||
Press(keys.Universal.Edit).
|
||||
Lines(
|
||||
MatchesRegexp("pick.*commit 05"),
|
||||
MatchesRegexp("pick.*commit 04"),
|
||||
MatchesRegexp("pick.*commit 03"),
|
||||
MatchesRegexp("YOU ARE HERE.*commit 02").IsSelected(),
|
||||
Contains("commit 01"),
|
||||
).
|
||||
SelectPreviousItem().
|
||||
Press(keys.Commits.MarkCommitAsFixup).
|
||||
Lines(
|
||||
MatchesRegexp("pick.*commit 05"),
|
||||
MatchesRegexp("pick.*commit 04"),
|
||||
MatchesRegexp("fixup.*commit 03").IsSelected(),
|
||||
MatchesRegexp("YOU ARE HERE.*commit 02"),
|
||||
Contains("commit 01"),
|
||||
).
|
||||
SelectPreviousItem().
|
||||
Press(keys.Universal.Remove).
|
||||
Lines(
|
||||
MatchesRegexp("pick.*commit 05"),
|
||||
MatchesRegexp("drop.*commit 04").IsSelected(),
|
||||
MatchesRegexp("fixup.*commit 03"),
|
||||
MatchesRegexp("YOU ARE HERE.*commit 02"),
|
||||
Contains("commit 01"),
|
||||
).
|
||||
SelectPreviousItem().
|
||||
Press(keys.Commits.SquashDown).
|
||||
Lines(
|
||||
MatchesRegexp("squash.*commit 05").IsSelected(),
|
||||
MatchesRegexp("drop.*commit 04"),
|
||||
MatchesRegexp("fixup.*commit 03"),
|
||||
MatchesRegexp("YOU ARE HERE.*commit 02"),
|
||||
Contains("commit 01"),
|
||||
)
|
||||
|
||||
input.ContinueRebase()
|
||||
|
||||
assert.Views().Current().Lines(
|
||||
input.Views().Commits().Lines(
|
||||
Contains("commit 02"),
|
||||
Contains("commit 01"),
|
||||
)
|
||||
|
@ -13,11 +13,14 @@ var ConfirmOnQuit = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
config.UserConfig.ConfirmOnQuit = true
|
||||
},
|
||||
SetupRepo: func(shell *Shell) {},
|
||||
Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
|
||||
assert.Model().CommitCount(0)
|
||||
Run: func(shell *Shell, input *Input, keys config.KeybindingConfig) {
|
||||
input.Model().CommitCount(0)
|
||||
|
||||
input.Press(keys.Universal.Quit)
|
||||
input.Confirmation().
|
||||
input.Views().Files().
|
||||
IsFocused().
|
||||
Press(keys.Universal.Quit)
|
||||
|
||||
input.ExpectConfirmation().
|
||||
Title(Equals("")).
|
||||
Content(Contains("Are you sure you want to quit?")).
|
||||
Confirm()
|
||||
|
@ -18,18 +18,18 @@ var Rename = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
CreateFileAndAdd("file-2", "change to stash2").
|
||||
StashWithMessage("bar")
|
||||
},
|
||||
Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
|
||||
input.SwitchToStashView()
|
||||
Run: func(shell *Shell, input *Input, keys config.KeybindingConfig) {
|
||||
input.Views().Stash().
|
||||
Focus().
|
||||
Lines(
|
||||
Equals("On master: bar"),
|
||||
Equals("On master: foo"),
|
||||
).
|
||||
SelectNextItem().
|
||||
Press(keys.Stash.RenameStash)
|
||||
|
||||
assert.Views().Current().Lines(
|
||||
Equals("On master: bar"),
|
||||
Equals("On master: foo"),
|
||||
)
|
||||
input.NextItem()
|
||||
input.Press(keys.Stash.RenameStash)
|
||||
input.ExpectPrompt().Title(Equals("Rename stash: stash@{1}")).Type(" baz").Confirm()
|
||||
|
||||
input.Prompt().Title(Equals("Rename stash: stash@{1}")).Type(" baz").Confirm()
|
||||
|
||||
assert.Views().Current().SelectedLine(Equals("On master: foo baz"))
|
||||
input.Views().Stash().SelectedLine(Equals("On master: foo baz"))
|
||||
},
|
||||
})
|
||||
|
@ -15,17 +15,18 @@ var Stash = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
shell.CreateFile("file", "content")
|
||||
shell.GitAddAll()
|
||||
},
|
||||
Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
|
||||
assert.Model().StashCount(0)
|
||||
assert.Model().WorkingTreeFileCount(1)
|
||||
Run: func(shell *Shell, input *Input, keys config.KeybindingConfig) {
|
||||
input.Model().StashCount(0)
|
||||
input.Model().WorkingTreeFileCount(1)
|
||||
|
||||
input.Press(keys.Files.ViewStashOptions)
|
||||
input.Views().Files().
|
||||
Press(keys.Files.ViewStashOptions)
|
||||
|
||||
input.Menu().Title(Equals("Stash options")).Select(MatchesRegexp("stash all changes$")).Confirm()
|
||||
input.ExpectMenu().Title(Equals("Stash options")).Select(MatchesRegexp("stash all changes$")).Confirm()
|
||||
|
||||
input.Prompt().Title(Equals("Stash changes")).Type("my stashed file").Confirm()
|
||||
input.ExpectPrompt().Title(Equals("Stash changes")).Type("my stashed file").Confirm()
|
||||
|
||||
assert.Model().StashCount(1)
|
||||
assert.Model().WorkingTreeFileCount(0)
|
||||
input.Model().StashCount(1)
|
||||
input.Model().WorkingTreeFileCount(0)
|
||||
},
|
||||
})
|
||||
|
@ -16,17 +16,18 @@ var StashIncludingUntrackedFiles = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
shell.CreateFile("file_2", "content")
|
||||
shell.GitAdd("file_1")
|
||||
},
|
||||
Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
|
||||
assert.Model().StashCount(0)
|
||||
assert.Model().WorkingTreeFileCount(2)
|
||||
Run: func(shell *Shell, input *Input, keys config.KeybindingConfig) {
|
||||
input.Model().StashCount(0)
|
||||
input.Model().WorkingTreeFileCount(2)
|
||||
|
||||
input.Press(keys.Files.ViewStashOptions)
|
||||
input.Views().Files().
|
||||
Press(keys.Files.ViewStashOptions)
|
||||
|
||||
input.Menu().Title(Equals("Stash options")).Select(Contains("stash all changes including untracked files")).Confirm()
|
||||
input.ExpectMenu().Title(Equals("Stash options")).Select(Contains("stash all changes including untracked files")).Confirm()
|
||||
|
||||
input.Prompt().Title(Equals("Stash changes")).Type("my stashed file").Confirm()
|
||||
input.ExpectPrompt().Title(Equals("Stash changes")).Type("my stashed file").Confirm()
|
||||
|
||||
assert.Model().StashCount(1)
|
||||
assert.Model().WorkingTreeFileCount(0)
|
||||
input.Model().StashCount(1)
|
||||
input.Model().WorkingTreeFileCount(0)
|
||||
},
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user