1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-08-06 22:33:07 +02:00

cleaner test assertions

This commit is contained in:
Jesse Duffield
2022-12-26 11:12:56 +11:00
parent fa0414777f
commit 9a6f21ce42
34 changed files with 442 additions and 378 deletions

View File

@ -16,9 +16,7 @@ var CherryPickConflicts = NewIntegrationTest(NewIntegrationTestArgs{
},
Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
input.SwitchToBranchesWindow()
assert.CurrentViewName("localBranches")
assert.CurrentViewLines(
assert.CurrentView().Name("localBranches").Lines(
Contains("first-change-branch"),
Contains("second-change-branch"),
Contains("original-branch"),
@ -28,24 +26,21 @@ var CherryPickConflicts = NewIntegrationTest(NewIntegrationTestArgs{
input.Enter()
assert.CurrentViewName("subCommits")
assert.CurrentViewTopLines(
assert.CurrentView().Name("subCommits").TopLines(
Contains("second-change-branch unrelated change"),
Contains("second change"),
)
input.Press(keys.Commits.CherryPickCopy)
assert.ViewContent("information", Contains("1 commit copied"))
assert.View("information").Content(Contains("1 commit copied"))
input.NextItem()
input.Press(keys.Commits.CherryPickCopy)
assert.ViewContent("information", Contains("2 commits copied"))
assert.View("information").Content(Contains("2 commits copied"))
input.SwitchToCommitsWindow()
assert.CurrentViewName("commits")
assert.CurrentViewTopLines(
assert.CurrentView().Name("commits").TopLines(
Contains("first change"),
)
@ -54,27 +49,26 @@ var CherryPickConflicts = NewIntegrationTest(NewIntegrationTestArgs{
input.AcceptConfirmation(Equals("Auto-merge failed"), Contains("Conflicts!"))
assert.CurrentViewName("files")
assert.CurrentLine(Contains("file"))
assert.CurrentView().Name("files")
assert.CurrentView().SelectedLine(Contains("file"))
// not using Confirm() convenience method because I suspect we might change this
// keybinding to something more bespoke
input.Press(keys.Universal.Confirm)
assert.CurrentViewName("mergeConflicts")
assert.CurrentView().Name("mergeConflicts")
// picking 'Second change'
input.NextItem()
input.PrimaryAction()
input.AcceptConfirmation(Equals("continue"), Contains("all merge conflicts resolved. Continue?"))
assert.CurrentViewName("files")
assert.CurrentView().Name("files")
assert.WorkingTreeFileCount(0)
input.SwitchToCommitsWindow()
assert.CurrentViewName("commits")
assert.CurrentViewTopLines(
assert.CurrentView().Name("commits").TopLines(
Contains("second-change-branch unrelated change"),
Contains("second change"),
Contains("first change"),
@ -83,11 +77,12 @@ var CherryPickConflicts = NewIntegrationTest(NewIntegrationTestArgs{
// because we picked 'Second change' when resolving the conflict,
// we now see this commit as having replaced First Change with Second Change,
// as opposed to replacing 'Original' with 'Second change'
assert.MainViewContent(Contains("-First Change"))
assert.MainViewContent(Contains("+Second Change"))
assert.MainView().
Content(Contains("-First Change")).
Content(Contains("+Second Change"))
assert.ViewContent("information", Contains("2 commits copied"))
assert.View("information").Content(Contains("2 commits copied"))
input.Press(keys.Universal.Return)
assert.ViewContent("information", NotContains("commits copied"))
assert.View("information").Content(NotContains("commits copied"))
},
})