1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-02-03 13:21:56 +02:00

Add integration tests for rebasing to the initial commit

This commit is contained in:
Stefan Haller 2023-02-19 11:33:58 +01:00
parent a349e886ce
commit 7351907474
5 changed files with 168 additions and 0 deletions

View File

@ -0,0 +1,38 @@
package interactive_rebase
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var EditFirstCommit = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Edits the first commit, just to show that it's possible",
ExtraCmdArgs: "",
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {
shell.
CreateNCommits(2)
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Commits().
Focus().
Lines(
Contains("commit 02"),
Contains("commit 01"),
).
NavigateToListItem(Contains("commit 01")).
Press(keys.Universal.Edit).
Lines(
Contains("commit 02"),
MatchesRegexp("YOU ARE HERE.*commit 01").IsSelected(),
).
Tap(func() {
t.Actions().ContinueRebase()
}).
Lines(
Contains("commit 02"),
Contains("commit 01"),
)
},
})

View File

@ -0,0 +1,44 @@
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.
CreateNCommits(3)
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Commits().
Focus().
Lines(
Contains("commit 03"),
Contains("commit 02"),
Contains("commit 01"),
).
NavigateToListItem(Contains("commit 02")).
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("commit 03"),
Contains("commit 01").IsSelected(),
)
t.Views().Main().
Content(Contains("commit 01")).
Content(DoesNotContain("commit 02")).
Content(Contains("+file01 content")).
Content(Contains("+file02 content"))
},
})

View File

@ -0,0 +1,39 @@
package interactive_rebase
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var RewordFirstCommit = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Rewords the first commit, just to show that it's possible",
ExtraCmdArgs: "",
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {
shell.
CreateNCommits(2)
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Commits().
Focus().
Lines(
Contains("commit 02"),
Contains("commit 01"),
).
NavigateToListItem(Contains("commit 01")).
Press(keys.Commits.RenameCommit).
Tap(func() {
t.ExpectPopup().Prompt().
Title(Equals("reword commit")).
InitialText(Equals("commit 01")).
Clear().
Type("renamed 01").
Confirm()
}).
Lines(
Contains("commit 02"),
Contains("renamed 01"),
)
},
})

View File

@ -0,0 +1,43 @@
package interactive_rebase
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var SquashDownSecondCommit = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Squash down the second commit into the first (initial)",
ExtraCmdArgs: "",
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {
shell.
CreateNCommits(3)
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Commits().
Focus().
Lines(
Contains("commit 03"),
Contains("commit 02"),
Contains("commit 01"),
).
NavigateToListItem(Contains("commit 02")).
Press(keys.Commits.SquashDown).
Tap(func() {
t.ExpectPopup().Confirmation().
Title(Equals("Squash")).
Content(Equals("Are you sure you want to squash this commit into the commit below?")).
Confirm()
}).
Lines(
Contains("commit 03"),
Contains("commit 01").IsSelected(),
)
t.Views().Main().
Content(Contains(" commit 01\n \n commit 02")).
Content(Contains("+file01 content")).
Content(Contains("+file02 content"))
},
})

View File

@ -66,9 +66,13 @@ var tests = []*components.IntegrationTest{
filter_by_path.SelectFile,
filter_by_path.TypeFile,
interactive_rebase.AmendMerge,
interactive_rebase.EditFirstCommit,
interactive_rebase.FixupFirstCommit,
interactive_rebase.FixupSecondCommit,
interactive_rebase.One,
interactive_rebase.RewordFirstCommit,
interactive_rebase.SquashDownFirstCommit,
interactive_rebase.SquashDownSecondCommit,
misc.ConfirmOnQuit,
misc.InitialOpen,
patch_building.CopyPatchToClipboard,