mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-02-09 13:47:11 +02:00
rename input to t
This commit is contained in:
parent
53e06b71ae
commit
78b495f50a
@ -24,16 +24,15 @@ In the setup step, we prepare a repo with shell commands, for example, creating
|
||||
|
||||
### Run step
|
||||
|
||||
The run step has four arguments passed in:
|
||||
The run step has three arguments passed in:
|
||||
|
||||
1. `shell`
|
||||
2. `input`
|
||||
3. `assert`
|
||||
2. `t` (the test driver)
|
||||
4. `keys`
|
||||
|
||||
`shell` we've already seen in the setup step. The reason it's passed into the run step is that we may want to emulate background events. For example, the user modifying a file outside of lazygit.
|
||||
|
||||
`input` is for driving the gui by pressing certain keys, selecting list items, etc.
|
||||
`t` is for driving the gui by pressing certain keys, selecting list items, etc.
|
||||
|
||||
`assert` is for asserting on the state of the lazygit session. When you call a method on `assert`, the assert struct will wait for the assertion to hold true and then continue (failing the test after a timeout). For this reason, assertions have two purposes: one is to ensure the test fails as soon as something unexpected happens, but another is to allow lazygit to process a keypress before you follow up with more keypresses. If you input a bunch of keypresses too quickly lazygit might get confused.
|
||||
|
||||
@ -43,32 +42,21 @@ The run step has four arguments passed in:
|
||||
|
||||
Try to do as much setup work as possible in your setup step. For example, if all you're testing is that the user is able to resolve merge conflicts, create the merge conflicts in the setup step. On the other hand, if you're testing to see that lazygit can warn the user about merge conflicts after an attempted merge, it's fine to wait until the run step to actually create the conflicts. If the run step is focused on the thing you're trying to test, the test will run faster and its intent will be clearer.
|
||||
|
||||
#### Assert after input
|
||||
|
||||
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)
|
||||
input.InCommitMessagePanel()
|
||||
```
|
||||
|
||||
Note that there are some `input` methods that have assertions baked in, such as the `SwitchToView` methods.
|
||||
|
||||
#### Create helper functions for (very) frequently used test logic
|
||||
|
||||
If you find yourself doing something frequently in a test, consider making it a method in one of the helper arguments. For example, instead of calling `input.PressKey(keys.Universal.Confirm)` in 100 places, it's better to have a method `input.Confirm()`. This is not to say that everything should be made into a method on the input struct: just things that are particularly common in tests.
|
||||
If you find yourself doing something frequently in a test, consider making it a method in one of the helper arguments. For example, instead of calling `t.PressKey(keys.Universal.Confirm)` in 100 places, it's better to have a method `t.Confirm()`. This is not to say that everything should be made into a helper method: just things that are particularly common in tests.
|
||||
|
||||
Also, given how often we need to select a menu item or type into a prompt panel, there are some helper functions for that. For example:
|
||||
|
||||
```go
|
||||
// asserts that a prompt opens with the title 'Enter a file name', and then types 'my file' and confirms
|
||||
input.Prompt(Equals("Enter a file name"), "my file")
|
||||
t.Prompt(Equals("Enter a file name"), "my file")
|
||||
|
||||
// asserts that a menu opens with the title: 'Choose file content', and then selects the option which contains 'bar'
|
||||
input.Menu(Equals("Choose file content"), Contains("bar"))
|
||||
t.Menu(Equals("Choose file content"), Contains("bar"))
|
||||
|
||||
// asserts a confirmation appears with the title 'Are you sure?' and the content 'Are you REALLY sure' and then confirms
|
||||
input.AcceptConfirmation(Equals("Are you sure?"), Equals("Are you REALLY sure?"))
|
||||
t.AcceptConfirmation(Equals("Are you sure?"), Equals("Are you REALLY sure?"))
|
||||
```
|
||||
|
||||
## Running tests
|
||||
|
@ -1,13 +1,13 @@
|
||||
package components
|
||||
|
||||
type AlertAsserter struct {
|
||||
input *Input
|
||||
t *TestDriver
|
||||
hasCheckedTitle bool
|
||||
hasCheckedContent bool
|
||||
}
|
||||
|
||||
func (self *AlertAsserter) getViewAsserter() *View {
|
||||
return self.input.Views().Confirmation()
|
||||
return self.t.Views().Confirmation()
|
||||
}
|
||||
|
||||
// asserts that the alert view has the expected title
|
||||
@ -42,6 +42,6 @@ func (self *AlertAsserter) Cancel() {
|
||||
|
||||
func (self *AlertAsserter) checkNecessaryChecksCompleted() {
|
||||
if !self.hasCheckedContent || !self.hasCheckedTitle {
|
||||
self.input.Fail("You must both check the content and title of a confirmation popup by calling Title()/Content() before calling Confirm()/Cancel().")
|
||||
self.t.Fail("You must both check the content and title of a confirmation popup by calling Title()/Content() before calling Confirm()/Cancel().")
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,11 @@
|
||||
package components
|
||||
|
||||
type CommitMessagePanelAsserter struct {
|
||||
input *Input
|
||||
t *TestDriver
|
||||
}
|
||||
|
||||
func (self *CommitMessagePanelAsserter) getViewAsserter() *View {
|
||||
return self.input.Views().CommitMessage()
|
||||
return self.t.Views().CommitMessage()
|
||||
}
|
||||
|
||||
// asserts on the text initially present in the prompt
|
||||
@ -16,13 +16,13 @@ func (self *CommitMessagePanelAsserter) InitialText(expected *matcher) *CommitMe
|
||||
}
|
||||
|
||||
func (self *CommitMessagePanelAsserter) Type(value string) *CommitMessagePanelAsserter {
|
||||
self.input.typeContent(value)
|
||||
self.t.typeContent(value)
|
||||
|
||||
return self
|
||||
}
|
||||
|
||||
func (self *CommitMessagePanelAsserter) AddNewline() *CommitMessagePanelAsserter {
|
||||
self.input.press(self.input.keys.Universal.AppendNewline)
|
||||
self.t.press(self.t.keys.Universal.AppendNewline)
|
||||
|
||||
return self
|
||||
}
|
||||
|
@ -1,13 +1,13 @@
|
||||
package components
|
||||
|
||||
type ConfirmationAsserter struct {
|
||||
input *Input
|
||||
t *TestDriver
|
||||
hasCheckedTitle bool
|
||||
hasCheckedContent bool
|
||||
}
|
||||
|
||||
func (self *ConfirmationAsserter) getViewAsserter() *View {
|
||||
return self.input.Views().Confirmation()
|
||||
return self.t.Views().Confirmation()
|
||||
}
|
||||
|
||||
// asserts that the confirmation view has the expected title
|
||||
@ -42,6 +42,6 @@ func (self *ConfirmationAsserter) Cancel() {
|
||||
|
||||
func (self *ConfirmationAsserter) checkNecessaryChecksCompleted() {
|
||||
if !self.hasCheckedContent || !self.hasCheckedTitle {
|
||||
self.input.Fail("You must both check the content and title of a confirmation popup by calling Title()/Content() before calling Confirm()/Cancel().")
|
||||
self.t.Fail("You must both check the content and title of a confirmation popup by calling Title()/Content() before calling Confirm()/Cancel().")
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
package components
|
||||
|
||||
type MenuAsserter struct {
|
||||
input *Input
|
||||
t *TestDriver
|
||||
hasCheckedTitle bool
|
||||
}
|
||||
|
||||
func (self *MenuAsserter) getViewAsserter() *View {
|
||||
return self.input.Views().Menu()
|
||||
return self.t.Views().Menu()
|
||||
}
|
||||
|
||||
// asserts that the popup has the expected title
|
||||
@ -38,6 +38,6 @@ func (self *MenuAsserter) Select(option *matcher) *MenuAsserter {
|
||||
|
||||
func (self *MenuAsserter) checkNecessaryChecksCompleted() {
|
||||
if !self.hasCheckedTitle {
|
||||
self.input.Fail("You must check the title of a menu popup by calling Title() before calling Confirm()/Cancel().")
|
||||
self.t.Fail("You must check the title of a menu popup by calling Title() before calling Confirm()/Cancel().")
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
package components
|
||||
|
||||
type PromptAsserter struct {
|
||||
input *Input
|
||||
t *TestDriver
|
||||
hasCheckedTitle bool
|
||||
}
|
||||
|
||||
func (self *PromptAsserter) getViewAsserter() *View {
|
||||
return self.input.Views().Confirmation()
|
||||
return self.t.Views().Confirmation()
|
||||
}
|
||||
|
||||
// asserts that the popup has the expected title
|
||||
@ -26,7 +26,7 @@ func (self *PromptAsserter) InitialText(expected *matcher) *PromptAsserter {
|
||||
}
|
||||
|
||||
func (self *PromptAsserter) Type(value string) *PromptAsserter {
|
||||
self.input.typeContent(value)
|
||||
self.t.typeContent(value)
|
||||
|
||||
return self
|
||||
}
|
||||
@ -49,25 +49,25 @@ func (self *PromptAsserter) Cancel() {
|
||||
|
||||
func (self *PromptAsserter) checkNecessaryChecksCompleted() {
|
||||
if !self.hasCheckedTitle {
|
||||
self.input.Fail("You must check the title of a prompt popup by calling Title() before calling Confirm()/Cancel().")
|
||||
self.t.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.input.Views().Suggestions().Lines(matchers...)
|
||||
self.t.Views().Suggestions().Lines(matchers...)
|
||||
|
||||
return self
|
||||
}
|
||||
|
||||
func (self *PromptAsserter) SuggestionTopLines(matchers ...*matcher) *PromptAsserter {
|
||||
self.input.Views().Suggestions().TopLines(matchers...)
|
||||
self.t.Views().Suggestions().TopLines(matchers...)
|
||||
|
||||
return self
|
||||
}
|
||||
|
||||
func (self *PromptAsserter) SelectFirstSuggestion() *PromptAsserter {
|
||||
self.input.press(self.input.keys.Universal.TogglePanel)
|
||||
self.input.Views().Suggestions().
|
||||
self.t.press(self.t.keys.Universal.TogglePanel)
|
||||
self.t.Views().Suggestions().
|
||||
IsFocused().
|
||||
SelectedLineIdx(0)
|
||||
|
||||
@ -75,8 +75,8 @@ func (self *PromptAsserter) SelectFirstSuggestion() *PromptAsserter {
|
||||
}
|
||||
|
||||
func (self *PromptAsserter) SelectSuggestion(matcher *matcher) *PromptAsserter {
|
||||
self.input.press(self.input.keys.Universal.TogglePanel)
|
||||
self.input.Views().Suggestions().
|
||||
self.t.press(self.t.keys.Universal.TogglePanel)
|
||||
self.t.Views().Suggestions().
|
||||
IsFocused().
|
||||
NavigateToListItem(matcher)
|
||||
|
||||
|
@ -25,7 +25,7 @@ type IntegrationTest struct {
|
||||
setupConfig func(config *config.AppConfig)
|
||||
run func(
|
||||
shell *Shell,
|
||||
input *Input,
|
||||
testController *TestDriver,
|
||||
keys config.KeybindingConfig,
|
||||
)
|
||||
}
|
||||
@ -40,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, keys config.KeybindingConfig)
|
||||
Run func(shell *Shell, t *TestDriver, keys config.KeybindingConfig)
|
||||
// additional args passed to lazygit
|
||||
ExtraCmdArgs string
|
||||
// for when a test is flakey
|
||||
@ -94,13 +94,13 @@ func (self *IntegrationTest) SetupRepo(shell *Shell) {
|
||||
func (self *IntegrationTest) Run(gui integrationTypes.GuiDriver) {
|
||||
shell := NewShell("/tmp/lazygit-test")
|
||||
keys := gui.Keys()
|
||||
input := NewInput(gui, keys, KeyPressDelay())
|
||||
testController := NewTestController(gui, keys, KeyPressDelay())
|
||||
|
||||
self.run(shell, input, keys)
|
||||
self.run(shell, testController, keys)
|
||||
|
||||
if KeyPressDelay() > 0 {
|
||||
// the dev would want to see the final state if they're running in slow mode
|
||||
input.Wait(2000)
|
||||
testController.Wait(2000)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -11,15 +11,15 @@ import (
|
||||
"github.com/samber/lo"
|
||||
)
|
||||
|
||||
type Input struct {
|
||||
type TestDriver struct {
|
||||
gui integrationTypes.GuiDriver
|
||||
keys config.KeybindingConfig
|
||||
pushKeyDelay int
|
||||
*assertionHelper
|
||||
}
|
||||
|
||||
func NewInput(gui integrationTypes.GuiDriver, keys config.KeybindingConfig, pushKeyDelay int) *Input {
|
||||
return &Input{
|
||||
func NewTestController(gui integrationTypes.GuiDriver, keys config.KeybindingConfig, pushKeyDelay int) *TestDriver {
|
||||
return &TestDriver{
|
||||
gui: gui,
|
||||
keys: keys,
|
||||
pushKeyDelay: pushKeyDelay,
|
||||
@ -29,19 +29,19 @@ func NewInput(gui integrationTypes.GuiDriver, keys config.KeybindingConfig, push
|
||||
|
||||
// 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(keyStr string) {
|
||||
func (self *TestDriver) press(keyStr string) {
|
||||
self.Wait(self.pushKeyDelay)
|
||||
|
||||
self.gui.PressKey(keyStr)
|
||||
}
|
||||
|
||||
func (self *Input) typeContent(content string) {
|
||||
func (self *TestDriver) typeContent(content string) {
|
||||
for _, char := range content {
|
||||
self.press(string(char))
|
||||
}
|
||||
}
|
||||
|
||||
func (self *Input) ContinueMerge() {
|
||||
func (self *TestDriver) ContinueMerge() {
|
||||
self.Views().current().Press(self.keys.Universal.CreateRebaseOptionsMenu)
|
||||
|
||||
self.ExpectMenu().
|
||||
@ -50,20 +50,20 @@ func (self *Input) ContinueMerge() {
|
||||
Confirm()
|
||||
}
|
||||
|
||||
func (self *Input) ContinueRebase() {
|
||||
func (self *TestDriver) ContinueRebase() {
|
||||
self.ContinueMerge()
|
||||
}
|
||||
|
||||
// for when you want to allow lazygit to process something before continuing
|
||||
func (self *Input) Wait(milliseconds int) {
|
||||
func (self *TestDriver) Wait(milliseconds int) {
|
||||
time.Sleep(time.Duration(milliseconds) * time.Millisecond)
|
||||
}
|
||||
|
||||
func (self *Input) LogUI(message string) {
|
||||
func (self *TestDriver) LogUI(message string) {
|
||||
self.gui.LogUI(message)
|
||||
}
|
||||
|
||||
func (self *Input) Log(message string) {
|
||||
func (self *TestDriver) Log(message string) {
|
||||
self.gui.LogUI(message)
|
||||
}
|
||||
|
||||
@ -78,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 *TestDriver) navigateToListItem(matcher *matcher) {
|
||||
self.inListContext()
|
||||
|
||||
currentContext := self.gui.CurrentContext().(types.IListContext)
|
||||
@ -128,7 +128,7 @@ func (self *Input) navigateToListItem(matcher *matcher) {
|
||||
}
|
||||
}
|
||||
|
||||
func (self *Input) inListContext() {
|
||||
func (self *TestDriver) inListContext() {
|
||||
self.assertWithRetries(func() (bool, string) {
|
||||
currentContext := self.gui.CurrentContext()
|
||||
_, ok := currentContext.(types.IListContext)
|
||||
@ -136,39 +136,39 @@ func (self *Input) inListContext() {
|
||||
})
|
||||
}
|
||||
|
||||
func (self *Input) ExpectConfirmation() *ConfirmationAsserter {
|
||||
func (self *TestDriver) ExpectConfirmation() *ConfirmationAsserter {
|
||||
self.inConfirm()
|
||||
|
||||
return &ConfirmationAsserter{input: self}
|
||||
return &ConfirmationAsserter{t: self}
|
||||
}
|
||||
|
||||
func (self *Input) inConfirm() {
|
||||
func (self *TestDriver) inConfirm() {
|
||||
self.assertWithRetries(func() (bool, string) {
|
||||
currentView := self.gui.CurrentContext().GetView()
|
||||
return currentView.Name() == "confirmation" && !currentView.Editable, "Expected confirmation popup to be focused"
|
||||
})
|
||||
}
|
||||
|
||||
func (self *Input) ExpectPrompt() *PromptAsserter {
|
||||
func (self *TestDriver) ExpectPrompt() *PromptAsserter {
|
||||
self.inPrompt()
|
||||
|
||||
return &PromptAsserter{input: self}
|
||||
return &PromptAsserter{t: self}
|
||||
}
|
||||
|
||||
func (self *Input) inPrompt() {
|
||||
func (self *TestDriver) inPrompt() {
|
||||
self.assertWithRetries(func() (bool, string) {
|
||||
currentView := self.gui.CurrentContext().GetView()
|
||||
return currentView.Name() == "confirmation" && currentView.Editable, "Expected prompt popup to be focused"
|
||||
})
|
||||
}
|
||||
|
||||
func (self *Input) ExpectAlert() *AlertAsserter {
|
||||
func (self *TestDriver) ExpectAlert() *AlertAsserter {
|
||||
self.inAlert()
|
||||
|
||||
return &AlertAsserter{input: self}
|
||||
return &AlertAsserter{t: self}
|
||||
}
|
||||
|
||||
func (self *Input) inAlert() {
|
||||
func (self *TestDriver) inAlert() {
|
||||
// basically the same thing as a confirmation popup with the current implementation
|
||||
self.assertWithRetries(func() (bool, string) {
|
||||
currentView := self.gui.CurrentContext().GetView()
|
||||
@ -176,32 +176,32 @@ func (self *Input) inAlert() {
|
||||
})
|
||||
}
|
||||
|
||||
func (self *Input) ExpectMenu() *MenuAsserter {
|
||||
func (self *TestDriver) ExpectMenu() *MenuAsserter {
|
||||
self.inMenu()
|
||||
|
||||
return &MenuAsserter{input: self}
|
||||
return &MenuAsserter{t: self}
|
||||
}
|
||||
|
||||
func (self *Input) inMenu() {
|
||||
func (self *TestDriver) inMenu() {
|
||||
self.assertWithRetries(func() (bool, string) {
|
||||
return self.gui.CurrentContext().GetView().Name() == "menu", "Expected popup menu to be focused"
|
||||
})
|
||||
}
|
||||
|
||||
func (self *Input) ExpectCommitMessagePanel() *CommitMessagePanelAsserter {
|
||||
func (self *TestDriver) ExpectCommitMessagePanel() *CommitMessagePanelAsserter {
|
||||
self.inCommitMessagePanel()
|
||||
|
||||
return &CommitMessagePanelAsserter{input: self}
|
||||
return &CommitMessagePanelAsserter{t: self}
|
||||
}
|
||||
|
||||
func (self *Input) inCommitMessagePanel() {
|
||||
func (self *TestDriver) inCommitMessagePanel() {
|
||||
self.assertWithRetries(func() (bool, string) {
|
||||
currentView := self.gui.CurrentContext().GetView()
|
||||
return currentView.Name() == "commitMessage", "Expected commit message panel to be focused"
|
||||
})
|
||||
}
|
||||
|
||||
func (self *Input) currentWindowName(expectedWindowName string) {
|
||||
func (self *TestDriver) currentWindowName(expectedWindowName string) {
|
||||
self.assertWithRetries(func() (bool, string) {
|
||||
actual := self.gui.CurrentContext().GetView().Name()
|
||||
return actual == expectedWindowName, fmt.Sprintf("Expected current window name to be '%s', but got '%s'", expectedWindowName, actual)
|
||||
@ -209,27 +209,27 @@ func (self *Input) currentWindowName(expectedWindowName string) {
|
||||
}
|
||||
|
||||
// for making assertions on lazygit views
|
||||
func (self *Input) Views() *Views {
|
||||
return &Views{input: self}
|
||||
func (self *TestDriver) Views() *Views {
|
||||
return &Views{t: self}
|
||||
}
|
||||
|
||||
// for making assertions on the lazygit model
|
||||
func (self *Input) Model() *Model {
|
||||
func (self *TestDriver) Model() *Model {
|
||||
return &Model{assertionHelper: self.assertionHelper, gui: self.gui}
|
||||
}
|
||||
|
||||
// for making assertions on the file system
|
||||
func (self *Input) FileSystem() *FileSystem {
|
||||
func (self *TestDriver) 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) {
|
||||
func (self *TestDriver) Fail(message string) {
|
||||
self.assertionHelper.fail(message)
|
||||
}
|
||||
|
||||
func (self *Input) NotInPopup() {
|
||||
func (self *TestDriver) 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)
|
@ -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, keys config.KeybindingConfig) {
|
||||
input.press("a")
|
||||
input.press("b")
|
||||
input.Model().CommitCount(2)
|
||||
Run: func(shell *Shell, t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.press("a")
|
||||
t.press("b")
|
||||
t.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, keys config.KeybindingConfig) {
|
||||
input.Fail("blah")
|
||||
Run: func(shell *Shell, t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.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, keys config.KeybindingConfig) {
|
||||
input.press("a")
|
||||
input.press("b")
|
||||
input.Model().CommitCount(0)
|
||||
Run: func(shell *Shell, t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.press("a")
|
||||
t.press("b")
|
||||
t.Model().CommitCount(0)
|
||||
},
|
||||
})
|
||||
driver := &fakeGuiDriver{}
|
||||
|
@ -10,23 +10,12 @@ 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
|
||||
t *TestDriver
|
||||
}
|
||||
|
||||
// asserts that the view has the expected title
|
||||
func (self *View) Title(expected *matcher) *View {
|
||||
self.input.assertWithRetries(func() (bool, string) {
|
||||
self.t.assertWithRetries(func() (bool, string) {
|
||||
actual := self.getView().Title
|
||||
return expected.context(fmt.Sprintf("%s title", self.context)).test(actual)
|
||||
})
|
||||
@ -39,7 +28,7 @@ func (self *View) Title(expected *matcher) *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) {
|
||||
self.t.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))
|
||||
})
|
||||
@ -50,7 +39,7 @@ func (self *View) TopLines(matchers ...*matcher) *View {
|
||||
// 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) {
|
||||
self.t.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))
|
||||
})
|
||||
@ -64,14 +53,14 @@ func (self *View) assertLines(matchers ...*matcher) *View {
|
||||
for i, matcher := range matchers {
|
||||
checkIsSelected, matcher := matcher.checkIsSelected()
|
||||
|
||||
self.input.matchString(matcher, fmt.Sprintf("Unexpected content in view '%s'.", view.Name()),
|
||||
self.t.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) {
|
||||
self.t.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)
|
||||
})
|
||||
@ -83,7 +72,7 @@ func (self *View) assertLines(matchers ...*matcher) *View {
|
||||
|
||||
// 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),
|
||||
self.t.matchString(matcher, fmt.Sprintf("%s: Unexpected content.", self.context),
|
||||
func() string {
|
||||
return self.getView().Buffer()
|
||||
},
|
||||
@ -94,7 +83,7 @@ func (self *View) Content(matcher *matcher) *View {
|
||||
|
||||
// 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),
|
||||
self.t.matchString(matcher, fmt.Sprintf("%s: Unexpected selected line.", self.context),
|
||||
func() string {
|
||||
return self.getView().SelectedLine()
|
||||
},
|
||||
@ -105,7 +94,7 @@ func (self *View) SelectedLine(matcher *matcher) *View {
|
||||
|
||||
// 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) {
|
||||
self.t.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)
|
||||
})
|
||||
@ -132,10 +121,10 @@ func (self *View) Focus() *View {
|
||||
|
||||
index, ok := windowIndexMap[viewName]
|
||||
if !ok {
|
||||
self.input.fail(fmt.Sprintf("Cannot focus view %s: Focus() method not implemented", viewName))
|
||||
self.t.fail(fmt.Sprintf("Cannot focus view %s: Focus() method not implemented", viewName))
|
||||
}
|
||||
|
||||
self.input.press(self.input.keys.Universal.JumpToBlock[index])
|
||||
self.t.press(self.t.keys.Universal.JumpToBlock[index])
|
||||
|
||||
// assert that we land in the expected view
|
||||
self.IsFocused()
|
||||
@ -145,9 +134,9 @@ func (self *View) Focus() *View {
|
||||
|
||||
// asserts that the view is focused
|
||||
func (self *View) IsFocused() *View {
|
||||
self.input.assertWithRetries(func() (bool, string) {
|
||||
self.t.assertWithRetries(func() (bool, string) {
|
||||
expected := self.getView().Name()
|
||||
actual := self.input.gui.CurrentContext().GetView().Name()
|
||||
actual := self.t.gui.CurrentContext().GetView().Name()
|
||||
return actual == expected, fmt.Sprintf("%s: Unexpected view focused. Expected %s, got %s", self.context, expected, actual)
|
||||
})
|
||||
|
||||
@ -157,40 +146,40 @@ func (self *View) IsFocused() *View {
|
||||
func (self *View) Press(keyStr string) *View {
|
||||
self.IsFocused()
|
||||
|
||||
self.input.press(keyStr)
|
||||
self.t.press(keyStr)
|
||||
|
||||
return self
|
||||
}
|
||||
|
||||
// i.e. pressing down arrow
|
||||
func (self *View) SelectNextItem() *View {
|
||||
return self.Press(self.input.keys.Universal.NextItem)
|
||||
return self.Press(self.t.keys.Universal.NextItem)
|
||||
}
|
||||
|
||||
// i.e. pressing up arrow
|
||||
func (self *View) SelectPreviousItem() *View {
|
||||
return self.Press(self.input.keys.Universal.PrevItem)
|
||||
return self.Press(self.t.keys.Universal.PrevItem)
|
||||
}
|
||||
|
||||
// i.e. pressing space
|
||||
func (self *View) PressPrimaryAction() *View {
|
||||
return self.Press(self.input.keys.Universal.Select)
|
||||
return self.Press(self.t.keys.Universal.Select)
|
||||
}
|
||||
|
||||
// i.e. pressing space
|
||||
func (self *View) PressEnter() *View {
|
||||
return self.Press(self.input.keys.Universal.Confirm)
|
||||
return self.Press(self.t.keys.Universal.Confirm)
|
||||
}
|
||||
|
||||
// i.e. pressing escape
|
||||
func (self *View) PressEscape() *View {
|
||||
return self.Press(self.input.keys.Universal.Return)
|
||||
return self.Press(self.t.keys.Universal.Return)
|
||||
}
|
||||
|
||||
func (self *View) NavigateToListItem(matcher *matcher) *View {
|
||||
self.IsFocused()
|
||||
|
||||
self.input.navigateToListItem(matcher)
|
||||
self.t.navigateToListItem(matcher)
|
||||
|
||||
return self
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
)
|
||||
|
||||
type Views struct {
|
||||
input *Input
|
||||
t *TestDriver
|
||||
}
|
||||
|
||||
// not exporting this because I want the test to always be explicit about what
|
||||
@ -15,32 +15,32 @@ type Views struct {
|
||||
func (self *Views) current() *View {
|
||||
return &View{
|
||||
context: "current view",
|
||||
getView: func() *gocui.View { return self.input.gui.CurrentContext().GetView() },
|
||||
input: self.input,
|
||||
getView: func() *gocui.View { return self.t.gui.CurrentContext().GetView() },
|
||||
t: self.t,
|
||||
}
|
||||
}
|
||||
|
||||
func (self *Views) Main() *View {
|
||||
return &View{
|
||||
context: "main view",
|
||||
getView: func() *gocui.View { return self.input.gui.MainView() },
|
||||
input: self.input,
|
||||
getView: func() *gocui.View { return self.t.gui.MainView() },
|
||||
t: self.t,
|
||||
}
|
||||
}
|
||||
|
||||
func (self *Views) Secondary() *View {
|
||||
return &View{
|
||||
context: "secondary view",
|
||||
getView: func() *gocui.View { return self.input.gui.SecondaryView() },
|
||||
input: self.input,
|
||||
getView: func() *gocui.View { return self.t.gui.SecondaryView() },
|
||||
t: self.t,
|
||||
}
|
||||
}
|
||||
|
||||
func (self *Views) ByName(viewName string) *View {
|
||||
return &View{
|
||||
context: fmt.Sprintf("%s view", viewName),
|
||||
getView: func() *gocui.View { return self.input.gui.View(viewName) },
|
||||
input: self.input,
|
||||
getView: func() *gocui.View { return self.t.gui.View(viewName) },
|
||||
t: self.t,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -16,33 +16,33 @@ var Basic = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
SetupConfig: func(cfg *config.AppConfig) {},
|
||||
Run: func(
|
||||
shell *Shell,
|
||||
input *Input,
|
||||
t *TestDriver,
|
||||
keys config.KeybindingConfig,
|
||||
) {
|
||||
markCommitAsBad := func() {
|
||||
input.Views().Commits().
|
||||
t.Views().Commits().
|
||||
Press(keys.Commits.ViewBisectOptions)
|
||||
|
||||
input.ExpectMenu().Title(Equals("Bisect")).Select(MatchesRegexp(`mark .* as bad`)).Confirm()
|
||||
t.ExpectMenu().Title(Equals("Bisect")).Select(MatchesRegexp(`mark .* as bad`)).Confirm()
|
||||
}
|
||||
|
||||
markCommitAsGood := func() {
|
||||
input.Views().Commits().
|
||||
t.Views().Commits().
|
||||
Press(keys.Commits.ViewBisectOptions)
|
||||
|
||||
input.ExpectMenu().Title(Equals("Bisect")).Select(MatchesRegexp(`mark .* as good`)).Confirm()
|
||||
t.ExpectMenu().Title(Equals("Bisect")).Select(MatchesRegexp(`mark .* as good`)).Confirm()
|
||||
}
|
||||
|
||||
input.Model().AtLeastOneCommit()
|
||||
t.Model().AtLeastOneCommit()
|
||||
|
||||
input.Views().Commits().
|
||||
t.Views().Commits().
|
||||
Focus().
|
||||
SelectedLine(Contains("commit 10")).
|
||||
NavigateToListItem(Contains("commit 09")).
|
||||
Tap(func() {
|
||||
markCommitAsBad()
|
||||
|
||||
input.Views().Information().Content(Contains("bisecting"))
|
||||
t.Views().Information().Content(Contains("bisecting"))
|
||||
}).
|
||||
SelectedLine(Contains("<-- bad")).
|
||||
NavigateToListItem(Contains("commit 02")).
|
||||
@ -55,11 +55,11 @@ var Basic = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
markCommitAsGood()
|
||||
|
||||
// commit 5 is the culprit because we marked 4 as good and 5 as bad.
|
||||
input.ExpectAlert().Title(Equals("Bisect complete")).Content(MatchesRegexp("(?s)commit 05.*Do you want to reset")).Confirm()
|
||||
t.ExpectAlert().Title(Equals("Bisect complete")).Content(MatchesRegexp("(?s)commit 05.*Do you want to reset")).Confirm()
|
||||
}).
|
||||
IsFocused().
|
||||
Content(Contains("commit 04"))
|
||||
|
||||
input.Views().Information().Content(DoesNotContain("bisecting"))
|
||||
t.Views().Information().Content(DoesNotContain("bisecting"))
|
||||
},
|
||||
})
|
||||
|
@ -20,14 +20,14 @@ var FromOtherBranch = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
SetupConfig: func(cfg *config.AppConfig) {},
|
||||
Run: func(
|
||||
shell *Shell,
|
||||
input *Input,
|
||||
t *TestDriver,
|
||||
keys config.KeybindingConfig,
|
||||
) {
|
||||
input.Views().Information().Content(Contains("bisecting"))
|
||||
t.Views().Information().Content(Contains("bisecting"))
|
||||
|
||||
input.Model().AtLeastOneCommit()
|
||||
t.Model().AtLeastOneCommit()
|
||||
|
||||
input.Views().Commits().
|
||||
t.Views().Commits().
|
||||
Focus().
|
||||
TopLines(
|
||||
MatchesRegexp(`<-- bad.*commit 08`),
|
||||
@ -38,11 +38,11 @@ var FromOtherBranch = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
SelectNextItem().
|
||||
Press(keys.Commits.ViewBisectOptions).
|
||||
Tap(func() {
|
||||
input.ExpectMenu().Title(Equals("Bisect")).Select(MatchesRegexp(`mark .* as good`)).Confirm()
|
||||
t.ExpectMenu().Title(Equals("Bisect")).Select(MatchesRegexp(`mark .* as good`)).Confirm()
|
||||
|
||||
input.ExpectAlert().Title(Equals("Bisect complete")).Content(MatchesRegexp("(?s)commit 08.*Do you want to reset")).Confirm()
|
||||
t.ExpectAlert().Title(Equals("Bisect complete")).Content(MatchesRegexp("(?s)commit 08.*Do you want to reset")).Confirm()
|
||||
|
||||
input.Views().Information().Content(DoesNotContain("bisecting"))
|
||||
t.Views().Information().Content(DoesNotContain("bisecting"))
|
||||
}).
|
||||
// back in master branch which just had the one commit
|
||||
Lines(
|
||||
|
@ -17,8 +17,8 @@ var CheckoutByName = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Checkout("master").
|
||||
EmptyCommit("blah")
|
||||
},
|
||||
Run: func(shell *Shell, input *Input, keys config.KeybindingConfig) {
|
||||
input.Views().Branches().
|
||||
Run: func(shell *Shell, t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.Views().Branches().
|
||||
Focus().
|
||||
Lines(
|
||||
Contains("master").IsSelected(),
|
||||
@ -27,9 +27,9 @@ var CheckoutByName = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
SelectNextItem().
|
||||
Press(keys.Branches.CheckoutBranchByName).
|
||||
Tap(func() {
|
||||
input.ExpectPrompt().Title(Equals("Branch name:")).Type("new-branch").Confirm()
|
||||
t.ExpectPrompt().Title(Equals("Branch name:")).Type("new-branch").Confirm()
|
||||
|
||||
input.ExpectAlert().Title(Equals("Branch not found")).Content(Equals("Branch not found. Create a new branch named new-branch?")).Confirm()
|
||||
t.ExpectAlert().Title(Equals("Branch not found")).Content(Equals("Branch not found. Create a new branch named new-branch?")).Confirm()
|
||||
}).
|
||||
Lines(
|
||||
MatchesRegexp(`\*.*new-branch`).IsSelected(),
|
||||
|
@ -16,8 +16,8 @@ var Delete = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
NewBranch("branch-one").
|
||||
NewBranch("branch-two")
|
||||
},
|
||||
Run: func(shell *Shell, input *Input, keys config.KeybindingConfig) {
|
||||
input.Views().Branches().
|
||||
Run: func(shell *Shell, t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.Views().Branches().
|
||||
Focus().
|
||||
Lines(
|
||||
MatchesRegexp(`\*.*branch-two`).IsSelected(),
|
||||
@ -26,12 +26,12 @@ var Delete = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
).
|
||||
Press(keys.Universal.Remove).
|
||||
Tap(func() {
|
||||
input.ExpectAlert().Title(Equals("Error")).Content(Contains("You cannot delete the checked out branch!")).Confirm()
|
||||
t.ExpectAlert().Title(Equals("Error")).Content(Contains("You cannot delete the checked out branch!")).Confirm()
|
||||
}).
|
||||
SelectNextItem().
|
||||
Press(keys.Universal.Remove).
|
||||
Tap(func() {
|
||||
input.ExpectConfirmation().
|
||||
t.ExpectConfirmation().
|
||||
Title(Equals("Delete Branch")).
|
||||
Content(Contains("Are you sure you want to delete the branch 'branch-one'?")).
|
||||
Confirm()
|
||||
|
@ -14,13 +14,13 @@ var Rebase = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
SetupRepo: func(shell *Shell) {
|
||||
shared.MergeConflictsSetup(shell)
|
||||
},
|
||||
Run: func(shell *Shell, input *Input, keys config.KeybindingConfig) {
|
||||
input.Views().Commits().TopLines(
|
||||
Run: func(shell *Shell, t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.Views().Commits().TopLines(
|
||||
Contains("first change"),
|
||||
Contains("original"),
|
||||
)
|
||||
|
||||
input.Views().Branches().
|
||||
t.Views().Branches().
|
||||
Focus().
|
||||
Lines(
|
||||
Contains("first-change-branch"),
|
||||
@ -30,35 +30,35 @@ var Rebase = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
SelectNextItem().
|
||||
Press(keys.Branches.RebaseBranch)
|
||||
|
||||
input.ExpectConfirmation().
|
||||
t.ExpectConfirmation().
|
||||
Title(Equals("Rebasing")).
|
||||
Content(Contains("Are you sure you want to rebase 'first-change-branch' on top of 'second-change-branch'?")).
|
||||
Confirm()
|
||||
|
||||
input.ExpectConfirmation().
|
||||
t.ExpectConfirmation().
|
||||
Title(Equals("Auto-merge failed")).
|
||||
Content(Contains("Conflicts!")).
|
||||
Confirm()
|
||||
|
||||
input.Views().Files().
|
||||
t.Views().Files().
|
||||
IsFocused().
|
||||
SelectedLine(Contains("file")).
|
||||
PressEnter()
|
||||
|
||||
input.Views().MergeConflicts().
|
||||
t.Views().MergeConflicts().
|
||||
IsFocused().
|
||||
PressPrimaryAction()
|
||||
|
||||
input.Views().Information().Content(Contains("rebasing"))
|
||||
t.Views().Information().Content(Contains("rebasing"))
|
||||
|
||||
input.ExpectConfirmation().
|
||||
t.ExpectConfirmation().
|
||||
Title(Equals("continue")).
|
||||
Content(Contains("all merge conflicts resolved. Continue?")).
|
||||
Confirm()
|
||||
|
||||
input.Views().Information().Content(DoesNotContain("rebasing"))
|
||||
t.Views().Information().Content(DoesNotContain("rebasing"))
|
||||
|
||||
input.Views().Commits().TopLines(
|
||||
t.Views().Commits().TopLines(
|
||||
Contains("second-change-branch unrelated change"),
|
||||
Contains("second change"),
|
||||
Contains("original"),
|
||||
|
@ -17,8 +17,8 @@ var RebaseAndDrop = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
shell.EmptyCommit("to remove")
|
||||
shell.EmptyCommit("to keep")
|
||||
},
|
||||
Run: func(shell *Shell, input *Input, keys config.KeybindingConfig) {
|
||||
input.Views().Branches().
|
||||
Run: func(shell *Shell, t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.Views().Branches().
|
||||
Focus().
|
||||
Lines(
|
||||
Contains("first-change-branch"),
|
||||
@ -26,7 +26,7 @@ var RebaseAndDrop = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Contains("original-branch"),
|
||||
)
|
||||
|
||||
input.Views().Commits().
|
||||
t.Views().Commits().
|
||||
TopLines(
|
||||
Contains("to keep").IsSelected(),
|
||||
Contains("to remove"),
|
||||
@ -36,22 +36,22 @@ var RebaseAndDrop = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
SelectNextItem().
|
||||
Press(keys.Branches.RebaseBranch)
|
||||
|
||||
input.ExpectConfirmation().
|
||||
t.ExpectConfirmation().
|
||||
Title(Equals("Rebasing")).
|
||||
Content(Contains("Are you sure you want to rebase 'first-change-branch' on top of 'second-change-branch'?")).
|
||||
Confirm()
|
||||
|
||||
input.Views().Information().Content(Contains("rebasing"))
|
||||
t.Views().Information().Content(Contains("rebasing"))
|
||||
|
||||
input.ExpectConfirmation().
|
||||
t.ExpectConfirmation().
|
||||
Title(Equals("Auto-merge failed")).
|
||||
Content(Contains("Conflicts!")).
|
||||
Confirm()
|
||||
|
||||
input.Views().Files().IsFocused().
|
||||
t.Views().Files().IsFocused().
|
||||
SelectedLine(MatchesRegexp("UU.*file"))
|
||||
|
||||
input.Views().Commits().
|
||||
t.Views().Commits().
|
||||
Focus().
|
||||
TopLines(
|
||||
MatchesRegexp(`pick.*to keep`).IsSelected(),
|
||||
@ -70,22 +70,22 @@ var RebaseAndDrop = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
MatchesRegexp("original"),
|
||||
)
|
||||
|
||||
input.Views().Files().
|
||||
t.Views().Files().
|
||||
Focus().
|
||||
PressEnter()
|
||||
|
||||
input.Views().MergeConflicts().
|
||||
t.Views().MergeConflicts().
|
||||
IsFocused().
|
||||
PressPrimaryAction()
|
||||
|
||||
input.ExpectConfirmation().
|
||||
t.ExpectConfirmation().
|
||||
Title(Equals("continue")).
|
||||
Content(Contains("all merge conflicts resolved. Continue?")).
|
||||
Confirm()
|
||||
|
||||
input.Views().Information().Content(DoesNotContain("rebasing"))
|
||||
t.Views().Information().Content(DoesNotContain("rebasing"))
|
||||
|
||||
input.Views().Commits().TopLines(
|
||||
t.Views().Commits().TopLines(
|
||||
Contains("to keep"),
|
||||
Contains("second-change-branch unrelated change").IsSelected(),
|
||||
Contains("second change"),
|
||||
|
@ -20,13 +20,13 @@ var Reset = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
shell.Checkout("current-branch")
|
||||
shell.EmptyCommit("current-branch commit")
|
||||
},
|
||||
Run: func(shell *Shell, input *Input, keys config.KeybindingConfig) {
|
||||
input.Views().Commits().Lines(
|
||||
Run: func(shell *Shell, t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.Views().Commits().Lines(
|
||||
Contains("current-branch commit"),
|
||||
Contains("root commit"),
|
||||
)
|
||||
|
||||
input.Views().Branches().
|
||||
t.Views().Branches().
|
||||
Focus().
|
||||
Lines(
|
||||
Contains("current-branch"),
|
||||
@ -35,10 +35,10 @@ var Reset = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
SelectNextItem().
|
||||
Press(keys.Commits.ViewResetOptions)
|
||||
|
||||
input.ExpectMenu().Title(Contains("reset to other-branch")).Select(Contains("hard reset")).Confirm()
|
||||
t.ExpectMenu().Title(Contains("reset to other-branch")).Select(Contains("hard reset")).Confirm()
|
||||
|
||||
// assert that we now have the expected commits in the commit panel
|
||||
input.Views().Commits().
|
||||
t.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, keys config.KeybindingConfig) {
|
||||
input.Views().Branches().
|
||||
Run: func(shell *Shell, t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.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.ExpectPrompt().
|
||||
t.ExpectPrompt().
|
||||
Title(Equals("Branch name:")).
|
||||
Type("branch-to").
|
||||
SuggestionTopLines(Contains("branch-to-checkout")).
|
||||
SelectFirstSuggestion().
|
||||
Confirm()
|
||||
|
||||
input.Model().CurrentBranchName("branch-to-checkout")
|
||||
t.Model().CurrentBranchName("branch-to-checkout")
|
||||
},
|
||||
})
|
||||
|
@ -23,8 +23,8 @@ var CherryPick = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
EmptyCommit("four").
|
||||
Checkout("first-branch")
|
||||
},
|
||||
Run: func(shell *Shell, input *Input, keys config.KeybindingConfig) {
|
||||
input.Views().Branches().
|
||||
Run: func(shell *Shell, t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.Views().Branches().
|
||||
Focus().
|
||||
Lines(
|
||||
Contains("first-branch"),
|
||||
@ -34,7 +34,7 @@ var CherryPick = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
SelectNextItem().
|
||||
PressEnter()
|
||||
|
||||
input.Views().SubCommits().
|
||||
t.Views().SubCommits().
|
||||
IsFocused().
|
||||
Lines(
|
||||
Contains("four").IsSelected(),
|
||||
@ -44,14 +44,14 @@ var CherryPick = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
// copy commits 'four' and 'three'
|
||||
Press(keys.Commits.CherryPickCopy).
|
||||
Tap(func() {
|
||||
input.Views().Information().Content(Contains("1 commit copied"))
|
||||
t.Views().Information().Content(Contains("1 commit copied"))
|
||||
}).
|
||||
SelectNextItem().
|
||||
Press(keys.Commits.CherryPickCopy)
|
||||
|
||||
input.Views().Information().Content(Contains("2 commits copied"))
|
||||
t.Views().Information().Content(Contains("2 commits copied"))
|
||||
|
||||
input.Views().Commits().
|
||||
t.Views().Commits().
|
||||
Focus().
|
||||
Lines(
|
||||
Contains("two").IsSelected(),
|
||||
@ -60,7 +60,7 @@ var CherryPick = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
).
|
||||
Press(keys.Commits.PasteCommits).
|
||||
Tap(func() {
|
||||
input.ExpectAlert().
|
||||
t.ExpectAlert().
|
||||
Title(Equals("Cherry-Pick")).
|
||||
Content(Contains("Are you sure you want to cherry-pick the copied commits onto this branch?")).
|
||||
Confirm()
|
||||
@ -74,11 +74,11 @@ var CherryPick = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
).
|
||||
Tap(func() {
|
||||
// we need to manually exit out of cherry pick mode
|
||||
input.Views().Information().Content(Contains("2 commits copied"))
|
||||
t.Views().Information().Content(Contains("2 commits copied"))
|
||||
}).
|
||||
PressEscape().
|
||||
Tap(func() {
|
||||
input.Views().Information().Content(DoesNotContain("commits copied"))
|
||||
t.Views().Information().Content(DoesNotContain("commits copied"))
|
||||
})
|
||||
},
|
||||
})
|
||||
|
@ -14,8 +14,8 @@ var CherryPickConflicts = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
SetupRepo: func(shell *Shell) {
|
||||
shared.MergeConflictsSetup(shell)
|
||||
},
|
||||
Run: func(shell *Shell, input *Input, keys config.KeybindingConfig) {
|
||||
input.Views().Branches().
|
||||
Run: func(shell *Shell, t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.Views().Branches().
|
||||
Focus().
|
||||
Lines(
|
||||
Contains("first-change-branch"),
|
||||
@ -25,7 +25,7 @@ var CherryPickConflicts = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
SelectNextItem().
|
||||
PressEnter()
|
||||
|
||||
input.Views().SubCommits().
|
||||
t.Views().SubCommits().
|
||||
IsFocused().
|
||||
TopLines(
|
||||
Contains("second-change-branch unrelated change"),
|
||||
@ -33,46 +33,46 @@ var CherryPickConflicts = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
).
|
||||
Press(keys.Commits.CherryPickCopy).
|
||||
Tap(func() {
|
||||
input.Views().Information().Content(Contains("1 commit copied"))
|
||||
t.Views().Information().Content(Contains("1 commit copied"))
|
||||
}).
|
||||
SelectNextItem().
|
||||
Press(keys.Commits.CherryPickCopy)
|
||||
|
||||
input.Views().Information().Content(Contains("2 commits copied"))
|
||||
t.Views().Information().Content(Contains("2 commits copied"))
|
||||
|
||||
input.Views().Commits().
|
||||
t.Views().Commits().
|
||||
Focus().
|
||||
TopLines(
|
||||
Contains("first change"),
|
||||
).
|
||||
Press(keys.Commits.PasteCommits)
|
||||
|
||||
input.ExpectAlert().Title(Equals("Cherry-Pick")).Content(Contains("Are you sure you want to cherry-pick the copied commits onto this branch?")).Confirm()
|
||||
t.ExpectAlert().Title(Equals("Cherry-Pick")).Content(Contains("Are you sure you want to cherry-pick the copied commits onto this branch?")).Confirm()
|
||||
|
||||
input.ExpectConfirmation().
|
||||
t.ExpectConfirmation().
|
||||
Title(Equals("Auto-merge failed")).
|
||||
Content(Contains("Conflicts!")).
|
||||
Confirm()
|
||||
|
||||
input.Views().Files().
|
||||
t.Views().Files().
|
||||
IsFocused().
|
||||
SelectedLine(Contains("file")).
|
||||
PressEnter()
|
||||
|
||||
input.Views().MergeConflicts().
|
||||
t.Views().MergeConflicts().
|
||||
IsFocused().
|
||||
// picking 'Second change'
|
||||
SelectNextItem().
|
||||
PressPrimaryAction()
|
||||
|
||||
input.ExpectConfirmation().
|
||||
t.ExpectConfirmation().
|
||||
Title(Equals("continue")).
|
||||
Content(Contains("all merge conflicts resolved. Continue?")).
|
||||
Confirm()
|
||||
|
||||
input.Model().WorkingTreeFileCount(0)
|
||||
t.Model().WorkingTreeFileCount(0)
|
||||
|
||||
input.Views().Commits().
|
||||
t.Views().Commits().
|
||||
Focus().
|
||||
TopLines(
|
||||
Contains("second-change-branch unrelated change"),
|
||||
@ -84,15 +84,15 @@ var CherryPickConflicts = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
// 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'
|
||||
input.Views().Main().
|
||||
t.Views().Main().
|
||||
Content(Contains("-First Change")).
|
||||
Content(Contains("+Second Change"))
|
||||
|
||||
input.Views().Information().Content(Contains("2 commits copied"))
|
||||
t.Views().Information().Content(Contains("2 commits copied"))
|
||||
}).
|
||||
PressEscape().
|
||||
Tap(func() {
|
||||
input.Views().Information().Content(DoesNotContain("commits copied"))
|
||||
t.Views().Information().Content(DoesNotContain("commits copied"))
|
||||
})
|
||||
},
|
||||
})
|
||||
|
@ -14,10 +14,10 @@ var Commit = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
shell.CreateFile("myfile", "myfile content")
|
||||
shell.CreateFile("myfile2", "myfile2 content")
|
||||
},
|
||||
Run: func(shell *Shell, input *Input, keys config.KeybindingConfig) {
|
||||
input.Model().CommitCount(0)
|
||||
Run: func(shell *Shell, t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.Model().CommitCount(0)
|
||||
|
||||
input.Views().Files().
|
||||
t.Views().Files().
|
||||
IsFocused().
|
||||
PressPrimaryAction(). // stage file
|
||||
SelectNextItem().
|
||||
@ -26,9 +26,9 @@ var Commit = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
|
||||
commitMessage := "my commit message"
|
||||
|
||||
input.ExpectCommitMessagePanel().Type(commitMessage).Confirm()
|
||||
t.ExpectCommitMessagePanel().Type(commitMessage).Confirm()
|
||||
|
||||
input.Model().
|
||||
t.Model().
|
||||
CommitCount(1).
|
||||
HeadCommitMessage(Equals(commitMessage))
|
||||
},
|
||||
|
@ -13,20 +13,20 @@ var CommitMultiline = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
SetupRepo: func(shell *Shell) {
|
||||
shell.CreateFile("myfile", "myfile content")
|
||||
},
|
||||
Run: func(shell *Shell, input *Input, keys config.KeybindingConfig) {
|
||||
input.Model().CommitCount(0)
|
||||
Run: func(shell *Shell, t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.Model().CommitCount(0)
|
||||
|
||||
input.Views().Files().
|
||||
t.Views().Files().
|
||||
IsFocused().
|
||||
PressPrimaryAction().
|
||||
Press(keys.Files.CommitChanges)
|
||||
|
||||
input.ExpectCommitMessagePanel().Type("first line").AddNewline().AddNewline().Type("third line").Confirm()
|
||||
t.ExpectCommitMessagePanel().Type("first line").AddNewline().AddNewline().Type("third line").Confirm()
|
||||
|
||||
input.Model().CommitCount(1)
|
||||
input.Model().HeadCommitMessage(Equals("first line"))
|
||||
t.Model().CommitCount(1)
|
||||
t.Model().HeadCommitMessage(Equals("first line"))
|
||||
|
||||
input.Views().Commits().Focus()
|
||||
input.Views().Main().Content(MatchesRegexp("first line\n\\s*\n\\s*third line"))
|
||||
t.Views().Commits().Focus()
|
||||
t.Views().Main().Content(MatchesRegexp("first line\n\\s*\n\\s*third line"))
|
||||
},
|
||||
})
|
||||
|
@ -16,10 +16,10 @@ var NewBranch = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
EmptyCommit("commit 2").
|
||||
EmptyCommit("commit 3")
|
||||
},
|
||||
Run: func(shell *Shell, input *Input, keys config.KeybindingConfig) {
|
||||
input.Model().CommitCount(3)
|
||||
Run: func(shell *Shell, t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.Model().CommitCount(3)
|
||||
|
||||
input.Views().Commits().
|
||||
t.Views().Commits().
|
||||
Focus().
|
||||
SelectNextItem().
|
||||
Lines(
|
||||
@ -30,9 +30,9 @@ var NewBranch = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Press(keys.Universal.New).
|
||||
Tap(func() {
|
||||
branchName := "my-branch-name"
|
||||
input.ExpectPrompt().Title(Contains("New Branch Name")).Type(branchName).Confirm()
|
||||
t.ExpectPrompt().Title(Contains("New Branch Name")).Type(branchName).Confirm()
|
||||
|
||||
input.Model().CurrentBranchName(branchName)
|
||||
t.Model().CurrentBranchName(branchName)
|
||||
}).
|
||||
Lines(
|
||||
Contains("commit 2"),
|
||||
|
@ -15,17 +15,17 @@ var Revert = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
shell.GitAddAll()
|
||||
shell.Commit("first commit")
|
||||
},
|
||||
Run: func(shell *Shell, input *Input, keys config.KeybindingConfig) {
|
||||
input.Model().CommitCount(1)
|
||||
Run: func(shell *Shell, t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.Model().CommitCount(1)
|
||||
|
||||
input.Views().Commits().
|
||||
t.Views().Commits().
|
||||
Focus().
|
||||
Lines(
|
||||
Contains("first commit"),
|
||||
).
|
||||
Press(keys.Commits.RevertCommit).
|
||||
Tap(func() {
|
||||
input.ExpectConfirmation().
|
||||
t.ExpectConfirmation().
|
||||
Title(Equals("Revert commit")).
|
||||
Content(MatchesRegexp(`Are you sure you want to revert \w+?`)).
|
||||
Confirm()
|
||||
@ -35,7 +35,7 @@ var Revert = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Contains("first commit"),
|
||||
)
|
||||
|
||||
input.Views().Main().Content(Contains("-myfile content"))
|
||||
input.FileSystem().PathNotPresent("myfile")
|
||||
t.Views().Main().Content(Contains("-myfile content"))
|
||||
t.FileSystem().PathNotPresent("myfile")
|
||||
},
|
||||
})
|
||||
|
@ -15,41 +15,41 @@ var Staged = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
CreateFile("myfile", "myfile content\nwith a second line").
|
||||
CreateFile("myfile2", "myfile2 content")
|
||||
},
|
||||
Run: func(shell *Shell, input *Input, keys config.KeybindingConfig) {
|
||||
input.Model().CommitCount(0)
|
||||
Run: func(shell *Shell, t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.Model().CommitCount(0)
|
||||
|
||||
input.Views().Files().
|
||||
t.Views().Files().
|
||||
IsFocused().
|
||||
SelectedLine(Contains("myfile")).
|
||||
PressPrimaryAction(). // stage the file
|
||||
PressEnter()
|
||||
|
||||
input.Views().StagingSecondary().
|
||||
t.Views().StagingSecondary().
|
||||
IsFocused().
|
||||
Tap(func() {
|
||||
// we start with both lines having been staged
|
||||
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"))
|
||||
t.Views().StagingSecondary().Content(Contains("+myfile content"))
|
||||
t.Views().StagingSecondary().Content(Contains("+with a second line"))
|
||||
t.Views().Staging().Content(DoesNotContain("+myfile content"))
|
||||
t.Views().Staging().Content(DoesNotContain("+with a second line"))
|
||||
}).
|
||||
// unstage the selected line
|
||||
PressPrimaryAction().
|
||||
Tap(func() {
|
||||
// the line should have been moved to the main view
|
||||
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"))
|
||||
t.Views().StagingSecondary().Content(DoesNotContain("+myfile content"))
|
||||
t.Views().StagingSecondary().Content(Contains("+with a second line"))
|
||||
t.Views().Staging().Content(Contains("+myfile content"))
|
||||
t.Views().Staging().Content(DoesNotContain("+with a second line"))
|
||||
}).
|
||||
Press(keys.Files.CommitChanges)
|
||||
|
||||
commitMessage := "my commit message"
|
||||
input.ExpectCommitMessagePanel().Type(commitMessage).Confirm()
|
||||
t.ExpectCommitMessagePanel().Type(commitMessage).Confirm()
|
||||
|
||||
input.Model().CommitCount(1)
|
||||
input.Model().HeadCommitMessage(Equals(commitMessage))
|
||||
input.Views().StagingSecondary().IsFocused()
|
||||
t.Model().CommitCount(1)
|
||||
t.Model().HeadCommitMessage(Equals(commitMessage))
|
||||
t.Views().StagingSecondary().IsFocused()
|
||||
|
||||
// TODO: assert that the staging panel has been refreshed (it currently does not get correctly refreshed)
|
||||
},
|
||||
|
@ -15,41 +15,41 @@ var StagedWithoutHooks = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
CreateFile("myfile", "myfile content\nwith a second line").
|
||||
CreateFile("myfile2", "myfile2 content")
|
||||
},
|
||||
Run: func(shell *Shell, input *Input, keys config.KeybindingConfig) {
|
||||
input.Model().CommitCount(0)
|
||||
Run: func(shell *Shell, t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.Model().CommitCount(0)
|
||||
|
||||
// stage the file
|
||||
input.Views().Files().
|
||||
t.Views().Files().
|
||||
IsFocused().
|
||||
SelectedLine(Contains("myfile")).
|
||||
PressPrimaryAction().
|
||||
PressEnter()
|
||||
|
||||
// we start with both lines having been staged
|
||||
input.Views().StagingSecondary().Content(
|
||||
t.Views().StagingSecondary().Content(
|
||||
Contains("+myfile content").Contains("+with a second line"),
|
||||
)
|
||||
input.Views().Staging().Content(
|
||||
t.Views().Staging().Content(
|
||||
DoesNotContain("+myfile content").DoesNotContain("+with a second line"),
|
||||
)
|
||||
|
||||
// unstage the selected line
|
||||
input.Views().StagingSecondary().
|
||||
t.Views().StagingSecondary().
|
||||
IsFocused().
|
||||
PressPrimaryAction().
|
||||
Tap(func() {
|
||||
// the line should have been moved to the main view
|
||||
input.Views().Staging().Content(Contains("+myfile content").DoesNotContain("+with a second line"))
|
||||
t.Views().Staging().Content(Contains("+myfile content").DoesNotContain("+with a second line"))
|
||||
}).
|
||||
Content(DoesNotContain("+myfile content").Contains("+with a second line")).
|
||||
Press(keys.Files.CommitChangesWithoutHook)
|
||||
|
||||
commitMessage := ": my commit message"
|
||||
input.ExpectCommitMessagePanel().InitialText(Contains("WIP")).Type(commitMessage).Confirm()
|
||||
t.ExpectCommitMessagePanel().InitialText(Contains("WIP")).Type(commitMessage).Confirm()
|
||||
|
||||
input.Model().CommitCount(1)
|
||||
input.Model().HeadCommitMessage(Equals("WIP" + commitMessage))
|
||||
input.Views().StagingSecondary().IsFocused()
|
||||
t.Model().CommitCount(1)
|
||||
t.Model().HeadCommitMessage(Equals("WIP" + commitMessage))
|
||||
t.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 input.SelectedLine() on the staging/stagingSecondary views.
|
||||
// TODO: find out why we can't use .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,33 +17,33 @@ var Unstaged = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
CreateFile("myfile", "myfile content\nwith a second line").
|
||||
CreateFile("myfile2", "myfile2 content")
|
||||
},
|
||||
Run: func(shell *Shell, input *Input, keys config.KeybindingConfig) {
|
||||
input.Model().CommitCount(0)
|
||||
Run: func(shell *Shell, t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.Model().CommitCount(0)
|
||||
|
||||
input.Views().Files().
|
||||
t.Views().Files().
|
||||
IsFocused().
|
||||
SelectedLine(Contains("myfile")).
|
||||
PressEnter()
|
||||
|
||||
input.Views().Staging().
|
||||
t.Views().Staging().
|
||||
IsFocused().
|
||||
Tap(func() {
|
||||
input.Views().StagingSecondary().Content(DoesNotContain("+myfile content"))
|
||||
t.Views().StagingSecondary().Content(DoesNotContain("+myfile content"))
|
||||
}).
|
||||
// stage the first line
|
||||
PressPrimaryAction().
|
||||
Tap(func() {
|
||||
input.Views().Staging().Content(DoesNotContain("+myfile content"))
|
||||
input.Views().StagingSecondary().Content(Contains("+myfile content"))
|
||||
t.Views().Staging().Content(DoesNotContain("+myfile content"))
|
||||
t.Views().StagingSecondary().Content(Contains("+myfile content"))
|
||||
}).
|
||||
Press(keys.Files.CommitChanges)
|
||||
|
||||
commitMessage := "my commit message"
|
||||
input.ExpectCommitMessagePanel().Type(commitMessage).Confirm()
|
||||
t.ExpectCommitMessagePanel().Type(commitMessage).Confirm()
|
||||
|
||||
input.Model().CommitCount(1)
|
||||
input.Model().HeadCommitMessage(Equals(commitMessage))
|
||||
input.Views().Staging().IsFocused()
|
||||
t.Model().CommitCount(1)
|
||||
t.Model().HeadCommitMessage(Equals(commitMessage))
|
||||
t.Views().Staging().IsFocused()
|
||||
|
||||
// TODO: assert that the staging panel has been refreshed (it currently does not get correctly refreshed)
|
||||
},
|
||||
|
@ -17,10 +17,10 @@ var RemoteNamedStar = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
SetupConfig: func(cfg *config.AppConfig) {},
|
||||
Run: func(
|
||||
shell *Shell,
|
||||
input *Input,
|
||||
t *TestDriver,
|
||||
keys config.KeybindingConfig,
|
||||
) {
|
||||
// here we're just asserting that we haven't panicked upon starting lazygit
|
||||
input.Model().AtLeastOneCommit()
|
||||
t.Model().AtLeastOneCommit()
|
||||
},
|
||||
})
|
||||
|
@ -23,12 +23,12 @@ var Basic = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
},
|
||||
Run: func(
|
||||
shell *Shell,
|
||||
input *Input,
|
||||
t *TestDriver,
|
||||
keys config.KeybindingConfig,
|
||||
) {
|
||||
input.Model().WorkingTreeFileCount(0)
|
||||
t.Model().WorkingTreeFileCount(0)
|
||||
|
||||
input.Views().Files().
|
||||
t.Views().Files().
|
||||
IsFocused().
|
||||
Press("a").
|
||||
Lines(
|
||||
|
@ -57,26 +57,26 @@ var FormPrompts = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
},
|
||||
Run: func(
|
||||
shell *Shell,
|
||||
input *Input,
|
||||
t *TestDriver,
|
||||
keys config.KeybindingConfig,
|
||||
) {
|
||||
input.Model().WorkingTreeFileCount(0)
|
||||
t.Model().WorkingTreeFileCount(0)
|
||||
|
||||
input.Views().Files().
|
||||
t.Views().Files().
|
||||
IsFocused().
|
||||
Press("a")
|
||||
|
||||
input.ExpectPrompt().Title(Equals("Enter a file name")).Type("my file").Confirm()
|
||||
t.ExpectPrompt().Title(Equals("Enter a file name")).Type("my file").Confirm()
|
||||
|
||||
input.ExpectMenu().Title(Equals("Choose file content")).Select(Contains("bar")).Confirm()
|
||||
t.ExpectMenu().Title(Equals("Choose file content")).Select(Contains("bar")).Confirm()
|
||||
|
||||
input.ExpectConfirmation().
|
||||
t.ExpectConfirmation().
|
||||
Title(Equals("Are you sure?")).
|
||||
Content(Equals("Are you REALLY sure you want to make this file? Up to you buddy.")).
|
||||
Confirm()
|
||||
|
||||
input.Model().WorkingTreeFileCount(1)
|
||||
input.Views().Files().SelectedLine(Contains("my file"))
|
||||
input.Views().Main().Content(Contains(`"BAR"`))
|
||||
t.Model().WorkingTreeFileCount(1)
|
||||
t.Views().Files().SelectedLine(Contains("my file"))
|
||||
t.Views().Main().Content(Contains(`"BAR"`))
|
||||
},
|
||||
})
|
||||
|
@ -44,21 +44,21 @@ var MenuFromCommand = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
},
|
||||
Run: func(
|
||||
shell *Shell,
|
||||
input *Input,
|
||||
t *TestDriver,
|
||||
keys config.KeybindingConfig,
|
||||
) {
|
||||
input.Model().WorkingTreeFileCount(0)
|
||||
input.Views().Branches().
|
||||
t.Model().WorkingTreeFileCount(0)
|
||||
t.Views().Branches().
|
||||
Focus().
|
||||
Press("a")
|
||||
|
||||
input.ExpectMenu().Title(Equals("Choose commit message")).Select(Contains("bar")).Confirm()
|
||||
t.ExpectMenu().Title(Equals("Choose commit message")).Select(Contains("bar")).Confirm()
|
||||
|
||||
input.ExpectPrompt().Title(Equals("Description")).Type(" my branch").Confirm()
|
||||
t.ExpectPrompt().Title(Equals("Description")).Type(" my branch").Confirm()
|
||||
|
||||
input.Model().WorkingTreeFileCount(1)
|
||||
t.Model().WorkingTreeFileCount(1)
|
||||
|
||||
input.Views().Files().Focus().SelectedLine(Contains("output.txt"))
|
||||
input.Views().Main().Content(Contains("bar Branch: #feature/foo my branch feature/foo"))
|
||||
t.Views().Files().Focus().SelectedLine(Contains("output.txt"))
|
||||
t.Views().Main().Content(Contains("bar Branch: #feature/foo my branch feature/foo"))
|
||||
},
|
||||
})
|
||||
|
@ -43,23 +43,23 @@ var MenuFromCommandsOutput = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
},
|
||||
Run: func(
|
||||
shell *Shell,
|
||||
input *Input,
|
||||
t *TestDriver,
|
||||
keys config.KeybindingConfig,
|
||||
) {
|
||||
input.Model().CurrentBranchName("feature/bar")
|
||||
input.Model().WorkingTreeFileCount(0)
|
||||
t.Model().CurrentBranchName("feature/bar")
|
||||
t.Model().WorkingTreeFileCount(0)
|
||||
|
||||
input.Views().Branches().
|
||||
t.Views().Branches().
|
||||
Focus().
|
||||
Press("a")
|
||||
|
||||
input.ExpectPrompt().
|
||||
t.ExpectPrompt().
|
||||
Title(Equals("Which git command do you want to run?")).
|
||||
InitialText(Equals("branch")).
|
||||
Confirm()
|
||||
|
||||
input.ExpectMenu().Title(Equals("Branch:")).Select(Equals("master")).Confirm()
|
||||
t.ExpectMenu().Title(Equals("Branch:")).Select(Equals("master")).Confirm()
|
||||
|
||||
input.Model().CurrentBranchName("master")
|
||||
t.Model().CurrentBranchName("master")
|
||||
},
|
||||
})
|
||||
|
@ -55,26 +55,26 @@ var MultiplePrompts = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
},
|
||||
Run: func(
|
||||
shell *Shell,
|
||||
input *Input,
|
||||
t *TestDriver,
|
||||
keys config.KeybindingConfig,
|
||||
) {
|
||||
input.Model().WorkingTreeFileCount(0)
|
||||
t.Model().WorkingTreeFileCount(0)
|
||||
|
||||
input.Views().Files().
|
||||
t.Views().Files().
|
||||
IsFocused().
|
||||
Press("a")
|
||||
|
||||
input.ExpectPrompt().Title(Equals("Enter a file name")).Type("myfile").Confirm()
|
||||
t.ExpectPrompt().Title(Equals("Enter a file name")).Type("myfile").Confirm()
|
||||
|
||||
input.ExpectMenu().Title(Equals("Choose file content")).Select(Contains("bar")).Confirm()
|
||||
t.ExpectMenu().Title(Equals("Choose file content")).Select(Contains("bar")).Confirm()
|
||||
|
||||
input.ExpectConfirmation().
|
||||
t.ExpectConfirmation().
|
||||
Title(Equals("Are you sure?")).
|
||||
Content(Equals("Are you REALLY sure you want to make this file? Up to you buddy.")).
|
||||
Confirm()
|
||||
|
||||
input.Model().WorkingTreeFileCount(1)
|
||||
input.Views().Files().SelectedLine(Contains("myfile"))
|
||||
input.Views().Main().Content(Contains("BAR"))
|
||||
t.Model().WorkingTreeFileCount(1)
|
||||
t.Views().Files().SelectedLine(Contains("myfile"))
|
||||
t.Views().Main().Content(Contains("BAR"))
|
||||
},
|
||||
})
|
||||
|
@ -21,8 +21,8 @@ var Diff = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
|
||||
shell.Checkout("branch-a")
|
||||
},
|
||||
Run: func(shell *Shell, input *Input, keys config.KeybindingConfig) {
|
||||
input.Views().Branches().
|
||||
Run: func(shell *Shell, t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.Views().Branches().
|
||||
Focus().
|
||||
TopLines(
|
||||
Contains("branch-a"),
|
||||
@ -30,44 +30,44 @@ var Diff = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
).
|
||||
Press(keys.Universal.DiffingMenu)
|
||||
|
||||
input.ExpectMenu().Title(Equals("Diffing")).Select(Contains(`diff branch-a`)).Confirm()
|
||||
t.ExpectMenu().Title(Equals("Diffing")).Select(Contains(`diff branch-a`)).Confirm()
|
||||
|
||||
input.Views().Branches().
|
||||
t.Views().Branches().
|
||||
IsFocused().
|
||||
Tap(func() {
|
||||
input.Views().Information().Content(Contains("showing output for: git diff branch-a branch-a"))
|
||||
t.Views().Information().Content(Contains("showing output for: git diff branch-a branch-a"))
|
||||
}).
|
||||
SelectNextItem().
|
||||
Tap(func() {
|
||||
input.Views().Information().Content(Contains("showing output for: git diff branch-a branch-b"))
|
||||
input.Views().Main().Content(Contains("+second line"))
|
||||
t.Views().Information().Content(Contains("showing output for: git diff branch-a branch-b"))
|
||||
t.Views().Main().Content(Contains("+second line"))
|
||||
}).
|
||||
PressEnter()
|
||||
|
||||
input.Views().SubCommits().
|
||||
t.Views().SubCommits().
|
||||
IsFocused().
|
||||
SelectedLine(Contains("update")).
|
||||
Tap(func() {
|
||||
input.Views().Main().Content(Contains("+second line"))
|
||||
t.Views().Main().Content(Contains("+second line"))
|
||||
}).
|
||||
PressEnter()
|
||||
|
||||
input.Views().CommitFiles().
|
||||
t.Views().CommitFiles().
|
||||
IsFocused().
|
||||
SelectedLine(Contains("file1")).
|
||||
Tap(func() {
|
||||
input.Views().Main().Content(Contains("+second line"))
|
||||
t.Views().Main().Content(Contains("+second line"))
|
||||
}).
|
||||
PressEscape()
|
||||
|
||||
input.Views().SubCommits().PressEscape()
|
||||
t.Views().SubCommits().PressEscape()
|
||||
|
||||
input.Views().Branches().
|
||||
t.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"))
|
||||
t.ExpectMenu().Title(Equals("Diffing")).Select(Contains("reverse diff direction")).Confirm()
|
||||
t.Views().Information().Content(Contains("showing output for: git diff branch-a branch-b -R"))
|
||||
t.Views().Main().Content(Contains("-second line"))
|
||||
},
|
||||
})
|
||||
|
@ -21,8 +21,8 @@ var DiffAndApplyPatch = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
|
||||
shell.Checkout("branch-a")
|
||||
},
|
||||
Run: func(shell *Shell, input *Input, keys config.KeybindingConfig) {
|
||||
input.Views().Branches().
|
||||
Run: func(shell *Shell, t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.Views().Branches().
|
||||
Focus().
|
||||
Lines(
|
||||
Contains("branch-a"),
|
||||
@ -30,49 +30,49 @@ var DiffAndApplyPatch = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
).
|
||||
Press(keys.Universal.DiffingMenu)
|
||||
|
||||
input.ExpectMenu().Title(Equals("Diffing")).Select(Equals("diff branch-a")).Confirm()
|
||||
t.ExpectMenu().Title(Equals("Diffing")).Select(Equals("diff branch-a")).Confirm()
|
||||
|
||||
input.Views().Information().Content(Contains("showing output for: git diff branch-a branch-a"))
|
||||
t.Views().Information().Content(Contains("showing output for: git diff branch-a branch-a"))
|
||||
|
||||
input.Views().Branches().
|
||||
t.Views().Branches().
|
||||
IsFocused().
|
||||
SelectNextItem().
|
||||
Tap(func() {
|
||||
input.Views().Information().Content(Contains("showing output for: git diff branch-a branch-b"))
|
||||
input.Views().Main().Content(Contains("+second line"))
|
||||
t.Views().Information().Content(Contains("showing output for: git diff branch-a branch-b"))
|
||||
t.Views().Main().Content(Contains("+second line"))
|
||||
}).
|
||||
PressEnter()
|
||||
|
||||
input.Views().SubCommits().
|
||||
t.Views().SubCommits().
|
||||
IsFocused().
|
||||
SelectedLine(Contains("update")).
|
||||
Tap(func() {
|
||||
input.Views().Main().Content(Contains("+second line"))
|
||||
t.Views().Main().Content(Contains("+second line"))
|
||||
}).
|
||||
PressEnter()
|
||||
|
||||
input.Views().CommitFiles().
|
||||
t.Views().CommitFiles().
|
||||
IsFocused().
|
||||
SelectedLine(Contains("file1")).
|
||||
Tap(func() {
|
||||
input.Views().Main().Content(Contains("+second line"))
|
||||
t.Views().Main().Content(Contains("+second line"))
|
||||
}).
|
||||
PressPrimaryAction(). // add the file to the patch
|
||||
Press(keys.Universal.DiffingMenu).
|
||||
Tap(func() {
|
||||
input.ExpectMenu().Title(Equals("Diffing")).Select(Contains("exit diff mode")).Confirm()
|
||||
t.ExpectMenu().Title(Equals("Diffing")).Select(Contains("exit diff mode")).Confirm()
|
||||
|
||||
input.Views().Information().Content(DoesNotContain("building patch"))
|
||||
t.Views().Information().Content(DoesNotContain("building patch"))
|
||||
}).
|
||||
Press(keys.Universal.CreatePatchOptionsMenu)
|
||||
|
||||
// adding the regex '$' here to distinguish the menu item from the 'apply patch in reverse' item
|
||||
input.ExpectMenu().Title(Equals("Patch Options")).Select(MatchesRegexp("apply patch$")).Confirm()
|
||||
t.ExpectMenu().Title(Equals("Patch Options")).Select(MatchesRegexp("apply patch$")).Confirm()
|
||||
|
||||
input.Views().Files().
|
||||
t.Views().Files().
|
||||
Focus().
|
||||
SelectedLine(Contains("file1"))
|
||||
|
||||
input.Views().Main().Content(Contains("+second line"))
|
||||
t.Views().Main().Content(Contains("+second line"))
|
||||
},
|
||||
})
|
||||
|
@ -18,8 +18,8 @@ var DiffCommits = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
shell.UpdateFileAndAdd("file1", "first line\nsecond line\nthird line\n")
|
||||
shell.Commit("third commit")
|
||||
},
|
||||
Run: func(shell *Shell, input *Input, keys config.KeybindingConfig) {
|
||||
input.Views().Commits().
|
||||
Run: func(shell *Shell, t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.Views().Commits().
|
||||
Focus().
|
||||
Lines(
|
||||
Contains("third commit").IsSelected(),
|
||||
@ -28,28 +28,28 @@ var DiffCommits = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
).
|
||||
Press(keys.Universal.DiffingMenu).
|
||||
Tap(func() {
|
||||
input.ExpectMenu().Title(Equals("Diffing")).Select(MatchesRegexp(`diff \w+`)).Confirm()
|
||||
t.ExpectMenu().Title(Equals("Diffing")).Select(MatchesRegexp(`diff \w+`)).Confirm()
|
||||
|
||||
input.Views().Information().Content(Contains("showing output for: git diff"))
|
||||
t.Views().Information().Content(Contains("showing output for: git diff"))
|
||||
}).
|
||||
SelectNextItem().
|
||||
SelectNextItem().
|
||||
SelectedLine(Contains("first commit")).
|
||||
Tap(func() {
|
||||
input.Views().Main().Content(Contains("-second line\n-third line"))
|
||||
t.Views().Main().Content(Contains("-second line\n-third line"))
|
||||
}).
|
||||
Press(keys.Universal.DiffingMenu).
|
||||
Tap(func() {
|
||||
input.ExpectMenu().Title(Equals("Diffing")).Select(Contains("reverse diff direction")).Confirm()
|
||||
t.ExpectMenu().Title(Equals("Diffing")).Select(Contains("reverse diff direction")).Confirm()
|
||||
|
||||
input.Views().Main().Content(Contains("+second line\n+third line"))
|
||||
t.Views().Main().Content(Contains("+second line\n+third line"))
|
||||
}).
|
||||
PressEnter()
|
||||
|
||||
input.Views().CommitFiles().
|
||||
t.Views().CommitFiles().
|
||||
IsFocused().
|
||||
SelectedLine(Contains("file1"))
|
||||
|
||||
input.Views().Main().Content(Contains("+second line\n+third line"))
|
||||
t.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, keys config.KeybindingConfig) {
|
||||
input.Model().CommitCount(1)
|
||||
Run: func(shell *Shell, t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.Model().CommitCount(1)
|
||||
|
||||
input.Views().Main().
|
||||
t.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, keys config.KeybindingConfig) {
|
||||
input.Model().CommitCount(3)
|
||||
Run: func(shell *Shell, t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.Model().CommitCount(3)
|
||||
|
||||
type statusFile struct {
|
||||
status string
|
||||
@ -82,12 +82,12 @@ var DiscardChanges = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
|
||||
discardOneByOne := func(files []statusFile) {
|
||||
for _, file := range files {
|
||||
input.Views().Files().
|
||||
t.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()
|
||||
t.ExpectMenu().Title(Equals(file.menuTitle)).Select(Contains("discard all changes")).Confirm()
|
||||
}
|
||||
}
|
||||
|
||||
@ -101,7 +101,7 @@ var DiscardChanges = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
{status: "DU", label: "deleted-us.txt", menuTitle: "deleted-us.txt"},
|
||||
})
|
||||
|
||||
input.ExpectConfirmation().
|
||||
t.ExpectConfirmation().
|
||||
Title(Equals("continue")).
|
||||
Content(Contains("all merge conflicts resolved. Continue?")).
|
||||
Cancel()
|
||||
@ -121,6 +121,6 @@ var DiscardChanges = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
{status: "??", label: "new.txt", menuTitle: "new.txt"},
|
||||
})
|
||||
|
||||
input.Model().WorkingTreeFileCount(0)
|
||||
t.Model().WorkingTreeFileCount(0)
|
||||
},
|
||||
})
|
||||
|
@ -27,27 +27,27 @@ var AmendMerge = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Merge("feature-branch").
|
||||
CreateFileAndAdd(postMergeFilename, postMergeFileContent)
|
||||
},
|
||||
Run: func(shell *Shell, input *Input, keys config.KeybindingConfig) {
|
||||
input.Model().CommitCount(3)
|
||||
Run: func(shell *Shell, t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.Model().CommitCount(3)
|
||||
|
||||
mergeCommitMessage := "Merge branch 'feature-branch' into development-branch"
|
||||
input.Model().HeadCommitMessage(Contains(mergeCommitMessage))
|
||||
t.Model().HeadCommitMessage(Contains(mergeCommitMessage))
|
||||
|
||||
input.Views().Commits().
|
||||
t.Views().Commits().
|
||||
Focus().
|
||||
Press(keys.Commits.AmendToCommit)
|
||||
|
||||
input.ExpectConfirmation().
|
||||
t.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
|
||||
input.Model().CommitCount(3)
|
||||
input.Model().HeadCommitMessage(Contains(mergeCommitMessage))
|
||||
t.Model().CommitCount(3)
|
||||
t.Model().HeadCommitMessage(Contains(mergeCommitMessage))
|
||||
|
||||
// assuring the post-merge file shows up in the merge commit.
|
||||
input.Views().Main().
|
||||
t.Views().Main().
|
||||
Content(Contains(postMergeFilename)).
|
||||
Content(Contains("++" + postMergeFileContent))
|
||||
},
|
||||
|
@ -14,8 +14,8 @@ var One = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
shell.
|
||||
CreateNCommits(5) // these will appears at commit 05, 04, 04, down to 01
|
||||
},
|
||||
Run: func(shell *Shell, input *Input, keys config.KeybindingConfig) {
|
||||
input.Views().Commits().
|
||||
Run: func(shell *Shell, t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.Views().Commits().
|
||||
Focus().
|
||||
Lines(
|
||||
Contains("commit 05"),
|
||||
@ -61,7 +61,7 @@ var One = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Contains("commit 01"),
|
||||
).
|
||||
Tap(func() {
|
||||
input.ContinueRebase()
|
||||
t.ContinueRebase()
|
||||
}).
|
||||
Lines(
|
||||
Contains("commit 02"),
|
||||
|
@ -13,14 +13,14 @@ var ConfirmOnQuit = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
config.UserConfig.ConfirmOnQuit = true
|
||||
},
|
||||
SetupRepo: func(shell *Shell) {},
|
||||
Run: func(shell *Shell, input *Input, keys config.KeybindingConfig) {
|
||||
input.Model().CommitCount(0)
|
||||
Run: func(shell *Shell, t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.Model().CommitCount(0)
|
||||
|
||||
input.Views().Files().
|
||||
t.Views().Files().
|
||||
IsFocused().
|
||||
Press(keys.Universal.Quit)
|
||||
|
||||
input.ExpectConfirmation().
|
||||
t.ExpectConfirmation().
|
||||
Title(Equals("")).
|
||||
Content(Contains("Are you sure you want to quit?")).
|
||||
Confirm()
|
||||
|
@ -18,8 +18,8 @@ var Rename = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
CreateFileAndAdd("file-2", "change to stash2").
|
||||
StashWithMessage("bar")
|
||||
},
|
||||
Run: func(shell *Shell, input *Input, keys config.KeybindingConfig) {
|
||||
input.Views().Stash().
|
||||
Run: func(shell *Shell, t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.Views().Stash().
|
||||
Focus().
|
||||
Lines(
|
||||
Equals("On master: bar"),
|
||||
@ -28,7 +28,7 @@ var Rename = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
SelectNextItem().
|
||||
Press(keys.Stash.RenameStash).
|
||||
Tap(func() {
|
||||
input.ExpectPrompt().Title(Equals("Rename stash: stash@{1}")).Type(" baz").Confirm()
|
||||
t.ExpectPrompt().Title(Equals("Rename stash: stash@{1}")).Type(" baz").Confirm()
|
||||
}).
|
||||
SelectedLine(Equals("On master: foo baz"))
|
||||
},
|
||||
|
@ -15,18 +15,18 @@ var Stash = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
shell.CreateFile("file", "content")
|
||||
shell.GitAddAll()
|
||||
},
|
||||
Run: func(shell *Shell, input *Input, keys config.KeybindingConfig) {
|
||||
input.Model().StashCount(0)
|
||||
input.Model().WorkingTreeFileCount(1)
|
||||
Run: func(shell *Shell, t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.Model().StashCount(0)
|
||||
t.Model().WorkingTreeFileCount(1)
|
||||
|
||||
input.Views().Files().
|
||||
t.Views().Files().
|
||||
Press(keys.Files.ViewStashOptions)
|
||||
|
||||
input.ExpectMenu().Title(Equals("Stash options")).Select(MatchesRegexp("stash all changes$")).Confirm()
|
||||
t.ExpectMenu().Title(Equals("Stash options")).Select(MatchesRegexp("stash all changes$")).Confirm()
|
||||
|
||||
input.ExpectPrompt().Title(Equals("Stash changes")).Type("my stashed file").Confirm()
|
||||
t.ExpectPrompt().Title(Equals("Stash changes")).Type("my stashed file").Confirm()
|
||||
|
||||
input.Model().StashCount(1)
|
||||
input.Model().WorkingTreeFileCount(0)
|
||||
t.Model().StashCount(1)
|
||||
t.Model().WorkingTreeFileCount(0)
|
||||
},
|
||||
})
|
||||
|
@ -16,18 +16,18 @@ var StashIncludingUntrackedFiles = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
shell.CreateFile("file_2", "content")
|
||||
shell.GitAdd("file_1")
|
||||
},
|
||||
Run: func(shell *Shell, input *Input, keys config.KeybindingConfig) {
|
||||
input.Model().StashCount(0)
|
||||
input.Model().WorkingTreeFileCount(2)
|
||||
Run: func(shell *Shell, t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.Model().StashCount(0)
|
||||
t.Model().WorkingTreeFileCount(2)
|
||||
|
||||
input.Views().Files().
|
||||
t.Views().Files().
|
||||
Press(keys.Files.ViewStashOptions)
|
||||
|
||||
input.ExpectMenu().Title(Equals("Stash options")).Select(Contains("stash all changes including untracked files")).Confirm()
|
||||
t.ExpectMenu().Title(Equals("Stash options")).Select(Contains("stash all changes including untracked files")).Confirm()
|
||||
|
||||
input.ExpectPrompt().Title(Equals("Stash changes")).Type("my stashed file").Confirm()
|
||||
t.ExpectPrompt().Title(Equals("Stash changes")).Type("my stashed file").Confirm()
|
||||
|
||||
input.Model().StashCount(1)
|
||||
input.Model().WorkingTreeFileCount(0)
|
||||
t.Model().StashCount(1)
|
||||
t.Model().WorkingTreeFileCount(0)
|
||||
},
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user