summaryrefslogtreecommitdiffstats
path: root/pkg/integration/tests
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2023-02-22 21:57:32 +1100
committerJesse Duffield <jessedduffield@gmail.com>2023-02-22 21:57:32 +1100
commiteabe7f462a1f950d05b66306c19a00855e3fa175 (patch)
tree2d500a74e016ee3a3cb5ab5e998914f7ba15f571 /pkg/integration/tests
parent22c10479d528d3d9982f142139f82a8c764a550d (diff)
migrate more tests
Diffstat (limited to 'pkg/integration/tests')
-rw-r--r--pkg/integration/tests/branch/reset_upstream.go36
-rw-r--r--pkg/integration/tests/branch/set_upstream.go40
-rw-r--r--pkg/integration/tests/commit/reset_author.go39
-rw-r--r--pkg/integration/tests/commit/search.go107
-rw-r--r--pkg/integration/tests/commit/set_author.go51
-rw-r--r--pkg/integration/tests/staging/search.go42
-rw-r--r--pkg/integration/tests/tests_gen.go7
7 files changed, 322 insertions, 0 deletions
diff --git a/pkg/integration/tests/branch/reset_upstream.go b/pkg/integration/tests/branch/reset_upstream.go
new file mode 100644
index 000000000..126d2abf9
--- /dev/null
+++ b/pkg/integration/tests/branch/reset_upstream.go
@@ -0,0 +1,36 @@
+package branch
+
+import (
+ "github.com/jesseduffield/lazygit/pkg/config"
+ . "github.com/jesseduffield/lazygit/pkg/integration/components"
+)
+
+var ResetUpstream = NewIntegrationTest(NewIntegrationTestArgs{
+ Description: "Reset the upstream of a branch",
+ ExtraCmdArgs: "",
+ Skip: false,
+ SetupConfig: func(config *config.AppConfig) {},
+ SetupRepo: func(shell *Shell) {
+ shell.EmptyCommit("one")
+ shell.CloneIntoRemote("origin")
+ shell.SetBranchUpstream("master", "origin/master")
+ },
+ Run: func(t *TestDriver, keys config.KeybindingConfig) {
+ t.Views().Branches().
+ Focus().
+ Press(keys.Universal.NextScreenMode). // we need to enlargen the window to see the upstream
+ Lines(
+ Contains("master").Contains("origin master").IsSelected(),
+ ).
+ Press(keys.Branches.SetUpstream).
+ Tap(func() {
+ t.ExpectPopup().Menu().
+ Title(Equals("Set/unset upstream")).
+ Select(Contains("unset upstream of selected branch")).
+ Confirm()
+ }).
+ Lines(
+ Contains("master").DoesNotContain("origin master").IsSelected(),
+ )
+ },
+})
diff --git a/pkg/integration/tests/branch/set_upstream.go b/pkg/integration/tests/branch/set_upstream.go
new file mode 100644
index 000000000..3388a6086
--- /dev/null
+++ b/pkg/integration/tests/branch/set_upstream.go
@@ -0,0 +1,40 @@
+package branch
+
+import (
+ "github.com/jesseduffield/lazygit/pkg/config"
+ . "github.com/jesseduffield/lazygit/pkg/integration/components"
+)
+
+var SetUpstream = NewIntegrationTest(NewIntegrationTestArgs{
+ Description: "Set the upstream of a branch",
+ ExtraCmdArgs: "",
+ Skip: false,
+ SetupConfig: func(config *config.AppConfig) {},
+ SetupRepo: func(shell *Shell) {
+ shell.EmptyCommit("one")
+ shell.CloneIntoRemote("origin")
+ },
+ Run: func(t *TestDriver, keys config.KeybindingConfig) {
+ t.Views().Branches().
+ Focus().
+ Press(keys.Universal.NextScreenMode). // we need to enlargen the window to see the upstream
+ Lines(
+ Contains("master").DoesNotContain("origin master").IsSelected(),
+ ).
+ Press(keys.Branches.SetUpstream).
+ Tap(func() {
+ t.ExpectPopup().Menu().
+ Title(Equals("Set/unset upstream")).
+ Select(Contains(" set upstream of selected branch")). // using leading space to disambiguate from the 'reset' option
+ Confirm()
+
+ t.ExpectPopup().Prompt().
+ Title(Equals("Enter upstream as '<remote> <branchname>'")).
+ SuggestionLines(Equals("origin master")).
+ ConfirmFirstSuggestion()
+ }).
+ Lines(
+ Contains("master").Contains("origin master").IsSelected(),
+ )
+ },
+})
diff --git a/pkg/integration/tests/commit/reset_author.go b/pkg/integration/tests/commit/reset_author.go
new file mode 100644
index 000000000..f54b5b5aa
--- /dev/null
+++ b/pkg/integration/tests/commit/reset_author.go
@@ -0,0 +1,39 @@
+package commit
+
+import (
+ "github.com/jesseduffield/lazygit/pkg/config"
+ . "github.com/jesseduffield/lazygit/pkg/integration/components"
+)
+
+var ResetAuthor = NewIntegrationTest(NewIntegrationTestArgs{
+ Description: "Reset author on a commit",
+ ExtraCmdArgs: "",
+ Skip: false,
+ SetupConfig: func(config *config.AppConfig) {},
+ SetupRepo: func(shell *Shell) {
+ shell.SetConfig("user.email", "Bill@example.com")
+ shell.SetConfig("user.name", "Bill Smith")
+
+ shell.EmptyCommit("one")
+
+ shell.SetConfig("user.email", "John@example.com")
+ shell.SetConfig("user.name", "John Smith")
+ },
+ Run: func(t *TestDriver, keys config.KeybindingConfig) {
+ t.Views().Commits().
+ Focus().
+ Lines(
+ Contains("BS").Contains("one").IsSelected(),
+ ).
+ Press(keys.Commits.ResetCommitAuthor).
+ Tap(func() {
+ t.ExpectPopup().Menu().
+ Title(Equals("Amend commit attribute")).
+ Select(Contains("reset author")).
+ Confirm()
+ }).
+ Lines(
+ Contains("JS").Contains("one").IsSelected(),
+ )
+ },
+})
diff --git a/pkg/integration/tests/commit/search.go b/pkg/integration/tests/commit/search.go
new file mode 100644
index 000000000..7159b11d1
--- /dev/null
+++ b/pkg/integration/tests/commit/search.go
@@ -0,0 +1,107 @@
+package commit
+
+import (
+ "github.com/jesseduffield/lazygit/pkg/config"
+ . "github.com/jesseduffield/lazygit/pkg/integration/components"
+)
+
+var Search = NewIntegrationTest(NewIntegrationTestArgs{
+ Description: "Search for a commit",
+ ExtraCmdArgs: "",
+ Skip: false,
+ SetupConfig: func(config *config.AppConfig) {},
+ SetupRepo: func(shell *Shell) {
+ shell.EmptyCommit("one")
+ shell.EmptyCommit("two")
+ shell.EmptyCommit("three")
+ shell.EmptyCommit("four")
+ },
+ Run: func(t *TestDriver, keys config.KeybindingConfig) {
+ t.Views().Commits().
+ Focus().
+ Lines(
+ Contains("four").IsSelected(),
+ Contains("three"),
+ Contains("two"),
+ Contains("one"),
+ ).
+ Press(keys.Universal.StartSearch).
+ Tap(func() {
+ t.ExpectSearch().
+ Type("two").
+ Confirm()
+
+ t.Views().Search().Content(Contains("matches for 'two' (1 of 1)"))
+ }).
+ Lines(
+ Contains("four"),
+ Contains("three"),
+ Contains("two").IsSelected(),
+ Contains("one"),
+ ).
+ Press(keys.Universal.StartSearch).
+ Tap(func() {
+ t.ExpectSearch().
+ Type("o").
+ Confirm()
+
+ t.Views().Search().Content(Contains("matches for 'o' (2 of 3)"))
+ }).
+ Lines(
+ Contains("four"),
+ Contains("three"),
+ Contains("two").IsSelected(),
+ Contains("one"),
+ ).
+ Press("n").
+ Tap(func() {
+ t.Views().Search().Content(Contains("matches for 'o' (3 of 3)"))
+ }).
+ Lines(
+ Contains("four"),
+ Contains("three"),
+ Contains("two"),
+ Contains("one").IsSelected(),
+ ).
+ Press("n").
+ Tap(func() {
+ t.Views().Search().Content(Contains("matches for 'o' (1 of 3)"))
+ }).
+ Lines(
+ Contains("four").IsSelected(),
+ Contains("three"),
+ Contains("two"),
+ Contains("one"),
+ ).
+ Press("n").
+ Tap(func() {
+ t.Views().Search().Content(Contains("matches for 'o' (2 of 3)"))
+ }).
+ Lines(
+ Contains("four"),
+ Contains("three"),
+ Contains("two").IsSelected(),
+ Contains("one"),
+ ).
+ Press("N").
+ Tap(func() {
+ t.Views().Search().Content(Contains("matches for 'o' (1 of 3)"))
+ }).
+ Lines(
+ Contains("four").IsSelected(),
+ Contains("three"),
+ Contains("two"),
+ Contains("one"),
+ ).
+ Press("N").
+ Tap(func() {
+ t.Views().Search().Content(Contains("matches for 'o' (3 of 3)"))
+ }).
+ Lines(
+ Contains("four"),
+ Contains("three"),
+ Contains("two"),
+ Contains("one").IsSelected(),
+ )
+ },
+})
diff --git a/pkg/integration/tests/commit/set_author.go b/pkg/integration/tests/commit/set_author.go
new file mode 100644
index 000000000..047ac167c
--- /dev/null
+++ b/pkg/integration/tests/commit/set_author.go
@@ -0,0 +1,51 @@
+package commit
+
+import (
+ "github.com/jesseduffield/lazygit/pkg/config"
+ . "github.com/jesseduffield/lazygit/pkg/integration/components"
+)
+
+var SetAuthor = NewIntegrationTest(NewIntegrationTestArgs{
+ Description: "Set author on a commit",
+ ExtraCmdArgs: "",
+ Skip: false,
+ SetupConfig: func(config *config.AppConfig) {},
+ SetupRepo: func(shell *Shell) {
+ shell.SetConfig("user.email", "Bill@example.com")
+ shell.SetConfig("user.name", "Bill Smith")
+
+ shell.EmptyCommit("one")
+
+ shell.SetConfig("user.email", "John@example.com")
+ shell.SetConfig("user.name", "John Smith")
+
+ shell.EmptyCommit("two")
+ },
+ Run: func(t *TestDriver, keys config.KeybindingConfig) {
+ t.Views().Commits().
+ Focus().
+ Lines(
+ Contains("JS").Contains("two").IsSelected(),
+ Contains("BS").Contains("one"),
+ ).
+ Press(keys.Commits.ResetCommitAuthor).
+ Tap(func() {
+ t.ExpectPopup().Menu().
+ Title(Equals("Amend commit attribute")).
+ Select(Contains(" set author")). // adding space at start to distinguish from 'reset author'
+ Confirm()
+
+ t.ExpectPopup().Prompt().
+ Title(Contains("Set author")).
+ SuggestionLines(
+ Contains("John Smith"),
+ Contains("Bill Smith"),
+ ).
+ ConfirmSuggestion(Contains("John Smith"))
+ }).
+ Lines(
+ Contains("JS").Contains("two").IsSelected(),
+ Contains("BS").Contains("one"),
+ )
+ },
+})
diff --git a/pkg/integration/tests/staging/search.go b/pkg/integration/tests/staging/search.go
new file mode 100644
index 000000000..b7a42a276
--- /dev/null
+++ b/pkg/integration/tests/staging/search.go
@@ -0,0 +1,42 @@
+package staging
+
+import (
+ "github.com/jesseduffield/lazygit/pkg/config"
+ . "github.com/jesseduffield/lazygit/pkg/integration/components"
+)
+
+var Search = NewIntegrationTest(NewIntegrationTestArgs{
+ Description: "Use the search feature in the staging panel",
+ ExtraCmdArgs: "",
+ Skip: false,
+ SetupConfig: func(config *config.AppConfig) {},
+ SetupRepo: func(shell *Shell) {
+ shell.CreateFile("file1", "one\ntwo\nthree\nfour\nfive")
+ },
+ Run: func(t *TestDriver, keys config.KeybindingConfig) {
+ t.Views().Files().
+ IsFocused().
+ Lines(
+ Contains("file1").IsSelected(),
+ ).
+ PressEnter()
+
+ t.Views().Staging().
+ IsFocused().
+ Press(keys.Universal.StartSearch).
+ Tap(func() {
+ t.ExpectSearch().
+ Type("four").
+ Confirm()
+
+ t.Views().Search().Content(Contains("matches for 'four' (1 of 1)"))
+ }).
+ SelectedLine(Contains("+four")). // stage the line
+ PressPrimaryAction().
+ Content(DoesNotContain("+four")).
+ Tap(func() {
+ t.Views().StagingSecondary().
+ Content(Contains("+four"))
+ })
+ },
+})
diff --git a/pkg/integration/tests/tests_gen.go b/pkg/integration/tests/tests_gen.go
index a7cade4d4..635451b54 100644
--- a/pkg/integration/tests/tests_gen.go
+++ b/pkg/integration/tests/tests_gen.go
@@ -18,6 +18,7 @@ import (
"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/staging"
"github.com/jesseduffield/lazygit/pkg/integration/tests/stash"
"github.com/jesseduffield/lazygit/pkg/integration/tests/submodule"
"github.com/jesseduffield/lazygit/pkg/integration/tests/sync"
@@ -38,6 +39,8 @@ var tests = []*components.IntegrationTest{
branch.RebaseAndDrop,
branch.RebaseDoesNotAutosquash,
branch.Reset,
+ branch.ResetUpstream,
+ branch.SetUpstream,
branch.Suggestions,
cherry_pick.CherryPick,
cherry_pick.CherryPickConflicts,
@@ -46,8 +49,11 @@ var tests = []*components.IntegrationTest{
commit.CreateTag,
commit.DiscardOldFileChange,
commit.NewBranch,
+ commit.ResetAuthor,
commit.Revert,
commit.RevertMerge,
+ commit.Search,
+ commit.SetAuthor,
commit.StageRangeOfLines,
commit.Staged,
commit.StagedWithoutHooks,
@@ -92,6 +98,7 @@ var tests = []*components.IntegrationTest{
reflog.CherryPick,
reflog.Patch,
reflog.Reset,
+ staging.Search,
stash.Apply,
stash.ApplyPatch,
stash.CreateBranch,