mirror of
https://github.com/jesseduffield/lazygit.git
synced 2024-12-02 09:21:40 +02:00
rename SelectedLine to CurrentLine in tests
This commit is contained in:
parent
5d2584a188
commit
fa0414777f
@ -143,7 +143,7 @@ func (self *Assert) InListContext() {
|
||||
})
|
||||
}
|
||||
|
||||
func (self *Assert) SelectedLine(matcher *matcher) {
|
||||
func (self *Assert) CurrentLine(matcher *matcher) {
|
||||
self.matchString(matcher, "Unexpected selected line.",
|
||||
func() string {
|
||||
return self.gui.CurrentContext().GetView().SelectedLine()
|
||||
@ -151,7 +151,7 @@ func (self *Assert) SelectedLine(matcher *matcher) {
|
||||
)
|
||||
}
|
||||
|
||||
func (self *Assert) SelectedLineIdx(expected int) {
|
||||
func (self *Assert) CurrentLineIdx(expected int) {
|
||||
self.assertWithRetries(func() (bool, string) {
|
||||
actual := self.gui.CurrentContext().GetView().SelectedLineIdx()
|
||||
return expected == actual, fmt.Sprintf("Expected selected line index to be %d, got %d", expected, actual)
|
||||
|
@ -103,7 +103,7 @@ func (self *Input) PreviousItem() {
|
||||
|
||||
func (self *Input) ContinueMerge() {
|
||||
self.Press(self.keys.Universal.CreateRebaseOptionsMenu)
|
||||
self.assert.SelectedLine(Contains("continue"))
|
||||
self.assert.CurrentLine(Contains("continue"))
|
||||
self.Confirm()
|
||||
}
|
||||
|
||||
@ -166,20 +166,20 @@ func (self *Input) NavigateToListItem(matcher *matcher) {
|
||||
|
||||
selectedLineIdx := view.SelectedLineIdx()
|
||||
if selectedLineIdx == matchIndex {
|
||||
self.assert.SelectedLine(matcher)
|
||||
self.assert.CurrentLine(matcher)
|
||||
return
|
||||
}
|
||||
if selectedLineIdx < matchIndex {
|
||||
for i := selectedLineIdx; i < matchIndex; i++ {
|
||||
self.NextItem()
|
||||
}
|
||||
self.assert.SelectedLine(matcher)
|
||||
self.assert.CurrentLine(matcher)
|
||||
return
|
||||
} else {
|
||||
for i := selectedLineIdx; i > matchIndex; i-- {
|
||||
self.PreviousItem()
|
||||
}
|
||||
self.assert.SelectedLine(matcher)
|
||||
self.assert.CurrentLine(matcher)
|
||||
return
|
||||
}
|
||||
}
|
||||
@ -213,7 +213,7 @@ func (self *Input) Typeahead(title *matcher, textToType string, expectedFirstOpt
|
||||
self.Type(textToType)
|
||||
self.Press(self.keys.Universal.TogglePanel)
|
||||
self.assert.CurrentViewName("suggestions")
|
||||
self.assert.SelectedLine(expectedFirstOption)
|
||||
self.assert.CurrentLine(expectedFirstOption)
|
||||
self.Confirm()
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ var Basic = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
|
||||
input.SwitchToCommitsWindow()
|
||||
|
||||
assert.SelectedLine(Contains("commit 10"))
|
||||
assert.CurrentLine(Contains("commit 10"))
|
||||
|
||||
input.NavigateToListItem(Contains("commit 09"))
|
||||
|
||||
@ -43,7 +43,7 @@ var Basic = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
assert.ViewContent("information", Contains("bisecting"))
|
||||
|
||||
assert.CurrentViewName("commits")
|
||||
assert.SelectedLine(Contains("<-- bad"))
|
||||
assert.CurrentLine(Contains("<-- bad"))
|
||||
|
||||
input.NavigateToListItem(Contains("commit 02"))
|
||||
|
||||
@ -51,14 +51,14 @@ var Basic = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
|
||||
// lazygit will land us in the commit between our good and bad commits.
|
||||
assert.CurrentViewName("commits")
|
||||
assert.SelectedLine(Contains("commit 05"))
|
||||
assert.SelectedLine(Contains("<-- current"))
|
||||
assert.CurrentLine(Contains("commit 05"))
|
||||
assert.CurrentLine(Contains("<-- current"))
|
||||
|
||||
markCommitAsBad()
|
||||
|
||||
assert.CurrentViewName("commits")
|
||||
assert.SelectedLine(Contains("commit 04"))
|
||||
assert.SelectedLine(Contains("<-- current"))
|
||||
assert.CurrentLine(Contains("commit 04"))
|
||||
assert.CurrentLine(Contains("<-- current"))
|
||||
|
||||
markCommitAsGood()
|
||||
|
||||
|
@ -40,6 +40,6 @@ var CheckoutByName = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Contains("@"),
|
||||
)
|
||||
|
||||
assert.SelectedLine(Contains("new-branch"))
|
||||
assert.CurrentLine(Contains("new-branch"))
|
||||
},
|
||||
})
|
||||
|
@ -39,6 +39,6 @@ var Delete = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
MatchesRegexp(`\*.*branch-two`),
|
||||
MatchesRegexp(`master`),
|
||||
)
|
||||
assert.SelectedLineIdx(1)
|
||||
assert.CurrentLineIdx(1)
|
||||
},
|
||||
})
|
||||
|
@ -39,7 +39,7 @@ var Rebase = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
input.AcceptConfirmation(Equals("Auto-merge failed"), Contains("Conflicts!"))
|
||||
|
||||
assert.CurrentViewName("files")
|
||||
assert.SelectedLine(Contains("file"))
|
||||
assert.CurrentLine(Contains("file"))
|
||||
|
||||
// not using Confirm() convenience method because I suspect we might change this
|
||||
// keybinding to something more bespoke
|
||||
|
@ -46,7 +46,7 @@ var RebaseAndDrop = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
input.AcceptConfirmation(Equals("Auto-merge failed"), Contains("Conflicts!"))
|
||||
|
||||
assert.CurrentViewName("files")
|
||||
assert.SelectedLine(Contains("file"))
|
||||
assert.CurrentLine(Contains("file"))
|
||||
|
||||
input.SwitchToCommitsWindow()
|
||||
assert.ViewTopLines(
|
||||
@ -57,10 +57,10 @@ var RebaseAndDrop = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
MatchesRegexp("second change"),
|
||||
MatchesRegexp("original"),
|
||||
)
|
||||
assert.SelectedLineIdx(0)
|
||||
assert.CurrentLineIdx(0)
|
||||
input.NextItem()
|
||||
input.Press(keys.Universal.Remove)
|
||||
assert.SelectedLine(MatchesRegexp(`drop.*to remove`))
|
||||
assert.CurrentLine(MatchesRegexp(`drop.*to remove`))
|
||||
|
||||
input.SwitchToFilesWindow()
|
||||
|
||||
|
@ -55,7 +55,7 @@ var CherryPickConflicts = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
input.AcceptConfirmation(Equals("Auto-merge failed"), Contains("Conflicts!"))
|
||||
|
||||
assert.CurrentViewName("files")
|
||||
assert.SelectedLine(Contains("file"))
|
||||
assert.CurrentLine(Contains("file"))
|
||||
|
||||
// not using Confirm() convenience method because I suspect we might change this
|
||||
// keybinding to something more bespoke
|
||||
|
@ -19,7 +19,7 @@ var Staged = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
assert.CommitCount(0)
|
||||
|
||||
assert.CurrentViewName("files")
|
||||
assert.SelectedLine(Contains("myfile"))
|
||||
assert.CurrentLine(Contains("myfile"))
|
||||
// stage the file
|
||||
input.PrimaryAction()
|
||||
input.Enter()
|
||||
|
@ -20,7 +20,7 @@ var StagedWithoutHooks = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
|
||||
// stage the file
|
||||
assert.CurrentViewName("files")
|
||||
assert.SelectedLine(Contains("myfile"))
|
||||
assert.CurrentLine(Contains("myfile"))
|
||||
input.PrimaryAction()
|
||||
input.Enter()
|
||||
assert.CurrentViewName("stagingSecondary")
|
||||
|
@ -21,7 +21,7 @@ var Unstaged = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
assert.CommitCount(0)
|
||||
|
||||
assert.CurrentViewName("files")
|
||||
assert.SelectedLine(Contains("myfile"))
|
||||
assert.CurrentLine(Contains("myfile"))
|
||||
input.Enter()
|
||||
assert.CurrentViewName("staging")
|
||||
assert.ViewContent("stagingSecondary", NotContains("+myfile content"))
|
||||
|
@ -31,6 +31,6 @@ var Basic = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
|
||||
input.Press("a")
|
||||
assert.WorkingTreeFileCount(1)
|
||||
assert.SelectedLine(Contains("myfile"))
|
||||
assert.CurrentLine(Contains("myfile"))
|
||||
},
|
||||
})
|
||||
|
@ -72,7 +72,7 @@ var FormPrompts = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
input.AcceptConfirmation(Equals("Are you sure?"), Equals("Are you REALLY sure you want to make this file? Up to you buddy."))
|
||||
|
||||
assert.WorkingTreeFileCount(1)
|
||||
assert.SelectedLine(Contains("my file"))
|
||||
assert.CurrentLine(Contains("my file"))
|
||||
assert.MainViewContent(Contains(`"BAR"`))
|
||||
},
|
||||
})
|
||||
|
@ -60,7 +60,7 @@ var MenuFromCommand = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
input.SwitchToFilesWindow()
|
||||
|
||||
assert.WorkingTreeFileCount(1)
|
||||
assert.SelectedLine(Contains("output.txt"))
|
||||
assert.CurrentLine(Contains("output.txt"))
|
||||
assert.MainViewContent(Contains("bar Branch: #feature/foo my branch feature/foo"))
|
||||
},
|
||||
})
|
||||
|
@ -56,7 +56,7 @@ var MenuFromCommandsOutput = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
|
||||
assert.InPrompt()
|
||||
assert.CurrentViewTitle(Equals("Which git command do you want to run?"))
|
||||
assert.SelectedLine(Equals("branch"))
|
||||
assert.CurrentLine(Equals("branch"))
|
||||
input.Confirm()
|
||||
|
||||
input.Menu(Equals("Branch:"), Equals("master"))
|
||||
|
@ -70,7 +70,7 @@ var MultiplePrompts = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
input.AcceptConfirmation(Equals("Are you sure?"), Equals("Are you REALLY sure you want to make this file? Up to you buddy."))
|
||||
|
||||
assert.WorkingTreeFileCount(1)
|
||||
assert.SelectedLine(Contains("myfile"))
|
||||
assert.CurrentLine(Contains("myfile"))
|
||||
assert.MainViewContent(Contains("BAR"))
|
||||
},
|
||||
})
|
||||
|
@ -42,10 +42,10 @@ var Diff = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
input.Enter()
|
||||
assert.CurrentViewName("subCommits")
|
||||
assert.MainViewContent(Contains("+second line"))
|
||||
assert.SelectedLine(Contains("update"))
|
||||
assert.CurrentLine(Contains("update"))
|
||||
input.Enter()
|
||||
assert.CurrentViewName("commitFiles")
|
||||
assert.SelectedLine(Contains("file1"))
|
||||
assert.CurrentLine(Contains("file1"))
|
||||
assert.MainViewContent(Contains("+second line"))
|
||||
|
||||
input.Press(keys.Universal.Return)
|
||||
|
@ -43,10 +43,10 @@ var DiffAndApplyPatch = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
input.Enter()
|
||||
assert.CurrentViewName("subCommits")
|
||||
assert.MainViewContent(Contains("+second line"))
|
||||
assert.SelectedLine(Contains("update"))
|
||||
assert.CurrentLine(Contains("update"))
|
||||
input.Enter()
|
||||
assert.CurrentViewName("commitFiles")
|
||||
assert.SelectedLine(Contains("file1"))
|
||||
assert.CurrentLine(Contains("file1"))
|
||||
assert.MainViewContent(Contains("+second line"))
|
||||
|
||||
// add the file to the patch
|
||||
@ -63,7 +63,7 @@ var DiffAndApplyPatch = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
|
||||
input.SwitchToFilesWindow()
|
||||
|
||||
assert.SelectedLine(Contains("file1"))
|
||||
assert.CurrentLine(Contains("file1"))
|
||||
assert.MainViewContent(Contains("+second line"))
|
||||
},
|
||||
})
|
||||
|
@ -37,7 +37,7 @@ var DiffCommits = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
|
||||
input.NextItem()
|
||||
input.NextItem()
|
||||
assert.SelectedLine(Contains("first commit"))
|
||||
assert.CurrentLine(Contains("first commit"))
|
||||
|
||||
assert.MainViewContent(Contains("-second line\n-third line"))
|
||||
|
||||
@ -50,7 +50,7 @@ var DiffCommits = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
input.Enter()
|
||||
|
||||
assert.CurrentViewName("commitFiles")
|
||||
assert.SelectedLine(Contains("file1"))
|
||||
assert.CurrentLine(Contains("file1"))
|
||||
assert.MainViewContent(Contains("+second line\n+third line"))
|
||||
},
|
||||
})
|
||||
|
@ -82,7 +82,7 @@ var DiscardChanges = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
|
||||
discardOneByOne := func(files []statusFile) {
|
||||
for _, file := range files {
|
||||
assert.SelectedLine(Contains(file.status + " " + file.label))
|
||||
assert.CurrentLine(Contains(file.status + " " + file.label))
|
||||
input.Press(keys.Universal.Remove)
|
||||
input.Menu(Equals(file.menuTitle), Contains("discard all changes"))
|
||||
}
|
||||
|
@ -20,19 +20,19 @@ var One = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
|
||||
input.NavigateToListItem(Contains("commit 02"))
|
||||
input.Press(keys.Universal.Edit)
|
||||
assert.SelectedLine(Contains("YOU ARE HERE"))
|
||||
assert.CurrentLine(Contains("YOU ARE HERE"))
|
||||
|
||||
input.PreviousItem()
|
||||
input.Press(keys.Commits.MarkCommitAsFixup)
|
||||
assert.SelectedLine(Contains("fixup"))
|
||||
assert.CurrentLine(Contains("fixup"))
|
||||
|
||||
input.PreviousItem()
|
||||
input.Press(keys.Universal.Remove)
|
||||
assert.SelectedLine(Contains("drop"))
|
||||
assert.CurrentLine(Contains("drop"))
|
||||
|
||||
input.PreviousItem()
|
||||
input.Press(keys.Commits.SquashDown)
|
||||
assert.SelectedLine(Contains("squash"))
|
||||
assert.CurrentLine(Contains("squash"))
|
||||
|
||||
input.ContinueRebase()
|
||||
|
||||
|
@ -31,6 +31,6 @@ var Rename = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
|
||||
input.Prompt(Equals("Rename stash: stash@{1}"), " baz")
|
||||
|
||||
assert.SelectedLine(Equals("On master: foo baz"))
|
||||
assert.CurrentLine(Equals("On master: foo baz"))
|
||||
},
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user