summaryrefslogtreecommitdiffstats
path: root/pkg/integration/tests
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2023-02-22 21:15:03 +1100
committerJesse Duffield <jessedduffield@gmail.com>2023-02-22 21:15:03 +1100
commit22c10479d528d3d9982f142139f82a8c764a550d (patch)
tree553e4fcec0da411783d114dfc363c9c59a5472f1 /pkg/integration/tests
parentf0572238cb577656edb18ea9688af3c243b7d25d (diff)
migrate reflog integration tests
Diffstat (limited to 'pkg/integration/tests')
-rw-r--r--pkg/integration/tests/cherry_pick/cherry_pick_conflicts.go5
-rw-r--r--pkg/integration/tests/reflog/checkout.go55
-rw-r--r--pkg/integration/tests/reflog/cherry_pick.go50
-rw-r--r--pkg/integration/tests/reflog/patch.go64
-rw-r--r--pkg/integration/tests/reflog/reset.go49
-rw-r--r--pkg/integration/tests/tests_gen.go5
6 files changed, 227 insertions, 1 deletions
diff --git a/pkg/integration/tests/cherry_pick/cherry_pick_conflicts.go b/pkg/integration/tests/cherry_pick/cherry_pick_conflicts.go
index df9988c2a..eaf9862d6 100644
--- a/pkg/integration/tests/cherry_pick/cherry_pick_conflicts.go
+++ b/pkg/integration/tests/cherry_pick/cherry_pick_conflicts.go
@@ -47,7 +47,10 @@ var CherryPickConflicts = NewIntegrationTest(NewIntegrationTestArgs{
).
Press(keys.Commits.PasteCommits)
- t.ExpectPopup().Alert().Title(Equals("Cherry-Pick")).Content(Contains("Are you sure you want to cherry-pick the copied commits onto this branch?")).Confirm()
+ t.ExpectPopup().Alert().
+ Title(Equals("Cherry-Pick")).
+ Content(Contains("Are you sure you want to cherry-pick the copied commits onto this branch?")).
+ Confirm()
t.ExpectPopup().Confirmation().
Title(Equals("Auto-merge failed")).
diff --git a/pkg/integration/tests/reflog/checkout.go b/pkg/integration/tests/reflog/checkout.go
new file mode 100644
index 000000000..9307ab609
--- /dev/null
+++ b/pkg/integration/tests/reflog/checkout.go
@@ -0,0 +1,55 @@
+package reflog
+
+import (
+ "github.com/jesseduffield/lazygit/pkg/config"
+ . "github.com/jesseduffield/lazygit/pkg/integration/components"
+)
+
+var Checkout = NewIntegrationTest(NewIntegrationTestArgs{
+ Description: "Checkout a reflog commit as a detached head",
+ ExtraCmdArgs: "",
+ Skip: false,
+ SetupConfig: func(config *config.AppConfig) {},
+ SetupRepo: func(shell *Shell) {
+ shell.EmptyCommit("one")
+ shell.EmptyCommit("two")
+ shell.EmptyCommit("three")
+ shell.HardReset("HEAD^^")
+ },
+ Run: func(t *TestDriver, keys config.KeybindingConfig) {
+ t.Views().ReflogCommits().
+ Focus().
+ Lines(
+ Contains("reset: moving to HEAD^^").IsSelected(),
+ Contains("commit: three"),
+ Contains("commit: two"),
+ Contains("commit (initial): one"),
+ ).
+ SelectNextItem().
+ PressPrimaryAction().
+ Tap(func() {
+ t.ExpectPopup().Confirmation().
+ Title(Contains("checkout commit")).
+ Content(Contains("Are you sure you want to checkout this commit?")).
+ Confirm()
+ }).
+ TopLines(
+ Contains("checkout: moving from master to").IsSelected(),
+ Contains("reset: moving to HEAD^^"),
+ )
+
+ t.Views().Branches().
+ Lines(
+ Contains("(HEAD detached at").IsSelected(),
+ Contains("master"),
+ )
+
+ t.Views().Commits().
+ Focus().
+ Lines(
+ Contains("three").IsSelected(),
+ Contains("two"),
+ Contains("one"),
+ )
+ },
+})
diff --git a/pkg/integration/tests/reflog/cherry_pick.go b/pkg/integration/tests/reflog/cherry_pick.go
new file mode 100644
index 000000000..cc7f503e2
--- /dev/null
+++ b/pkg/integration/tests/reflog/cherry_pick.go
@@ -0,0 +1,50 @@
+package reflog
+
+import (
+ "github.com/jesseduffield/lazygit/pkg/config"
+ . "github.com/jesseduffield/lazygit/pkg/integration/components"
+)
+
+var CherryPick = NewIntegrationTest(NewIntegrationTestArgs{
+ Description: "Cherry pick a reflog commit",
+ ExtraCmdArgs: "",
+ Skip: false,
+ SetupConfig: func(config *config.AppConfig) {},
+ SetupRepo: func(shell *Shell) {
+ shell.EmptyCommit("one")
+ shell.EmptyCommit("two")
+ shell.EmptyCommit("three")
+ shell.HardReset("HEAD^^")
+ },
+ Run: func(t *TestDriver, keys config.KeybindingConfig) {
+ t.Views().ReflogCommits().
+ Focus().
+ Lines(
+ Contains("reset: moving to HEAD^^").IsSelected(),
+ Contains("commit: three"),
+ Contains("commit: two"),
+ Contains("commit (initial): one"),
+ ).
+ SelectNextItem().
+ Press(keys.Commits.CherryPickCopy)
+
+ t.Views().Information().Content(Contains("1 commit copied"))
+
+ t.Views().Commits().
+ Focus().
+ Lines(
+ Contains("one").IsSelected(),
+ ).
+ Press(keys.Commits.PasteCommits).
+ Tap(func() {
+ t.ExpectPopup().Alert().
+ Title(Equals("Cherry-Pick")).
+ Content(Contains("Are you sure you want to cherry-pick the copied commits onto this branch?")).
+ Confirm()
+ }).
+ Lines(
+ Contains("three").IsSelected(),
+ Contains("one"),
+ )
+ },
+})
diff --git a/pkg/integration/tests/reflog/patch.go b/pkg/integration/tests/reflog/patch.go
new file mode 100644
index 000000000..568f36c43
--- /dev/null
+++ b/pkg/integration/tests/reflog/patch.go
@@ -0,0 +1,64 @@
+package reflog
+
+import (
+ "github.com/jesseduffield/lazygit/pkg/config"
+ . "github.com/jesseduffield/lazygit/pkg/integration/components"
+)
+
+var Patch = NewIntegrationTest(NewIntegrationTestArgs{
+ Description: "Build a patch from a reflog commit and apply it",
+ ExtraCmdArgs: "",
+ Skip: false,
+ SetupConfig: func(config *config.AppConfig) {},
+ SetupRepo: func(shell *Shell) {
+ shell.EmptyCommit("one")
+ shell.EmptyCommit("two")
+ shell.CreateFileAndAdd("file1", "content1")
+ shell.CreateFileAndAdd("file2", "content2")
+ shell.Commit("three")
+ shell.HardReset("HEAD^^")
+ },
+ Run: func(t *TestDriver, keys config.KeybindingConfig) {
+ t.Views().ReflogCommits().
+ Focus().
+ Lines(
+ Contains("reset: moving to HEAD^^").IsSelected(),
+ Contains("commit: three"),
+ Contains("commit: two"),
+ Contains("commit (initial): one"),
+ ).
+ SelectNextItem().
+ PressEnter()
+
+ t.Views().SubCommits().
+ IsFocused().
+ Lines(
+ Contains("three").IsSelected(),
+ Contains("two"),
+ Contains("one"),
+ ).
+ PressEnter()
+
+ t.Views().CommitFiles().
+ IsFocused().
+ Lines(
+ Contains("file1").IsSelected(),
+ Contains("file2"),
+ ).
+ PressPrimaryAction()
+
+ t.Views().Information().Content(Contains("building patch"))
+
+ t.Views().
+ CommitFiles().
+ Press(keys.Universal.CreatePatchOptionsMenu)
+
+ t.ExpectPopup().Menu().
+ Title(Equals("Patch Options")).
+ Select(MatchesRegexp(`apply patch$`)).Confirm()
+
+ t.Views().Files().Lines(
+ Contains("file1"),
+ )
+ },
+})
diff --git a/pkg/integration/tests/reflog/reset.go b/pkg/integration/tests/reflog/reset.go
new file mode 100644
index 000000000..80c11cbb7
--- /dev/null
+++ b/pkg/integration/tests/reflog/reset.go
@@ -0,0 +1,49 @@
+package reflog
+
+import (
+ "github.com/jesseduffield/lazygit/pkg/config"
+ . "github.com/jesseduffield/lazygit/pkg/integration/components"
+)
+
+var Reset = NewIntegrationTest(NewIntegrationTestArgs{
+ Description: "Hard reset to a reflog commit",
+ ExtraCmdArgs: "",
+ Skip: false,
+ SetupConfig: func(config *config.AppConfig) {},
+ SetupRepo: func(shell *Shell) {
+ shell.EmptyCommit("one")
+ shell.EmptyCommit("two")
+ shell.EmptyCommit("three")
+ shell.HardReset("HEAD^^")
+ },
+ Run: func(t *TestDriver, keys config.KeybindingConfig) {
+ t.Views().ReflogCommits().
+ Focus().
+ Lines(
+ Contains("reset: moving to HEAD^^").IsSelected(),
+ Contains("commit: three"),
+ Contains("commit: two"),
+ Contains("commit (initial): one"),
+ ).
+ SelectNextItem().
+ Press(keys.Commits.ViewResetOptions).
+ Tap(func() {
+ t.ExpectPopup().Menu().
+ Title(Contains("reset to")).
+ Select(Contains("hard reset")).
+ Confirm()
+ }).
+ TopLines(
+ Contains("reset: moving to").IsSelected(),
+ Contains("reset: moving to HEAD^^"),
+ )
+
+ t.Views().Commits().
+ Focus().
+ Lines(
+ Contains("three").IsSelected(),
+ Contains("two"),
+ Contains("one"),
+ )
+ },
+})
diff --git a/pkg/integration/tests/tests_gen.go b/pkg/integration/tests/tests_gen.go
index 6a7e36373..a7cade4d4 100644
--- a/pkg/integration/tests/tests_gen.go
+++ b/pkg/integration/tests/tests_gen.go
@@ -17,6 +17,7 @@ import (
"github.com/jesseduffield/lazygit/pkg/integration/tests/interactive_rebase"
"github.com/jesseduffield/lazygit/pkg/integration/tests/misc"
"github.com/jesseduffield/lazygit/pkg/integration/tests/patch_building"
+ "github.com/jesseduffield/lazygit/pkg/integration/tests/reflog"
"github.com/jesseduffield/lazygit/pkg/integration/tests/stash"
"github.com/jesseduffield/lazygit/pkg/integration/tests/submodule"
"github.com/jesseduffield/lazygit/pkg/integration/tests/sync"
@@ -87,6 +88,10 @@ var tests = []*components.IntegrationTest{
misc.ConfirmOnQuit,
misc.InitialOpen,
patch_building.CopyPatchToClipboard,
+ reflog.Checkout,
+ reflog.CherryPick,
+ reflog.Patch,
+ reflog.Reset,
stash.Apply,
stash.ApplyPatch,
stash.CreateBranch,