1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-01-10 04:07:18 +02:00
lazygit/pkg/integration/tests/interactive_rebase/fixup_second_commit.go
Stefan Haller 161bb684fa 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.
2023-02-27 08:53:06 +01:00

50 lines
1.6 KiB
Go

package interactive_rebase
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var FixupSecondCommit = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Fixup the second commit into the first (initial)",
ExtraCmdArgs: "",
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {
shell.
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("Third Commit"),
Contains("Fixup Commit Message"),
Contains("First Commit"),
).
NavigateToLine(Contains("Fixup Commit Message")).
Press(keys.Commits.MarkCommitAsFixup).
Tap(func() {
t.ExpectPopup().Confirmation().
Title(Equals("Fixup")).
Content(Equals("Are you sure you want to 'fixup' this commit? It will be merged into the commit below")).
Confirm()
}).
Lines(
Contains("Third Commit"),
Contains("First Commit").IsSelected(),
)
t.Views().Main().
// 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"))
},
})