From 09e80e5f2a56e5d13262e6d01c68cb4054bad6f4 Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Tue, 27 Dec 2022 15:22:31 +1100 Subject: [PATCH] better namespacing for assertions --- pkg/integration/components/alert_asserter.go | 2 +- pkg/integration/components/assert.go | 214 ++---------------- .../components/assertion_helper.go | 40 ++++ .../commit_message_panel_asserter.go | 2 +- .../components/confirmation_asserter.go | 2 +- pkg/integration/components/file_system.go | 26 +++ pkg/integration/components/input.go | 88 +++++-- pkg/integration/components/menu_asserter.go | 2 +- pkg/integration/components/model.go | 72 ++++++ pkg/integration/components/prompt_asserter.go | 2 +- pkg/integration/components/test_test.go | 4 +- .../components/{view_asserter.go => views.go} | 54 ++++- pkg/integration/tests/bisect/basic.go | 2 +- .../tests/bisect/from_other_branch.go | 2 +- pkg/integration/tests/branch/suggestions.go | 2 +- .../cherry_pick/cherry_pick_conflicts.go | 2 +- pkg/integration/tests/commit/commit.go | 6 +- .../tests/commit/commit_multiline.go | 6 +- pkg/integration/tests/commit/new_branch.go | 4 +- pkg/integration/tests/commit/revert.go | 4 +- pkg/integration/tests/commit/staged.go | 8 +- .../tests/commit/staged_without_hooks.go | 6 +- pkg/integration/tests/commit/unstaged.go | 8 +- .../tests/config/remote_named_star.go | 2 +- .../tests/custom_commands/basic.go | 2 +- .../tests/custom_commands/form_prompts.go | 4 +- .../custom_commands/menu_from_command.go | 4 +- .../menu_from_commands_output.go | 13 +- .../tests/custom_commands/multiple_prompts.go | 4 +- pkg/integration/tests/diff/diff_commits.go | 3 - .../tests/file/dir_with_untracked_file.go | 2 +- pkg/integration/tests/file/discard_changes.go | 4 +- .../tests/interactive_rebase/amend_merge.go | 8 +- pkg/integration/tests/misc/confirm_on_quit.go | 2 +- pkg/integration/tests/stash/stash.go | 8 +- .../stash/stash_including_untracked_files.go | 8 +- 36 files changed, 328 insertions(+), 294 deletions(-) create mode 100644 pkg/integration/components/assertion_helper.go create mode 100644 pkg/integration/components/file_system.go create mode 100644 pkg/integration/components/model.go rename pkg/integration/components/{view_asserter.go => views.go} (70%) diff --git a/pkg/integration/components/alert_asserter.go b/pkg/integration/components/alert_asserter.go index 9dc2d32ab..8ca027b59 100644 --- a/pkg/integration/components/alert_asserter.go +++ b/pkg/integration/components/alert_asserter.go @@ -7,7 +7,7 @@ type AlertAsserter struct { hasCheckedContent bool } -func (self *AlertAsserter) getViewAsserter() *ViewAsserter { +func (self *AlertAsserter) getViewAsserter() *Views { return self.assert.Views().ByName("confirmation") } diff --git a/pkg/integration/components/assert.go b/pkg/integration/components/assert.go index b4be669c5..42ef90d6f 100644 --- a/pkg/integration/components/assert.go +++ b/pkg/integration/components/assert.go @@ -1,12 +1,6 @@ package components import ( - "fmt" - "os" - "time" - - "github.com/jesseduffield/gocui" - "github.com/jesseduffield/lazygit/pkg/gui/types" integrationTypes "github.com/jesseduffield/lazygit/pkg/integration/types" ) @@ -14,212 +8,30 @@ import ( type Assert struct { gui integrationTypes.GuiDriver + *assertionHelper } func NewAssert(gui integrationTypes.GuiDriver) *Assert { return &Assert{gui: gui} } -func (self *Assert) WorkingTreeFileCount(expectedCount int) { - self.assertWithRetries(func() (bool, string) { - actualCount := len(self.gui.Model().Files) - - return actualCount == expectedCount, fmt.Sprintf( - "Expected %d changed working tree files, but got %d", - expectedCount, actualCount, - ) - }) -} - -func (self *Assert) CommitCount(expectedCount int) { - self.assertWithRetries(func() (bool, string) { - actualCount := len(self.gui.Model().Commits) - - return actualCount == expectedCount, fmt.Sprintf( - "Expected %d commits present, but got %d", - expectedCount, actualCount, - ) - }) -} - -func (self *Assert) StashCount(expectedCount int) { - self.assertWithRetries(func() (bool, string) { - actualCount := len(self.gui.Model().StashEntries) - - return actualCount == expectedCount, fmt.Sprintf( - "Expected %d stash entries, but got %d", - expectedCount, actualCount, - ) - }) -} - -func (self *Assert) AtLeastOneCommit() { - self.assertWithRetries(func() (bool, string) { - actualCount := len(self.gui.Model().Commits) - - return actualCount > 0, "Expected at least one commit present" - }) -} - -func (self *Assert) HeadCommitMessage(matcher *matcher) { - self.assertWithRetries(func() (bool, string) { - return len(self.gui.Model().Commits) > 0, "Expected at least one commit to be present" - }) - - self.matchString(matcher, "Unexpected commit message.", - func() string { - return self.gui.Model().Commits[0].Name - }, - ) -} - -func (self *Assert) 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) - }) -} - -func (self *Assert) CurrentBranchName(expectedViewName string) { - 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) - }) -} - -func (self *Assert) InListContext() { - self.assertWithRetries(func() (bool, string) { - currentContext := self.gui.CurrentContext() - _, ok := currentContext.(types.IListContext) - return ok, fmt.Sprintf("Expected current context to be a list context, but got %s", currentContext.GetKey()) - }) -} - -func (self *Assert) 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 *Assert) 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 *Assert) InAlert() { - // basically the same thing as a confirmation popup with the current implementation - self.assertWithRetries(func() (bool, string) { - currentView := self.gui.CurrentContext().GetView() - return currentView.Name() == "confirmation" && !currentView.Editable, "Expected alert popup to be focused" - }) -} - -func (self *Assert) InCommitMessagePanel() { - self.assertWithRetries(func() (bool, string) { - currentView := self.gui.CurrentContext().GetView() - return currentView.Name() == "commitMessage", "Expected commit message panel to be focused" - }) -} - -func (self *Assert) InMenu() { - self.assertWithRetries(func() (bool, string) { - return self.gui.CurrentContext().GetView().Name() == "menu", "Expected popup menu to be focused" - }) -} - -func (self *Assert) NotInPopup() { - self.assertWithRetries(func() (bool, string) { - currentViewName := self.gui.CurrentContext().GetView().Name() - return currentViewName != "menu" && currentViewName != "confirmation" && currentViewName != "commitMessage", "Expected popup not to be focused" - }) -} - -func (self *Assert) matchString(matcher *matcher, context string, getValue func() string) { - self.assertWithRetries(func() (bool, string) { - value := getValue() - return matcher.context(context).test(value) - }) -} - -func (self *Assert) assertWithRetries(test func() (bool, string)) { - waitTimes := []int{0, 1, 1, 1, 1, 1, 5, 10, 20, 40, 100, 200, 500, 1000, 2000, 4000} - - var message string - for _, waitTime := range waitTimes { - time.Sleep(time.Duration(waitTime) * time.Millisecond) - - var ok bool - ok, message = test() - if ok { - return - } - } - - self.Fail(message) -} - -// for when you just want to fail the test yourself -func (self *Assert) Fail(message string) { - self.gui.Fail(message) -} - -// This does _not_ check the files panel, it actually checks the filesystem -func (self *Assert) FileSystemPathPresent(path string) { - self.assertWithRetries(func() (bool, string) { - _, err := os.Stat(path) - return err == nil, fmt.Sprintf("Expected path '%s' to exist, but it does not", path) - }) -} - -// This does _not_ check the files panel, it actually checks the filesystem -func (self *Assert) FileSystemPathNotPresent(path string) { - self.assertWithRetries(func() (bool, string) { - _, err := os.Stat(path) - return os.IsNotExist(err), fmt.Sprintf("Expected path '%s' to not exist, but it does", path) - }) -} - +// for making assertions on lazygit views func (self *Assert) Views() *ViewAsserterGetter { - return &ViewAsserterGetter{ - assert: self, - } + return &ViewAsserterGetter{assert: self} } -type ViewAsserterGetter struct { - assert *Assert +// for making assertions on the lazygit model +func (self *Assert) Model() *Model { + return &Model{assertionHelper: self.assertionHelper, gui: self.gui} } -func (self *ViewAsserterGetter) Current() *ViewAsserter { - return &ViewAsserter{ - context: "current view", - getView: func() *gocui.View { return self.assert.gui.CurrentContext().GetView() }, - assert: self.assert, - } +// for making assertions on the file system +func (self *Assert) FileSystem() *FileSystem { + return &FileSystem{assertionHelper: self.assertionHelper} } -func (self *ViewAsserterGetter) Main() *ViewAsserter { - return &ViewAsserter{ - context: "main view", - getView: func() *gocui.View { return self.assert.gui.MainView() }, - assert: self.assert, - } -} - -func (self *ViewAsserterGetter) Secondary() *ViewAsserter { - return &ViewAsserter{ - context: "secondary view", - getView: func() *gocui.View { return self.assert.gui.SecondaryView() }, - assert: self.assert, - } -} - -func (self *ViewAsserterGetter) ByName(viewName string) *ViewAsserter { - return &ViewAsserter{ - context: fmt.Sprintf("%s view", viewName), - getView: func() *gocui.View { return self.assert.gui.View(viewName) }, - assert: self.assert, - } +// 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) } diff --git a/pkg/integration/components/assertion_helper.go b/pkg/integration/components/assertion_helper.go new file mode 100644 index 000000000..70f2ff182 --- /dev/null +++ b/pkg/integration/components/assertion_helper.go @@ -0,0 +1,40 @@ +package components + +import ( + "time" + + integrationTypes "github.com/jesseduffield/lazygit/pkg/integration/types" +) + +type assertionHelper struct { + gui integrationTypes.GuiDriver +} + +// milliseconds we'll wait when an assertion fails. +var retryWaitTimes = []int{0, 1, 1, 1, 1, 1, 5, 10, 20, 40, 100, 200, 500, 1000, 2000, 4000} + +func (self *assertionHelper) matchString(matcher *matcher, context string, getValue func() string) { + self.assertWithRetries(func() (bool, string) { + value := getValue() + return matcher.context(context).test(value) + }) +} + +func (self *assertionHelper) assertWithRetries(test func() (bool, string)) { + var message string + for _, waitTime := range retryWaitTimes { + time.Sleep(time.Duration(waitTime) * time.Millisecond) + + var ok bool + ok, message = test() + if ok { + return + } + } + + self.fail(message) +} + +func (self *assertionHelper) fail(message string) { + self.gui.Fail(message) +} diff --git a/pkg/integration/components/commit_message_panel_asserter.go b/pkg/integration/components/commit_message_panel_asserter.go index 6ffb6b80c..3a534bd2d 100644 --- a/pkg/integration/components/commit_message_panel_asserter.go +++ b/pkg/integration/components/commit_message_panel_asserter.go @@ -5,7 +5,7 @@ type CommitMessagePanelAsserter struct { input *Input } -func (self *CommitMessagePanelAsserter) getViewAsserter() *ViewAsserter { +func (self *CommitMessagePanelAsserter) getViewAsserter() *Views { return self.assert.Views().ByName("commitMessage") } diff --git a/pkg/integration/components/confirmation_asserter.go b/pkg/integration/components/confirmation_asserter.go index 371e46028..9cf4d653d 100644 --- a/pkg/integration/components/confirmation_asserter.go +++ b/pkg/integration/components/confirmation_asserter.go @@ -7,7 +7,7 @@ type ConfirmationAsserter struct { hasCheckedContent bool } -func (self *ConfirmationAsserter) getViewAsserter() *ViewAsserter { +func (self *ConfirmationAsserter) getViewAsserter() *Views { return self.assert.Views().ByName("confirmation") } diff --git a/pkg/integration/components/file_system.go b/pkg/integration/components/file_system.go new file mode 100644 index 000000000..040234e77 --- /dev/null +++ b/pkg/integration/components/file_system.go @@ -0,0 +1,26 @@ +package components + +import ( + "fmt" + "os" +) + +type FileSystem struct { + *assertionHelper +} + +// This does _not_ check the files panel, it actually checks the filesystem +func (self *FileSystem) PathPresent(path string) { + self.assertWithRetries(func() (bool, string) { + _, err := os.Stat(path) + return err == nil, fmt.Sprintf("Expected path '%s' to exist, but it does not", path) + }) +} + +// This does _not_ check the files panel, it actually checks the filesystem +func (self *FileSystem) PathNotPresent(path string) { + self.assertWithRetries(func() (bool, string) { + _, err := os.Stat(path) + return os.IsNotExist(err), fmt.Sprintf("Expected path '%s' to not exist, but it does", path) + }) +} diff --git a/pkg/integration/components/input.go b/pkg/integration/components/input.go index 014a74d5d..2f1ed18c5 100644 --- a/pkg/integration/components/input.go +++ b/pkg/integration/components/input.go @@ -11,18 +11,20 @@ import ( ) type Input struct { - gui integrationTypes.GuiDriver - keys config.KeybindingConfig - assert *Assert + gui integrationTypes.GuiDriver + keys config.KeybindingConfig + assert *Assert + *assertionHelper pushKeyDelay int } func NewInput(gui integrationTypes.GuiDriver, keys config.KeybindingConfig, assert *Assert, pushKeyDelay int) *Input { return &Input{ - gui: gui, - keys: keys, - assert: assert, - pushKeyDelay: pushKeyDelay, + gui: gui, + keys: keys, + assert: assert, + pushKeyDelay: pushKeyDelay, + assertionHelper: assert.assertionHelper, } } @@ -42,7 +44,7 @@ func (self *Input) press(keyStr string) { func (self *Input) SwitchToStatusWindow() { self.press(self.keys.Universal.JumpToBlock[0]) - self.assert.CurrentWindowName("status") + self.currentWindowName("status") } // switch to status window and assert that the status view is on top @@ -53,7 +55,7 @@ func (self *Input) SwitchToStatusView() { func (self *Input) SwitchToFilesWindow() { self.press(self.keys.Universal.JumpToBlock[1]) - self.assert.CurrentWindowName("files") + self.currentWindowName("files") } // switch to files window and assert that the files view is on top @@ -64,7 +66,7 @@ func (self *Input) SwitchToFilesView() { func (self *Input) SwitchToBranchesWindow() { self.press(self.keys.Universal.JumpToBlock[2]) - self.assert.CurrentWindowName("localBranches") + self.currentWindowName("localBranches") } // switch to branches window and assert that the branches view is on top @@ -75,7 +77,7 @@ func (self *Input) SwitchToBranchesView() { func (self *Input) SwitchToCommitsWindow() { self.press(self.keys.Universal.JumpToBlock[3]) - self.assert.CurrentWindowName("commits") + self.currentWindowName("commits") } // switch to commits window and assert that the commits view is on top @@ -86,7 +88,7 @@ func (self *Input) SwitchToCommitsView() { func (self *Input) SwitchToStashWindow() { self.press(self.keys.Universal.JumpToBlock[4]) - self.assert.CurrentWindowName("stash") + self.currentWindowName("stash") } // switch to stash window and assert that the stash view is on top @@ -166,7 +168,7 @@ func (self *Input) Log(message string) { // 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) { - self.assert.InListContext() + self.inListContext() currentContext := self.gui.CurrentContext().(types.IListContext) @@ -215,32 +217,82 @@ func (self *Input) NavigateToListItem(matcher *matcher) { } } +func (self *Input) inListContext() { + self.assertWithRetries(func() (bool, string) { + currentContext := self.gui.CurrentContext() + _, ok := currentContext.(types.IListContext) + return ok, fmt.Sprintf("Expected current context to be a list context, but got %s", currentContext.GetKey()) + }) +} + func (self *Input) Confirmation() *ConfirmationAsserter { - self.assert.InConfirm() + self.inConfirm() return &ConfirmationAsserter{assert: self.assert, input: self} } +func (self *Input) 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) Prompt() *PromptAsserter { - self.assert.InPrompt() + self.inPrompt() return &PromptAsserter{assert: self.assert, input: self} } +func (self *Input) 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) Alert() *AlertAsserter { - self.assert.InAlert() + self.inAlert() return &AlertAsserter{assert: self.assert, input: self} } +func (self *Input) inAlert() { + // basically the same thing as a confirmation popup with the current implementation + self.assertWithRetries(func() (bool, string) { + currentView := self.gui.CurrentContext().GetView() + return currentView.Name() == "confirmation" && !currentView.Editable, "Expected alert popup to be focused" + }) +} + func (self *Input) Menu() *MenuAsserter { - self.assert.InMenu() + self.inMenu() return &MenuAsserter{assert: self.assert, input: self} } +func (self *Input) inMenu() { + self.assertWithRetries(func() (bool, string) { + return self.gui.CurrentContext().GetView().Name() == "menu", "Expected popup menu to be focused" + }) +} + func (self *Input) CommitMessagePanel() *CommitMessagePanelAsserter { - self.assert.InCommitMessagePanel() + self.inCommitMessagePanel() return &CommitMessagePanelAsserter{assert: self.assert, input: self} } + +func (self *Input) 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) { + 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) + }) +} diff --git a/pkg/integration/components/menu_asserter.go b/pkg/integration/components/menu_asserter.go index ab2256320..e302c235b 100644 --- a/pkg/integration/components/menu_asserter.go +++ b/pkg/integration/components/menu_asserter.go @@ -6,7 +6,7 @@ type MenuAsserter struct { hasCheckedTitle bool } -func (self *MenuAsserter) getViewAsserter() *ViewAsserter { +func (self *MenuAsserter) getViewAsserter() *Views { return self.assert.Views().ByName("menu") } diff --git a/pkg/integration/components/model.go b/pkg/integration/components/model.go new file mode 100644 index 000000000..83d2e97e8 --- /dev/null +++ b/pkg/integration/components/model.go @@ -0,0 +1,72 @@ +package components + +import ( + "fmt" + + integrationTypes "github.com/jesseduffield/lazygit/pkg/integration/types" +) + +type Model struct { + *assertionHelper + gui integrationTypes.GuiDriver +} + +func (self *Model) WorkingTreeFileCount(expectedCount int) { + self.assertWithRetries(func() (bool, string) { + actualCount := len(self.gui.Model().Files) + + return actualCount == expectedCount, fmt.Sprintf( + "Expected %d changed working tree files, but got %d", + expectedCount, actualCount, + ) + }) +} + +func (self *Model) CommitCount(expectedCount int) { + self.assertWithRetries(func() (bool, string) { + actualCount := len(self.gui.Model().Commits) + + return actualCount == expectedCount, fmt.Sprintf( + "Expected %d commits present, but got %d", + expectedCount, actualCount, + ) + }) +} + +func (self *Model) StashCount(expectedCount int) { + self.assertWithRetries(func() (bool, string) { + actualCount := len(self.gui.Model().StashEntries) + + return actualCount == expectedCount, fmt.Sprintf( + "Expected %d stash entries, but got %d", + expectedCount, actualCount, + ) + }) +} + +func (self *Model) AtLeastOneCommit() { + self.assertWithRetries(func() (bool, string) { + actualCount := len(self.gui.Model().Commits) + + return actualCount > 0, "Expected at least one commit present" + }) +} + +func (self *Model) HeadCommitMessage(matcher *matcher) { + self.assertWithRetries(func() (bool, string) { + return len(self.gui.Model().Commits) > 0, "Expected at least one commit to be present" + }) + + self.matchString(matcher, "Unexpected commit message.", + func() string { + return self.gui.Model().Commits[0].Name + }, + ) +} + +func (self *Model) CurrentBranchName(expectedViewName string) { + 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) + }) +} diff --git a/pkg/integration/components/prompt_asserter.go b/pkg/integration/components/prompt_asserter.go index 079cc4d3f..b03ee85b7 100644 --- a/pkg/integration/components/prompt_asserter.go +++ b/pkg/integration/components/prompt_asserter.go @@ -6,7 +6,7 @@ type PromptAsserter struct { hasCheckedTitle bool } -func (self *PromptAsserter) getViewAsserter() *ViewAsserter { +func (self *PromptAsserter) getViewAsserter() *Views { return self.assert.Views().ByName("confirmation") } diff --git a/pkg/integration/components/test_test.go b/pkg/integration/components/test_test.go index dbab22883..eb901a402 100644 --- a/pkg/integration/components/test_test.go +++ b/pkg/integration/components/test_test.go @@ -66,7 +66,7 @@ func TestAssertionFailure(t *testing.T) { Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) { input.Press("a") input.Press("b") - assert.CommitCount(2) + assert.Model().CommitCount(2) }, }) driver := &fakeGuiDriver{} @@ -93,7 +93,7 @@ func TestSuccess(t *testing.T) { Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) { input.Press("a") input.Press("b") - assert.CommitCount(0) + assert.Model().CommitCount(0) }, }) driver := &fakeGuiDriver{} diff --git a/pkg/integration/components/view_asserter.go b/pkg/integration/components/views.go similarity index 70% rename from pkg/integration/components/view_asserter.go rename to pkg/integration/components/views.go index 73f315993..624d1f66e 100644 --- a/pkg/integration/components/view_asserter.go +++ b/pkg/integration/components/views.go @@ -6,7 +6,7 @@ import ( "github.com/jesseduffield/gocui" ) -type ViewAsserter struct { +type Views struct { // context is prepended to any error messages e.g. 'context: "current view"' context string getView func() *gocui.View @@ -15,7 +15,7 @@ type ViewAsserter struct { // 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 *ViewAsserter) Name(expected string) *ViewAsserter { +func (self *Views) Name(expected string) *Views { 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) @@ -25,7 +25,7 @@ func (self *ViewAsserter) Name(expected string) *ViewAsserter { } // asserts that the view has the expected title -func (self *ViewAsserter) Title(expected *matcher) *ViewAsserter { +func (self *Views) Title(expected *matcher) *Views { self.assert.assertWithRetries(func() (bool, string) { actual := self.getView().Title return expected.context(fmt.Sprintf("%s title", self.context)).test(actual) @@ -38,7 +38,7 @@ func (self *ViewAsserter) Title(expected *matcher) *ViewAsserter { // 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 *ViewAsserter) TopLines(matchers ...*matcher) *ViewAsserter { +func (self *Views) TopLines(matchers ...*matcher) *Views { 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)) @@ -49,7 +49,7 @@ func (self *ViewAsserter) TopLines(matchers ...*matcher) *ViewAsserter { // 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 *ViewAsserter) Lines(matchers ...*matcher) *ViewAsserter { +func (self *Views) Lines(matchers ...*matcher) *Views { 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)) @@ -58,7 +58,7 @@ func (self *ViewAsserter) Lines(matchers ...*matcher) *ViewAsserter { return self.assertLines(matchers...) } -func (self *ViewAsserter) assertLines(matchers ...*matcher) *ViewAsserter { +func (self *Views) assertLines(matchers ...*matcher) *Views { view := self.getView() for i, matcher := range matchers { @@ -82,7 +82,7 @@ func (self *ViewAsserter) assertLines(matchers ...*matcher) *ViewAsserter { } // asserts on the content of the view i.e. the stuff within the view's frame. -func (self *ViewAsserter) Content(matcher *matcher) *ViewAsserter { +func (self *Views) Content(matcher *matcher) *Views { self.assert.matchString(matcher, fmt.Sprintf("%s: Unexpected content.", self.context), func() string { return self.getView().Buffer() @@ -93,7 +93,7 @@ func (self *ViewAsserter) Content(matcher *matcher) *ViewAsserter { } // asserts on the selected line of the view -func (self *ViewAsserter) SelectedLine(matcher *matcher) *ViewAsserter { +func (self *Views) SelectedLine(matcher *matcher) *Views { self.assert.matchString(matcher, fmt.Sprintf("%s: Unexpected selected line.", self.context), func() string { return self.getView().SelectedLine() @@ -104,7 +104,7 @@ func (self *ViewAsserter) SelectedLine(matcher *matcher) *ViewAsserter { } // asserts on the index of the selected line. 0 is the first index, representing the line at the top of the view. -func (self *ViewAsserter) SelectedLineIdx(expected int) *ViewAsserter { +func (self *Views) SelectedLineIdx(expected int) *Views { 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) @@ -112,3 +112,39 @@ func (self *ViewAsserter) SelectedLineIdx(expected int) *ViewAsserter { return self } + +type ViewAsserterGetter struct { + assert *Assert +} + +func (self *ViewAsserterGetter) Current() *Views { + return &Views{ + context: "current view", + getView: func() *gocui.View { return self.assert.gui.CurrentContext().GetView() }, + assert: self.assert, + } +} + +func (self *ViewAsserterGetter) Main() *Views { + return &Views{ + context: "main view", + getView: func() *gocui.View { return self.assert.gui.MainView() }, + assert: self.assert, + } +} + +func (self *ViewAsserterGetter) Secondary() *Views { + return &Views{ + context: "secondary view", + getView: func() *gocui.View { return self.assert.gui.SecondaryView() }, + assert: self.assert, + } +} + +func (self *ViewAsserterGetter) ByName(viewName string) *Views { + return &Views{ + context: fmt.Sprintf("%s view", viewName), + getView: func() *gocui.View { return self.assert.gui.View(viewName) }, + assert: self.assert, + } +} diff --git a/pkg/integration/tests/bisect/basic.go b/pkg/integration/tests/bisect/basic.go index 7e2a21a61..dfe2b6aaa 100644 --- a/pkg/integration/tests/bisect/basic.go +++ b/pkg/integration/tests/bisect/basic.go @@ -30,7 +30,7 @@ var Basic = NewIntegrationTest(NewIntegrationTestArgs{ input.Menu().Title(Equals("Bisect")).Select(MatchesRegexp(`mark .* as good`)).Confirm() } - assert.AtLeastOneCommit() + assert.Model().AtLeastOneCommit() input.SwitchToCommitsView() diff --git a/pkg/integration/tests/bisect/from_other_branch.go b/pkg/integration/tests/bisect/from_other_branch.go index 255b39542..0caab5d67 100644 --- a/pkg/integration/tests/bisect/from_other_branch.go +++ b/pkg/integration/tests/bisect/from_other_branch.go @@ -26,7 +26,7 @@ var FromOtherBranch = NewIntegrationTest(NewIntegrationTestArgs{ ) { assert.Views().ByName("information").Content(Contains("bisecting")) - assert.AtLeastOneCommit() + assert.Model().AtLeastOneCommit() input.SwitchToCommitsView() diff --git a/pkg/integration/tests/branch/suggestions.go b/pkg/integration/tests/branch/suggestions.go index f9399296d..b33a78721 100644 --- a/pkg/integration/tests/branch/suggestions.go +++ b/pkg/integration/tests/branch/suggestions.go @@ -34,6 +34,6 @@ var Suggestions = NewIntegrationTest(NewIntegrationTestArgs{ SelectFirstSuggestion(). Confirm() - assert.CurrentBranchName("branch-to-checkout") + assert.Model().CurrentBranchName("branch-to-checkout") }, }) diff --git a/pkg/integration/tests/cherry_pick/cherry_pick_conflicts.go b/pkg/integration/tests/cherry_pick/cherry_pick_conflicts.go index b0be4b48e..b078f7164 100644 --- a/pkg/integration/tests/cherry_pick/cherry_pick_conflicts.go +++ b/pkg/integration/tests/cherry_pick/cherry_pick_conflicts.go @@ -70,7 +70,7 @@ var CherryPickConflicts = NewIntegrationTest(NewIntegrationTestArgs{ Confirm() assert.Views().Current().Name("files") - assert.WorkingTreeFileCount(0) + assert.Model().WorkingTreeFileCount(0) input.SwitchToCommitsView() diff --git a/pkg/integration/tests/commit/commit.go b/pkg/integration/tests/commit/commit.go index cda9f63e0..93ccf5b53 100644 --- a/pkg/integration/tests/commit/commit.go +++ b/pkg/integration/tests/commit/commit.go @@ -15,7 +15,7 @@ var Commit = NewIntegrationTest(NewIntegrationTestArgs{ shell.CreateFile("myfile2", "myfile2 content") }, Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) { - assert.CommitCount(0) + assert.Model().CommitCount(0) input.PrimaryAction() input.NextItem() @@ -26,7 +26,7 @@ var Commit = NewIntegrationTest(NewIntegrationTestArgs{ input.CommitMessagePanel().Type(commitMessage).Confirm() - assert.CommitCount(1) - assert.HeadCommitMessage(Equals(commitMessage)) + assert.Model().CommitCount(1) + assert.Model().HeadCommitMessage(Equals(commitMessage)) }, }) diff --git a/pkg/integration/tests/commit/commit_multiline.go b/pkg/integration/tests/commit/commit_multiline.go index eb0723c39..3beeff344 100644 --- a/pkg/integration/tests/commit/commit_multiline.go +++ b/pkg/integration/tests/commit/commit_multiline.go @@ -14,15 +14,15 @@ var CommitMultiline = NewIntegrationTest(NewIntegrationTestArgs{ shell.CreateFile("myfile", "myfile content") }, Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) { - assert.CommitCount(0) + assert.Model().CommitCount(0) input.PrimaryAction() input.Press(keys.Files.CommitChanges) input.CommitMessagePanel().Type("first line").AddNewline().AddNewline().Type("third line").Confirm() - assert.CommitCount(1) - assert.HeadCommitMessage(Equals("first line")) + assert.Model().CommitCount(1) + assert.Model().HeadCommitMessage(Equals("first line")) input.SwitchToCommitsView() assert.Views().Main().Content(MatchesRegexp("first line\n\\s*\n\\s*third line")) diff --git a/pkg/integration/tests/commit/new_branch.go b/pkg/integration/tests/commit/new_branch.go index a4001df8d..c02ffb9a9 100644 --- a/pkg/integration/tests/commit/new_branch.go +++ b/pkg/integration/tests/commit/new_branch.go @@ -17,7 +17,7 @@ var NewBranch = NewIntegrationTest(NewIntegrationTestArgs{ EmptyCommit("commit 3") }, Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) { - assert.CommitCount(3) + assert.Model().CommitCount(3) input.SwitchToCommitsView() assert.Views().Current().Lines( @@ -32,7 +32,7 @@ var NewBranch = NewIntegrationTest(NewIntegrationTestArgs{ branchName := "my-branch-name" input.Prompt().Title(Equals("New Branch Name")).Type(branchName).Confirm() - assert.CurrentBranchName(branchName) + assert.Model().CurrentBranchName(branchName) assert.Views().ByName("commits").Lines( Contains("commit 2"), diff --git a/pkg/integration/tests/commit/revert.go b/pkg/integration/tests/commit/revert.go index 5ce7ac12b..ca1a94be5 100644 --- a/pkg/integration/tests/commit/revert.go +++ b/pkg/integration/tests/commit/revert.go @@ -16,7 +16,7 @@ var Revert = NewIntegrationTest(NewIntegrationTestArgs{ shell.Commit("first commit") }, Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) { - assert.CommitCount(1) + assert.Model().CommitCount(1) input.SwitchToCommitsView() @@ -37,6 +37,6 @@ var Revert = NewIntegrationTest(NewIntegrationTestArgs{ ) assert.Views().Main().Content(Contains("-myfile content")) - assert.FileSystemPathNotPresent("myfile") + assert.FileSystem().PathNotPresent("myfile") }, }) diff --git a/pkg/integration/tests/commit/staged.go b/pkg/integration/tests/commit/staged.go index 7862aaeef..ffcd7dd9b 100644 --- a/pkg/integration/tests/commit/staged.go +++ b/pkg/integration/tests/commit/staged.go @@ -16,7 +16,7 @@ var Staged = NewIntegrationTest(NewIntegrationTestArgs{ CreateFile("myfile2", "myfile2 content") }, Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) { - assert.CommitCount(0) + assert.Model().CommitCount(0) assert.Views().Current().Name("files") assert.Views().Current().SelectedLine(Contains("myfile")) @@ -44,9 +44,9 @@ var Staged = NewIntegrationTest(NewIntegrationTestArgs{ input.Type(commitMessage) input.Confirm() - assert.CommitCount(1) - assert.HeadCommitMessage(Equals(commitMessage)) - assert.CurrentWindowName("stagingSecondary") + assert.Model().CommitCount(1) + assert.Model().HeadCommitMessage(Equals(commitMessage)) + assert.Views().Current().Name("stagingSecondary") // TODO: assert that the staging panel has been refreshed (it currently does not get correctly refreshed) }, diff --git a/pkg/integration/tests/commit/staged_without_hooks.go b/pkg/integration/tests/commit/staged_without_hooks.go index 1f41238a3..9d1dcb97d 100644 --- a/pkg/integration/tests/commit/staged_without_hooks.go +++ b/pkg/integration/tests/commit/staged_without_hooks.go @@ -16,7 +16,7 @@ var StagedWithoutHooks = NewIntegrationTest(NewIntegrationTestArgs{ CreateFile("myfile2", "myfile2 content") }, Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) { - assert.CommitCount(0) + assert.Model().CommitCount(0) // stage the file assert.Views().Current().Name("files") @@ -44,8 +44,8 @@ var StagedWithoutHooks = NewIntegrationTest(NewIntegrationTestArgs{ commitMessage := ": my commit message" input.CommitMessagePanel().InitialText(Contains("WIP")).Type(commitMessage).Confirm() - assert.CommitCount(1) - assert.HeadCommitMessage(Equals("WIP" + commitMessage)) + assert.Model().CommitCount(1) + assert.Model().HeadCommitMessage(Equals("WIP" + commitMessage)) assert.Views().Current().Name("stagingSecondary") // TODO: assert that the staging panel has been refreshed (it currently does not get correctly refreshed) diff --git a/pkg/integration/tests/commit/unstaged.go b/pkg/integration/tests/commit/unstaged.go index 9b56c9c43..e8c8126e0 100644 --- a/pkg/integration/tests/commit/unstaged.go +++ b/pkg/integration/tests/commit/unstaged.go @@ -18,7 +18,7 @@ var Unstaged = NewIntegrationTest(NewIntegrationTestArgs{ CreateFile("myfile2", "myfile2 content") }, Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) { - assert.CommitCount(0) + assert.Model().CommitCount(0) assert.Views().Current().Name("files").SelectedLine(Contains("myfile")) input.Enter() @@ -34,9 +34,9 @@ var Unstaged = NewIntegrationTest(NewIntegrationTestArgs{ commitMessage := "my commit message" input.CommitMessagePanel().Type(commitMessage).Confirm() - assert.CommitCount(1) - assert.HeadCommitMessage(Equals(commitMessage)) - assert.CurrentWindowName("staging") + assert.Model().CommitCount(1) + assert.Model().HeadCommitMessage(Equals(commitMessage)) + assert.Views().Current().Name("staging") // TODO: assert that the staging panel has been refreshed (it currently does not get correctly refreshed) }, diff --git a/pkg/integration/tests/config/remote_named_star.go b/pkg/integration/tests/config/remote_named_star.go index fd28dea7b..589394061 100644 --- a/pkg/integration/tests/config/remote_named_star.go +++ b/pkg/integration/tests/config/remote_named_star.go @@ -22,6 +22,6 @@ var RemoteNamedStar = NewIntegrationTest(NewIntegrationTestArgs{ keys config.KeybindingConfig, ) { // here we're just asserting that we haven't panicked upon starting lazygit - assert.AtLeastOneCommit() + assert.Model().AtLeastOneCommit() }, }) diff --git a/pkg/integration/tests/custom_commands/basic.go b/pkg/integration/tests/custom_commands/basic.go index 7fb67aa77..bd7b1519b 100644 --- a/pkg/integration/tests/custom_commands/basic.go +++ b/pkg/integration/tests/custom_commands/basic.go @@ -27,7 +27,7 @@ var Basic = NewIntegrationTest(NewIntegrationTestArgs{ assert *Assert, keys config.KeybindingConfig, ) { - assert.WorkingTreeFileCount(0) + assert.Model().WorkingTreeFileCount(0) input.Press("a") diff --git a/pkg/integration/tests/custom_commands/form_prompts.go b/pkg/integration/tests/custom_commands/form_prompts.go index 6778dd7aa..cc854d524 100644 --- a/pkg/integration/tests/custom_commands/form_prompts.go +++ b/pkg/integration/tests/custom_commands/form_prompts.go @@ -61,7 +61,7 @@ var FormPrompts = NewIntegrationTest(NewIntegrationTestArgs{ assert *Assert, keys config.KeybindingConfig, ) { - assert.WorkingTreeFileCount(0) + assert.Model().WorkingTreeFileCount(0) input.Press("a") @@ -74,7 +74,7 @@ var FormPrompts = NewIntegrationTest(NewIntegrationTestArgs{ Content(Equals("Are you REALLY sure you want to make this file? Up to you buddy.")). Confirm() - assert.WorkingTreeFileCount(1) + assert.Model().WorkingTreeFileCount(1) assert.Views().Current().SelectedLine(Contains("my file")) assert.Views().Main().Content(Contains(`"BAR"`)) }, diff --git a/pkg/integration/tests/custom_commands/menu_from_command.go b/pkg/integration/tests/custom_commands/menu_from_command.go index 7268a0c25..a89b4e90a 100644 --- a/pkg/integration/tests/custom_commands/menu_from_command.go +++ b/pkg/integration/tests/custom_commands/menu_from_command.go @@ -48,7 +48,7 @@ var MenuFromCommand = NewIntegrationTest(NewIntegrationTestArgs{ assert *Assert, keys config.KeybindingConfig, ) { - assert.WorkingTreeFileCount(0) + assert.Model().WorkingTreeFileCount(0) input.SwitchToBranchesView() input.Press("a") @@ -59,7 +59,7 @@ var MenuFromCommand = NewIntegrationTest(NewIntegrationTestArgs{ input.SwitchToFilesView() - assert.WorkingTreeFileCount(1) + assert.Model().WorkingTreeFileCount(1) assert.Views().Current().SelectedLine(Contains("output.txt")) assert.Views().Main().Content(Contains("bar Branch: #feature/foo my branch feature/foo")) }, diff --git a/pkg/integration/tests/custom_commands/menu_from_commands_output.go b/pkg/integration/tests/custom_commands/menu_from_commands_output.go index f7177f086..e17f38cdd 100644 --- a/pkg/integration/tests/custom_commands/menu_from_commands_output.go +++ b/pkg/integration/tests/custom_commands/menu_from_commands_output.go @@ -47,21 +47,20 @@ var MenuFromCommandsOutput = NewIntegrationTest(NewIntegrationTestArgs{ assert *Assert, keys config.KeybindingConfig, ) { - assert.CurrentBranchName("feature/bar") + assert.Model().CurrentBranchName("feature/bar") - assert.WorkingTreeFileCount(0) + assert.Model().WorkingTreeFileCount(0) input.SwitchToBranchesView() input.Press("a") - assert.InPrompt() - assert.Views().Current(). + input.Prompt(). Title(Equals("Which git command do you want to run?")). - SelectedLine(Equals("branch")) - input.Confirm() + InitialText(Equals("branch")). + Confirm() input.Menu().Title(Equals("Branch:")).Select(Equals("master")).Confirm() - assert.CurrentBranchName("master") + assert.Model().CurrentBranchName("master") }, }) diff --git a/pkg/integration/tests/custom_commands/multiple_prompts.go b/pkg/integration/tests/custom_commands/multiple_prompts.go index ec49a127d..c3f040e27 100644 --- a/pkg/integration/tests/custom_commands/multiple_prompts.go +++ b/pkg/integration/tests/custom_commands/multiple_prompts.go @@ -59,7 +59,7 @@ var MultiplePrompts = NewIntegrationTest(NewIntegrationTestArgs{ assert *Assert, keys config.KeybindingConfig, ) { - assert.WorkingTreeFileCount(0) + assert.Model().WorkingTreeFileCount(0) input.Press("a") @@ -72,7 +72,7 @@ var MultiplePrompts = NewIntegrationTest(NewIntegrationTestArgs{ Content(Equals("Are you REALLY sure you want to make this file? Up to you buddy.")). Confirm() - assert.WorkingTreeFileCount(1) + assert.Model().WorkingTreeFileCount(1) assert.Views().Current().SelectedLine(Contains("myfile")) assert.Views().Main().Content(Contains("BAR")) }, diff --git a/pkg/integration/tests/diff/diff_commits.go b/pkg/integration/tests/diff/diff_commits.go index 9095c22e8..d05272e07 100644 --- a/pkg/integration/tests/diff/diff_commits.go +++ b/pkg/integration/tests/diff/diff_commits.go @@ -30,8 +30,6 @@ var DiffCommits = NewIntegrationTest(NewIntegrationTestArgs{ input.Press(keys.Universal.DiffingMenu) input.Menu().Title(Equals("Diffing")).Select(MatchesRegexp(`diff \w+`)).Confirm() - assert.NotInPopup() - assert.Views().ByName("information").Content(Contains("showing output for: git diff")) input.NextItem() @@ -42,7 +40,6 @@ var DiffCommits = NewIntegrationTest(NewIntegrationTestArgs{ input.Press(keys.Universal.DiffingMenu) input.Menu().Title(Equals("Diffing")).Select(Contains("reverse diff direction")).Confirm() - assert.NotInPopup() assert.Views().Main().Content(Contains("+second line\n+third line")) diff --git a/pkg/integration/tests/file/dir_with_untracked_file.go b/pkg/integration/tests/file/dir_with_untracked_file.go index 344aa7c91..bfd40f2ea 100644 --- a/pkg/integration/tests/file/dir_with_untracked_file.go +++ b/pkg/integration/tests/file/dir_with_untracked_file.go @@ -22,7 +22,7 @@ var DirWithUntrackedFile = NewIntegrationTest(NewIntegrationTestArgs{ shell.UpdateFile("dir/file", "baz") }, Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) { - assert.CommitCount(1) + assert.Model().CommitCount(1) assert.Views().Main(). Content(DoesNotContain("error: Could not access")). diff --git a/pkg/integration/tests/file/discard_changes.go b/pkg/integration/tests/file/discard_changes.go index 12324e7c1..cb650f34d 100644 --- a/pkg/integration/tests/file/discard_changes.go +++ b/pkg/integration/tests/file/discard_changes.go @@ -72,7 +72,7 @@ var DiscardChanges = NewIntegrationTest(NewIntegrationTestArgs{ }, Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) { - assert.CommitCount(3) + assert.Model().CommitCount(3) type statusFile struct { status string @@ -118,6 +118,6 @@ var DiscardChanges = NewIntegrationTest(NewIntegrationTestArgs{ {status: "??", label: "new.txt", menuTitle: "new.txt"}, }) - assert.WorkingTreeFileCount(0) + assert.Model().WorkingTreeFileCount(0) }, }) diff --git a/pkg/integration/tests/interactive_rebase/amend_merge.go b/pkg/integration/tests/interactive_rebase/amend_merge.go index 67a90ff6f..6bfbdb4db 100644 --- a/pkg/integration/tests/interactive_rebase/amend_merge.go +++ b/pkg/integration/tests/interactive_rebase/amend_merge.go @@ -28,12 +28,12 @@ var AmendMerge = NewIntegrationTest(NewIntegrationTestArgs{ CreateFileAndAdd(postMergeFilename, postMergeFileContent) }, Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) { - assert.CommitCount(3) + assert.Model().CommitCount(3) input.SwitchToCommitsView() mergeCommitMessage := "Merge branch 'feature-branch' into development-branch" - assert.HeadCommitMessage(Contains(mergeCommitMessage)) + assert.Model().HeadCommitMessage(Contains(mergeCommitMessage)) input.Press(keys.Commits.AmendToCommit) input.Confirmation(). @@ -42,8 +42,8 @@ var AmendMerge = NewIntegrationTest(NewIntegrationTestArgs{ Confirm() // assuring we haven't added a brand new commit - assert.CommitCount(3) - assert.HeadCommitMessage(Contains(mergeCommitMessage)) + assert.Model().CommitCount(3) + assert.Model().HeadCommitMessage(Contains(mergeCommitMessage)) // assuring the post-merge file shows up in the merge commit. assert.Views().Main(). diff --git a/pkg/integration/tests/misc/confirm_on_quit.go b/pkg/integration/tests/misc/confirm_on_quit.go index 5f377eeab..4d12418c1 100644 --- a/pkg/integration/tests/misc/confirm_on_quit.go +++ b/pkg/integration/tests/misc/confirm_on_quit.go @@ -14,7 +14,7 @@ var ConfirmOnQuit = NewIntegrationTest(NewIntegrationTestArgs{ }, SetupRepo: func(shell *Shell) {}, Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) { - assert.CommitCount(0) + assert.Model().CommitCount(0) input.Press(keys.Universal.Quit) input.Confirmation(). diff --git a/pkg/integration/tests/stash/stash.go b/pkg/integration/tests/stash/stash.go index 8f1281bc3..e506b150a 100644 --- a/pkg/integration/tests/stash/stash.go +++ b/pkg/integration/tests/stash/stash.go @@ -16,8 +16,8 @@ var Stash = NewIntegrationTest(NewIntegrationTestArgs{ shell.GitAddAll() }, Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) { - assert.StashCount(0) - assert.WorkingTreeFileCount(1) + assert.Model().StashCount(0) + assert.Model().WorkingTreeFileCount(1) input.Press(keys.Files.ViewStashOptions) @@ -25,7 +25,7 @@ var Stash = NewIntegrationTest(NewIntegrationTestArgs{ input.Prompt().Title(Equals("Stash changes")).Type("my stashed file").Confirm() - assert.StashCount(1) - assert.WorkingTreeFileCount(0) + assert.Model().StashCount(1) + assert.Model().WorkingTreeFileCount(0) }, }) diff --git a/pkg/integration/tests/stash/stash_including_untracked_files.go b/pkg/integration/tests/stash/stash_including_untracked_files.go index 51cdbbc25..673bb1c04 100644 --- a/pkg/integration/tests/stash/stash_including_untracked_files.go +++ b/pkg/integration/tests/stash/stash_including_untracked_files.go @@ -17,8 +17,8 @@ var StashIncludingUntrackedFiles = NewIntegrationTest(NewIntegrationTestArgs{ shell.GitAdd("file_1") }, Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) { - assert.StashCount(0) - assert.WorkingTreeFileCount(2) + assert.Model().StashCount(0) + assert.Model().WorkingTreeFileCount(2) input.Press(keys.Files.ViewStashOptions) @@ -26,7 +26,7 @@ var StashIncludingUntrackedFiles = NewIntegrationTest(NewIntegrationTestArgs{ input.Prompt().Title(Equals("Stash changes")).Type("my stashed file").Confirm() - assert.StashCount(1) - assert.WorkingTreeFileCount(0) + assert.Model().StashCount(1) + assert.Model().WorkingTreeFileCount(0) }, })