From 9a6f21ce429fedd949fdf9853c6ebf4892f858fd Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Mon, 26 Dec 2022 11:12:56 +1100 Subject: cleaner test assertions --- pkg/integration/tests/cherry_pick/cherry_pick.go | 20 +++++-------- .../tests/cherry_pick/cherry_pick_conflicts.go | 35 ++++++++++------------ 2 files changed, 23 insertions(+), 32 deletions(-) (limited to 'pkg/integration/tests/cherry_pick') diff --git a/pkg/integration/tests/cherry_pick/cherry_pick.go b/pkg/integration/tests/cherry_pick/cherry_pick.go index 6d11b9a7e..7ca89f402 100644 --- a/pkg/integration/tests/cherry_pick/cherry_pick.go +++ b/pkg/integration/tests/cherry_pick/cherry_pick.go @@ -25,9 +25,8 @@ var CherryPick = 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-branch"), Contains("second-branch"), Contains("master"), @@ -37,8 +36,7 @@ var CherryPick = NewIntegrationTest(NewIntegrationTestArgs{ input.Enter() - assert.CurrentViewName("subCommits") - assert.CurrentViewLines( + assert.CurrentView().Name("subCommits").Lines( Contains("four"), Contains("three"), Contains("base"), @@ -46,15 +44,14 @@ var CherryPick = NewIntegrationTest(NewIntegrationTestArgs{ // copy commits 'four' and 'three' 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.CurrentViewLines( + assert.CurrentView().Name("commits").Lines( Contains("two"), Contains("one"), Contains("base"), @@ -63,8 +60,7 @@ var CherryPick = NewIntegrationTest(NewIntegrationTestArgs{ input.Press(keys.Commits.PasteCommits) input.Alert(Equals("Cherry-Pick"), Contains("Are you sure you want to cherry-pick the copied commits onto this branch?")) - assert.CurrentViewName("commits") - assert.CurrentViewLines( + assert.CurrentView().Name("commits").Lines( Contains("four"), Contains("three"), Contains("two"), @@ -72,8 +68,8 @@ var CherryPick = NewIntegrationTest(NewIntegrationTestArgs{ Contains("base"), ) - 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")) }, }) diff --git a/pkg/integration/tests/cherry_pick/cherry_pick_conflicts.go b/pkg/integration/tests/cherry_pick/cherry_pick_conflicts.go index 4095a563f..3dfb995e2 100644 --- a/pkg/integration/tests/cherry_pick/cherry_pick_conflicts.go +++ b/pkg/integration/tests/cherry_pick/cherry_pick_conflicts.go @@ -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")) }, }) -- cgit v1.2.3