diff --git a/pkg/integration/components/input.go b/pkg/integration/components/input.go index 03aacd758..796d1bf9d 100644 --- a/pkg/integration/components/input.go +++ b/pkg/integration/components/input.go @@ -45,26 +45,56 @@ func (self *Input) SwitchToStatusWindow() { self.assert.CurrentWindowName("status") } +// switch to status window and assert that the status view is on top +func (self *Input) SwitchToStatusView() { + self.SwitchToStatusWindow() + self.assert.CurrentView().Name("status") +} + func (self *Input) SwitchToFilesWindow() { self.press(self.keys.Universal.JumpToBlock[1]) self.assert.CurrentWindowName("files") } +// switch to files window and assert that the files view is on top +func (self *Input) SwitchToFilesView() { + self.SwitchToFilesWindow() + self.assert.CurrentView().Name("files") +} + func (self *Input) SwitchToBranchesWindow() { self.press(self.keys.Universal.JumpToBlock[2]) self.assert.CurrentWindowName("localBranches") } +// switch to branches window and assert that the branches view is on top +func (self *Input) SwitchToBranchesView() { + self.SwitchToBranchesWindow() + self.assert.CurrentView().Name("localBranches") +} + func (self *Input) SwitchToCommitsWindow() { self.press(self.keys.Universal.JumpToBlock[3]) self.assert.CurrentWindowName("commits") } +// switch to commits window and assert that the commits view is on top +func (self *Input) SwitchToCommitsView() { + self.SwitchToCommitsWindow() + self.assert.CurrentView().Name("commits") +} + func (self *Input) SwitchToStashWindow() { self.press(self.keys.Universal.JumpToBlock[4]) self.assert.CurrentWindowName("stash") } +// switch to stash window and assert that the stash view is on top +func (self *Input) SwitchToStashView() { + self.SwitchToStashWindow() + self.assert.CurrentView().Name("stash") +} + func (self *Input) Type(content string) { for _, char := range content { self.press(string(char)) diff --git a/pkg/integration/tests/bisect/basic.go b/pkg/integration/tests/bisect/basic.go index 58fcb8896..52e272c3a 100644 --- a/pkg/integration/tests/bisect/basic.go +++ b/pkg/integration/tests/bisect/basic.go @@ -32,7 +32,7 @@ var Basic = NewIntegrationTest(NewIntegrationTestArgs{ assert.AtLeastOneCommit() - input.SwitchToCommitsWindow() + input.SwitchToCommitsView() assert.CurrentView().SelectedLine(Contains("commit 10")) diff --git a/pkg/integration/tests/bisect/from_other_branch.go b/pkg/integration/tests/bisect/from_other_branch.go index a523a4e3e..36dad4705 100644 --- a/pkg/integration/tests/bisect/from_other_branch.go +++ b/pkg/integration/tests/bisect/from_other_branch.go @@ -28,9 +28,9 @@ var FromOtherBranch = NewIntegrationTest(NewIntegrationTestArgs{ assert.AtLeastOneCommit() - input.SwitchToCommitsWindow() + input.SwitchToCommitsView() - assert.CurrentView().Name("commits").TopLines( + assert.CurrentView().TopLines( MatchesRegexp(`<-- bad.*commit 08`), MatchesRegexp(`<-- current.*commit 07`), MatchesRegexp(`\?.*commit 06`), diff --git a/pkg/integration/tests/branch/checkout_by_name.go b/pkg/integration/tests/branch/checkout_by_name.go index d8af26ee9..d3742e8f9 100644 --- a/pkg/integration/tests/branch/checkout_by_name.go +++ b/pkg/integration/tests/branch/checkout_by_name.go @@ -18,9 +18,9 @@ var CheckoutByName = NewIntegrationTest(NewIntegrationTestArgs{ EmptyCommit("blah") }, Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) { - input.SwitchToBranchesWindow() + input.SwitchToBranchesView() - assert.CurrentView().Name("localBranches").Lines( + assert.CurrentView().Lines( Contains("master"), Contains("@"), ) diff --git a/pkg/integration/tests/branch/delete.go b/pkg/integration/tests/branch/delete.go index a873ebaef..c90458546 100644 --- a/pkg/integration/tests/branch/delete.go +++ b/pkg/integration/tests/branch/delete.go @@ -17,9 +17,9 @@ var Delete = NewIntegrationTest(NewIntegrationTestArgs{ NewBranch("branch-two") }, Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) { - input.SwitchToBranchesWindow() + input.SwitchToBranchesView() - assert.CurrentView().Name("localBranches").Lines( + assert.CurrentView().Lines( MatchesRegexp(`\*.*branch-two`), MatchesRegexp(`branch-one`), MatchesRegexp(`master`), diff --git a/pkg/integration/tests/branch/rebase.go b/pkg/integration/tests/branch/rebase.go index 2b158e5e4..ad0e40925 100644 --- a/pkg/integration/tests/branch/rebase.go +++ b/pkg/integration/tests/branch/rebase.go @@ -15,8 +15,7 @@ var Rebase = NewIntegrationTest(NewIntegrationTestArgs{ shared.MergeConflictsSetup(shell) }, Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) { - input.SwitchToBranchesWindow() - assert.CurrentView().Name("localBranches") + input.SwitchToBranchesView() assert.View("localBranches").Lines( Contains("first-change-branch"), diff --git a/pkg/integration/tests/branch/rebase_and_drop.go b/pkg/integration/tests/branch/rebase_and_drop.go index 5d62ed551..5c1afe141 100644 --- a/pkg/integration/tests/branch/rebase_and_drop.go +++ b/pkg/integration/tests/branch/rebase_and_drop.go @@ -18,9 +18,9 @@ var RebaseAndDrop = NewIntegrationTest(NewIntegrationTestArgs{ shell.EmptyCommit("to keep") }, Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) { - input.SwitchToBranchesWindow() + input.SwitchToBranchesView() - assert.CurrentView().Name("localBranches").Lines( + assert.CurrentView().Lines( Contains("first-change-branch"), Contains("second-change-branch"), Contains("original-branch"), @@ -46,9 +46,8 @@ var RebaseAndDrop = NewIntegrationTest(NewIntegrationTestArgs{ Name("files"). SelectedLine(Contains("file")) - input.SwitchToCommitsWindow() + input.SwitchToCommitsView() assert.CurrentView(). - Name("commits"). TopLines( MatchesRegexp(`pick.*to keep`), MatchesRegexp(`pick.*to remove`), @@ -62,7 +61,7 @@ var RebaseAndDrop = NewIntegrationTest(NewIntegrationTestArgs{ input.Press(keys.Universal.Remove) assert.CurrentView().SelectedLine(MatchesRegexp(`drop.*to remove`)) - input.SwitchToFilesWindow() + input.SwitchToFilesView() // not using Confirm() convenience method because I suspect we might change this // keybinding to something more bespoke diff --git a/pkg/integration/tests/branch/reset.go b/pkg/integration/tests/branch/reset.go index d7b2db5a3..8be35e4ec 100644 --- a/pkg/integration/tests/branch/reset.go +++ b/pkg/integration/tests/branch/reset.go @@ -26,9 +26,9 @@ var Reset = NewIntegrationTest(NewIntegrationTestArgs{ Contains("root commit"), ) - input.SwitchToBranchesWindow() + input.SwitchToBranchesView() - assert.CurrentView().Name("localBranches").Lines( + assert.CurrentView().Lines( Contains("current-branch"), Contains("other-branch"), ) @@ -42,8 +42,8 @@ var Reset = NewIntegrationTest(NewIntegrationTestArgs{ assert.CurrentView().Name("localBranches") // assert that we now have the expected commits in the commit panel - input.SwitchToCommitsWindow() - assert.CurrentView().Name("commits").Lines( + input.SwitchToCommitsView() + assert.CurrentView().Lines( Contains("other-branch commit"), Contains("root commit"), ) diff --git a/pkg/integration/tests/branch/suggestions.go b/pkg/integration/tests/branch/suggestions.go index 22c276556..7631ad735 100644 --- a/pkg/integration/tests/branch/suggestions.go +++ b/pkg/integration/tests/branch/suggestions.go @@ -21,8 +21,7 @@ var Suggestions = NewIntegrationTest(NewIntegrationTestArgs{ NewBranch("other-new-branch-3") }, Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) { - input.SwitchToBranchesWindow() - assert.CurrentView().Name("localBranches") + input.SwitchToBranchesView() input.Press(keys.Branches.CheckoutBranchByName) diff --git a/pkg/integration/tests/cherry_pick/cherry_pick.go b/pkg/integration/tests/cherry_pick/cherry_pick.go index 7ca89f402..e306a016e 100644 --- a/pkg/integration/tests/cherry_pick/cherry_pick.go +++ b/pkg/integration/tests/cherry_pick/cherry_pick.go @@ -24,9 +24,9 @@ var CherryPick = NewIntegrationTest(NewIntegrationTestArgs{ Checkout("first-branch") }, Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) { - input.SwitchToBranchesWindow() + input.SwitchToBranchesView() - assert.CurrentView().Name("localBranches").Lines( + assert.CurrentView().Lines( Contains("first-branch"), Contains("second-branch"), Contains("master"), @@ -49,9 +49,9 @@ var CherryPick = NewIntegrationTest(NewIntegrationTestArgs{ input.Press(keys.Commits.CherryPickCopy) assert.View("information").Content(Contains("2 commits copied")) - input.SwitchToCommitsWindow() + input.SwitchToCommitsView() - assert.CurrentView().Name("commits").Lines( + assert.CurrentView().Lines( Contains("two"), Contains("one"), Contains("base"), diff --git a/pkg/integration/tests/cherry_pick/cherry_pick_conflicts.go b/pkg/integration/tests/cherry_pick/cherry_pick_conflicts.go index 3dfb995e2..2aed02334 100644 --- a/pkg/integration/tests/cherry_pick/cherry_pick_conflicts.go +++ b/pkg/integration/tests/cherry_pick/cherry_pick_conflicts.go @@ -15,8 +15,8 @@ var CherryPickConflicts = NewIntegrationTest(NewIntegrationTestArgs{ shared.MergeConflictsSetup(shell) }, Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) { - input.SwitchToBranchesWindow() - assert.CurrentView().Name("localBranches").Lines( + input.SwitchToBranchesView() + assert.CurrentView().Lines( Contains("first-change-branch"), Contains("second-change-branch"), Contains("original-branch"), @@ -38,9 +38,9 @@ var CherryPickConflicts = NewIntegrationTest(NewIntegrationTestArgs{ input.Press(keys.Commits.CherryPickCopy) assert.View("information").Content(Contains("2 commits copied")) - input.SwitchToCommitsWindow() + input.SwitchToCommitsView() - assert.CurrentView().Name("commits").TopLines( + assert.CurrentView().TopLines( Contains("first change"), ) @@ -66,9 +66,9 @@ var CherryPickConflicts = NewIntegrationTest(NewIntegrationTestArgs{ assert.CurrentView().Name("files") assert.WorkingTreeFileCount(0) - input.SwitchToCommitsWindow() + input.SwitchToCommitsView() - assert.CurrentView().Name("commits").TopLines( + assert.CurrentView().TopLines( Contains("second-change-branch unrelated change"), Contains("second change"), Contains("first change"), diff --git a/pkg/integration/tests/commit/commit_multiline.go b/pkg/integration/tests/commit/commit_multiline.go index 79085926b..d19e09a72 100644 --- a/pkg/integration/tests/commit/commit_multiline.go +++ b/pkg/integration/tests/commit/commit_multiline.go @@ -29,7 +29,7 @@ var CommitMultiline = NewIntegrationTest(NewIntegrationTestArgs{ assert.CommitCount(1) assert.HeadCommitMessage(Equals("first line")) - input.SwitchToCommitsWindow() + input.SwitchToCommitsView() assert.MainView().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 55887676b..1702b0973 100644 --- a/pkg/integration/tests/commit/new_branch.go +++ b/pkg/integration/tests/commit/new_branch.go @@ -19,8 +19,8 @@ var NewBranch = NewIntegrationTest(NewIntegrationTestArgs{ Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) { assert.CommitCount(3) - input.SwitchToCommitsWindow() - assert.CurrentView().Name("commits").Lines( + input.SwitchToCommitsView() + assert.CurrentView().Lines( Contains("commit 3"), Contains("commit 2"), Contains("commit 1"), diff --git a/pkg/integration/tests/commit/revert.go b/pkg/integration/tests/commit/revert.go index c62124994..e23091baf 100644 --- a/pkg/integration/tests/commit/revert.go +++ b/pkg/integration/tests/commit/revert.go @@ -18,9 +18,9 @@ var Revert = NewIntegrationTest(NewIntegrationTestArgs{ Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) { assert.CommitCount(1) - input.SwitchToCommitsWindow() + input.SwitchToCommitsView() - assert.CurrentView().Name("commits").Lines( + assert.CurrentView().Lines( Contains("first commit"), ) diff --git a/pkg/integration/tests/custom_commands/menu_from_command.go b/pkg/integration/tests/custom_commands/menu_from_command.go index 7fee7ba6c..c4fe063e2 100644 --- a/pkg/integration/tests/custom_commands/menu_from_command.go +++ b/pkg/integration/tests/custom_commands/menu_from_command.go @@ -49,7 +49,7 @@ var MenuFromCommand = NewIntegrationTest(NewIntegrationTestArgs{ keys config.KeybindingConfig, ) { assert.WorkingTreeFileCount(0) - input.SwitchToBranchesWindow() + input.SwitchToBranchesView() input.Press("a") @@ -57,7 +57,7 @@ var MenuFromCommand = NewIntegrationTest(NewIntegrationTestArgs{ input.Prompt(Equals("Description"), " my branch") - input.SwitchToFilesWindow() + input.SwitchToFilesView() assert.WorkingTreeFileCount(1) assert.CurrentView().SelectedLine(Contains("output.txt")) 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 bfc26efcf..68c4db0f6 100644 --- a/pkg/integration/tests/custom_commands/menu_from_commands_output.go +++ b/pkg/integration/tests/custom_commands/menu_from_commands_output.go @@ -50,7 +50,7 @@ var MenuFromCommandsOutput = NewIntegrationTest(NewIntegrationTestArgs{ assert.CurrentBranchName("feature/bar") assert.WorkingTreeFileCount(0) - input.SwitchToBranchesWindow() + input.SwitchToBranchesView() input.Press("a") diff --git a/pkg/integration/tests/diff/diff.go b/pkg/integration/tests/diff/diff.go index 561b04be0..4bba36de8 100644 --- a/pkg/integration/tests/diff/diff.go +++ b/pkg/integration/tests/diff/diff.go @@ -22,9 +22,9 @@ var Diff = NewIntegrationTest(NewIntegrationTestArgs{ shell.Checkout("branch-a") }, Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) { - input.SwitchToBranchesWindow() + input.SwitchToBranchesView() - assert.CurrentView().Name("localBranches").TopLines( + assert.CurrentView().TopLines( Contains("branch-a"), Contains("branch-b"), ) diff --git a/pkg/integration/tests/diff/diff_and_apply_patch.go b/pkg/integration/tests/diff/diff_and_apply_patch.go index 94b5f51d6..6e85b3911 100644 --- a/pkg/integration/tests/diff/diff_and_apply_patch.go +++ b/pkg/integration/tests/diff/diff_and_apply_patch.go @@ -22,8 +22,8 @@ var DiffAndApplyPatch = NewIntegrationTest(NewIntegrationTestArgs{ shell.Checkout("branch-a") }, Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) { - input.SwitchToBranchesWindow() - assert.CurrentView().Name("localBranches").Lines( + input.SwitchToBranchesView() + assert.CurrentView().Lines( Contains("branch-a"), Contains("branch-b"), ) @@ -60,7 +60,7 @@ var DiffAndApplyPatch = NewIntegrationTest(NewIntegrationTestArgs{ // adding the regex '$' here to distinguish the menu item from the 'apply patch in reverse' item input.Menu(Equals("Patch Options"), MatchesRegexp("apply patch$")) - input.SwitchToFilesWindow() + input.SwitchToFilesView() assert.CurrentView().SelectedLine(Contains("file1")) assert.MainView().Content(Contains("+second line")) diff --git a/pkg/integration/tests/diff/diff_commits.go b/pkg/integration/tests/diff/diff_commits.go index 280b6922c..920686c2c 100644 --- a/pkg/integration/tests/diff/diff_commits.go +++ b/pkg/integration/tests/diff/diff_commits.go @@ -19,9 +19,9 @@ var DiffCommits = NewIntegrationTest(NewIntegrationTestArgs{ shell.Commit("third commit") }, Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) { - input.SwitchToCommitsWindow() + input.SwitchToCommitsView() - assert.CurrentView().Name("commits").Lines( + assert.CurrentView().Lines( Contains("third commit"), Contains("second commit"), Contains("first commit"), diff --git a/pkg/integration/tests/interactive_rebase/amend_merge.go b/pkg/integration/tests/interactive_rebase/amend_merge.go index 5ba891daf..449d5f614 100644 --- a/pkg/integration/tests/interactive_rebase/amend_merge.go +++ b/pkg/integration/tests/interactive_rebase/amend_merge.go @@ -30,8 +30,7 @@ var AmendMerge = NewIntegrationTest(NewIntegrationTestArgs{ Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) { assert.CommitCount(3) - input.SwitchToCommitsWindow() - assert.CurrentView().Name("commits") + input.SwitchToCommitsView() mergeCommitMessage := "Merge branch 'feature-branch' into development-branch" assert.HeadCommitMessage(Contains(mergeCommitMessage)) diff --git a/pkg/integration/tests/interactive_rebase/one.go b/pkg/integration/tests/interactive_rebase/one.go index 0d6058e2f..3c4c07a4d 100644 --- a/pkg/integration/tests/interactive_rebase/one.go +++ b/pkg/integration/tests/interactive_rebase/one.go @@ -15,8 +15,8 @@ var One = NewIntegrationTest(NewIntegrationTestArgs{ CreateNCommits(5) // these will appears at commit 05, 04, 04, down to 01 }, Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) { - input.SwitchToCommitsWindow() - assert.CurrentView().Name("commits").Lines( + input.SwitchToCommitsView() + assert.CurrentView().Lines( Contains("commit 05"), Contains("commit 04"), Contains("commit 03"), diff --git a/pkg/integration/tests/stash/rename.go b/pkg/integration/tests/stash/rename.go index 1eb44605e..7088de423 100644 --- a/pkg/integration/tests/stash/rename.go +++ b/pkg/integration/tests/stash/rename.go @@ -19,9 +19,9 @@ var Rename = NewIntegrationTest(NewIntegrationTestArgs{ StashWithMessage("bar") }, Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) { - input.SwitchToStashWindow() + input.SwitchToStashView() - assert.CurrentView().Name("stash").Lines( + assert.CurrentView().Lines( Equals("On master: bar"), Equals("On master: foo"), )