1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-07-05 00:59:19 +02:00

add view asserter getter struct

This commit is contained in:
Jesse Duffield
2022-12-27 15:07:11 +11:00
parent b64f55518b
commit be30cbb375
35 changed files with 184 additions and 174 deletions

View File

@ -25,6 +25,6 @@ var CommitMultiline = NewIntegrationTest(NewIntegrationTestArgs{
assert.HeadCommitMessage(Equals("first line"))
input.SwitchToCommitsView()
assert.MainView().Content(MatchesRegexp("first line\n\\s*\n\\s*third line"))
assert.Views().Main().Content(MatchesRegexp("first line\n\\s*\n\\s*third line"))
},
})

View File

@ -20,7 +20,7 @@ var NewBranch = NewIntegrationTest(NewIntegrationTestArgs{
assert.CommitCount(3)
input.SwitchToCommitsView()
assert.CurrentView().Lines(
assert.Views().Current().Lines(
Contains("commit 3"),
Contains("commit 2"),
Contains("commit 1"),
@ -34,7 +34,7 @@ var NewBranch = NewIntegrationTest(NewIntegrationTestArgs{
assert.CurrentBranchName(branchName)
assert.View("commits").Lines(
assert.Views().ByName("commits").Lines(
Contains("commit 2"),
Contains("commit 1"),
)

View File

@ -20,7 +20,7 @@ var Revert = NewIntegrationTest(NewIntegrationTestArgs{
input.SwitchToCommitsView()
assert.CurrentView().Lines(
assert.Views().Current().Lines(
Contains("first commit"),
)
@ -30,13 +30,13 @@ var Revert = NewIntegrationTest(NewIntegrationTestArgs{
Content(MatchesRegexp(`Are you sure you want to revert \w+?`)).
Confirm()
assert.CurrentView().Name("commits").
assert.Views().Current().Name("commits").
Lines(
Contains("Revert \"first commit\"").IsSelected(),
Contains("first commit"),
)
assert.MainView().Content(Contains("-myfile content"))
assert.Views().Main().Content(Contains("-myfile content"))
assert.FileSystemPathNotPresent("myfile")
},
})

View File

@ -18,26 +18,26 @@ var Staged = NewIntegrationTest(NewIntegrationTestArgs{
Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
assert.CommitCount(0)
assert.CurrentView().Name("files")
assert.CurrentView().SelectedLine(Contains("myfile"))
assert.Views().Current().Name("files")
assert.Views().Current().SelectedLine(Contains("myfile"))
// stage the file
input.PrimaryAction()
input.Enter()
assert.CurrentView().Name("stagingSecondary")
assert.Views().Current().Name("stagingSecondary")
// we start with both lines having been staged
assert.View("stagingSecondary").Content(Contains("+myfile content"))
assert.View("stagingSecondary").Content(Contains("+with a second line"))
assert.View("staging").Content(DoesNotContain("+myfile content"))
assert.View("staging").Content(DoesNotContain("+with a second line"))
assert.Views().ByName("stagingSecondary").Content(Contains("+myfile content"))
assert.Views().ByName("stagingSecondary").Content(Contains("+with a second line"))
assert.Views().ByName("staging").Content(DoesNotContain("+myfile content"))
assert.Views().ByName("staging").Content(DoesNotContain("+with a second line"))
// unstage the selected line
input.PrimaryAction()
// the line should have been moved to the main view
assert.View("stagingSecondary").Content(DoesNotContain("+myfile content"))
assert.View("stagingSecondary").Content(Contains("+with a second line"))
assert.View("staging").Content(Contains("+myfile content"))
assert.View("staging").Content(DoesNotContain("+with a second line"))
assert.Views().ByName("stagingSecondary").Content(DoesNotContain("+myfile content"))
assert.Views().ByName("stagingSecondary").Content(Contains("+with a second line"))
assert.Views().ByName("staging").Content(Contains("+myfile content"))
assert.Views().ByName("staging").Content(DoesNotContain("+with a second line"))
input.Press(keys.Files.CommitChanges)
commitMessage := "my commit message"

View File

@ -19,16 +19,16 @@ var StagedWithoutHooks = NewIntegrationTest(NewIntegrationTestArgs{
assert.CommitCount(0)
// stage the file
assert.CurrentView().Name("files")
assert.CurrentView().SelectedLine(Contains("myfile"))
assert.Views().Current().Name("files")
assert.Views().Current().SelectedLine(Contains("myfile"))
input.PrimaryAction()
input.Enter()
assert.CurrentView().Name("stagingSecondary")
assert.Views().Current().Name("stagingSecondary")
// we start with both lines having been staged
assert.View("stagingSecondary").Content(
assert.Views().ByName("stagingSecondary").Content(
Contains("+myfile content").Contains("+with a second line"),
)
assert.View("staging").Content(
assert.Views().ByName("staging").Content(
DoesNotContain("+myfile content").DoesNotContain("+with a second line"),
)
@ -36,8 +36,8 @@ var StagedWithoutHooks = NewIntegrationTest(NewIntegrationTestArgs{
input.PrimaryAction()
// the line should have been moved to the main view
assert.View("stagingSecondary").Content(DoesNotContain("+myfile content").Contains("+with a second line"))
assert.View("staging").Content(Contains("+myfile content").DoesNotContain("+with a second line"))
assert.Views().ByName("stagingSecondary").Content(DoesNotContain("+myfile content").Contains("+with a second line"))
assert.Views().ByName("staging").Content(Contains("+myfile content").DoesNotContain("+with a second line"))
input.Press(keys.Files.CommitChangesWithoutHook)
@ -46,7 +46,7 @@ var StagedWithoutHooks = NewIntegrationTest(NewIntegrationTestArgs{
assert.CommitCount(1)
assert.HeadCommitMessage(Equals("WIP" + commitMessage))
assert.CurrentView().Name("stagingSecondary")
assert.Views().Current().Name("stagingSecondary")
// TODO: assert that the staging panel has been refreshed (it currently does not get correctly refreshed)
},

View File

@ -20,14 +20,14 @@ var Unstaged = NewIntegrationTest(NewIntegrationTestArgs{
Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
assert.CommitCount(0)
assert.CurrentView().Name("files").SelectedLine(Contains("myfile"))
assert.Views().Current().Name("files").SelectedLine(Contains("myfile"))
input.Enter()
assert.CurrentView().Name("staging")
assert.View("stagingSecondary").Content(DoesNotContain("+myfile content"))
assert.Views().Current().Name("staging")
assert.Views().ByName("stagingSecondary").Content(DoesNotContain("+myfile content"))
// stage the first line
input.PrimaryAction()
assert.View("staging").Content(DoesNotContain("+myfile content"))
assert.View("stagingSecondary").Content(Contains("+myfile content"))
assert.Views().ByName("staging").Content(DoesNotContain("+myfile content"))
assert.Views().ByName("stagingSecondary").Content(Contains("+myfile content"))
input.Press(keys.Files.CommitChanges)