1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-02-03 13:21:56 +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) {},
SetupRepo: func(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) {
t.Views().Commits().
Focus().
Lines(
Contains("commit 03"),
Contains("commit 02"),
Contains("commit 01"),
Contains("Third Commit"),
Contains("Fixup Commit Message"),
Contains("First Commit"),
).
NavigateToLine(Contains("commit 02")).
NavigateToLine(Contains("Fixup Commit Message")).
Press(keys.Commits.MarkCommitAsFixup).
Tap(func() {
t.ExpectPopup().Confirmation().
@ -31,14 +33,17 @@ var FixupSecondCommit = NewIntegrationTest(NewIntegrationTestArgs{
Confirm()
}).
Lines(
Contains("commit 03"),
Contains("commit 01").IsSelected(),
Contains("Third Commit"),
Contains("First Commit").IsSelected(),
)
t.Views().Main().
Content(Contains("commit 01")).
Content(DoesNotContain("commit 02")).
Content(Contains("+file01 content")).
Content(Contains("+file02 content"))
// Make sure that the resulting commit message doesn't contain the
// message of the fixup commit; compare this to
// squash_down_second_commit.go, where it does.
Content(Contains("First Commit")).
Content(DoesNotContain("Fixup Commit Message")).
Content(Contains("+File1 Content")).
Content(Contains("+Fixup Content"))
},
})