mirror of
https://github.com/jesseduffield/lazygit.git
synced 2024-12-10 11:10:18 +02:00
add switch-to-view methods
This commit is contained in:
parent
9a6f21ce42
commit
c841ba8237
@ -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))
|
||||
|
@ -32,7 +32,7 @@ var Basic = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
|
||||
assert.AtLeastOneCommit()
|
||||
|
||||
input.SwitchToCommitsWindow()
|
||||
input.SwitchToCommitsView()
|
||||
|
||||
assert.CurrentView().SelectedLine(Contains("commit 10"))
|
||||
|
||||
|
@ -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`),
|
||||
|
@ -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("@"),
|
||||
)
|
||||
|
@ -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`),
|
||||
|
@ -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"),
|
||||
|
@ -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
|
||||
|
@ -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"),
|
||||
)
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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"),
|
||||
|
@ -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"),
|
||||
|
@ -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"))
|
||||
},
|
||||
})
|
||||
|
@ -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"),
|
||||
|
@ -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"),
|
||||
)
|
||||
|
||||
|
@ -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"))
|
||||
|
@ -50,7 +50,7 @@ var MenuFromCommandsOutput = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
assert.CurrentBranchName("feature/bar")
|
||||
|
||||
assert.WorkingTreeFileCount(0)
|
||||
input.SwitchToBranchesWindow()
|
||||
input.SwitchToBranchesView()
|
||||
|
||||
input.Press("a")
|
||||
|
||||
|
@ -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"),
|
||||
)
|
||||
|
@ -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"))
|
||||
|
@ -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"),
|
||||
|
@ -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))
|
||||
|
@ -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"),
|
||||
|
@ -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"),
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user