1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-07-13 01:30:53 +02:00

Make integration test more robust

If you ran this test enough times it would eventually fail; this happened
whenever the resulting squashed commit had a sha that happened to start with
"02". We test that "commit 02" does not appear in the diff window, but in that
case it did, at the very top of the window.

A better fix might be to change the commit message that we use in CreateNCommits
to something other than "commit XY", but that would require touching tons of
tests, so this is the easier fix.
This commit is contained in:
Stefan Haller
2023-02-25 17:44:43 +01:00
parent f2aa7e7e28
commit 161bb684fa

View File

@ -12,17 +12,19 @@ var FixupSecondCommit = NewIntegrationTest(NewIntegrationTestArgs{
SetupConfig: func(config *config.AppConfig) {}, SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) { SetupRepo: func(shell *Shell) {
shell. shell.
CreateNCommits(3) CreateFileAndAdd("file1.txt", "File1 Content\n").Commit("First Commit").
CreateFileAndAdd("file2.txt", "Fixup Content\n").Commit("Fixup Commit Message").
CreateFileAndAdd("file3.txt", "File3 Content\n").Commit("Third Commit")
}, },
Run: func(t *TestDriver, keys config.KeybindingConfig) { Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Commits(). t.Views().Commits().
Focus(). Focus().
Lines( Lines(
Contains("commit 03"), Contains("Third Commit"),
Contains("commit 02"), Contains("Fixup Commit Message"),
Contains("commit 01"), Contains("First Commit"),
). ).
NavigateToLine(Contains("commit 02")). NavigateToLine(Contains("Fixup Commit Message")).
Press(keys.Commits.MarkCommitAsFixup). Press(keys.Commits.MarkCommitAsFixup).
Tap(func() { Tap(func() {
t.ExpectPopup().Confirmation(). t.ExpectPopup().Confirmation().
@ -31,14 +33,17 @@ var FixupSecondCommit = NewIntegrationTest(NewIntegrationTestArgs{
Confirm() Confirm()
}). }).
Lines( Lines(
Contains("commit 03"), Contains("Third Commit"),
Contains("commit 01").IsSelected(), Contains("First Commit").IsSelected(),
) )
t.Views().Main(). t.Views().Main().
Content(Contains("commit 01")). // Make sure that the resulting commit message doesn't contain the
Content(DoesNotContain("commit 02")). // message of the fixup commit; compare this to
Content(Contains("+file01 content")). // squash_down_second_commit.go, where it does.
Content(Contains("+file02 content")) Content(Contains("First Commit")).
Content(DoesNotContain("Fixup Commit Message")).
Content(Contains("+File1 Content")).
Content(Contains("+Fixup Content"))
}, },
}) })