summaryrefslogtreecommitdiffstats
path: root/pkg/integration/tests/commit
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/integration/tests/commit')
-rw-r--r--pkg/integration/tests/commit/add_co_author_range.go105
-rw-r--r--pkg/integration/tests/commit/reset_author_range.go52
-rw-r--r--pkg/integration/tests/commit/set_author_range.go57
3 files changed, 214 insertions, 0 deletions
diff --git a/pkg/integration/tests/commit/add_co_author_range.go b/pkg/integration/tests/commit/add_co_author_range.go
new file mode 100644
index 000000000..9452c1ded
--- /dev/null
+++ b/pkg/integration/tests/commit/add_co_author_range.go
@@ -0,0 +1,105 @@
+package commit
+
+import (
+ "github.com/jesseduffield/lazygit/pkg/config"
+ . "github.com/jesseduffield/lazygit/pkg/integration/components"
+)
+
+var AddCoAuthorRange = NewIntegrationTest(NewIntegrationTestArgs{
+ Description: "Add co-author on a range of commits",
+ ExtraCmdArgs: []string{},
+ Skip: false,
+ SetupConfig: func(config *config.AppConfig) {},
+ SetupRepo: func(shell *Shell) {
+ shell.EmptyCommit("fourth commit")
+ shell.EmptyCommit("third commit")
+ shell.EmptyCommit("second commit")
+ shell.EmptyCommit("first commit")
+ },
+ Run: func(t *TestDriver, keys config.KeybindingConfig) {
+ t.Views().Commits().
+ Focus().
+ Lines(
+ Contains("first commit").IsSelected(),
+ Contains("second commit"),
+ Contains("third commit"),
+ Contains("fourth commit"),
+ ).
+ SelectNextItem().
+ Press(keys.Universal.ToggleRangeSelect).
+ SelectNextItem().
+ Lines(
+ Contains("first commit"),
+ Contains("second commit").IsSelected(),
+ Contains("third commit").IsSelected(),
+ Contains("fourth commit"),
+ ).
+ Press(keys.Commits.ResetCommitAuthor).
+ Tap(func() {
+ t.ExpectPopup().Menu().
+ Title(Equals("Amend commit attribute")).
+ Select(Contains("Add co-author")).
+ Confirm()
+
+ t.ExpectPopup().Prompt().
+ Title(Contains("Add co-author")).
+ Type("John Smith <jsmith@gmail.com>").
+ Confirm()
+ }).
+ // exit range selection mode
+ PressEscape().
+ SelectNextItem()
+
+ t.Views().Main().Content(
+ Contains("fourth commit").
+ DoesNotContain("Co-authored-by: John Smith <jsmith@gmail.com>"),
+ )
+
+ t.Views().Commits().
+ IsFocused().
+ SelectPreviousItem().
+ Lines(
+ Contains("first commit"),
+ Contains("second commit"),
+ Contains("third commit").IsSelected(),
+ Contains("fourth commit"),
+ )
+
+ t.Views().Main().ContainsLines(
+ Equals(" third commit"),
+ Equals(" "),
+ Equals(" Co-authored-by: John Smith <jsmith@gmail.com>"),
+ )
+
+ t.Views().Commits().
+ IsFocused().
+ SelectPreviousItem().
+ Lines(
+ Contains("first commit"),
+ Contains("second commit").IsSelected(),
+ Contains("third commit"),
+ Contains("fourth commit"),
+ )
+
+ t.Views().Main().ContainsLines(
+ Equals(" second commit"),
+ Equals(" "),
+ Equals(" Co-authored-by: John Smith <jsmith@gmail.com>"),
+ )
+
+ t.Views().Commits().
+ IsFocused().
+ SelectPreviousItem().
+ Lines(
+ Contains("first commit").IsSelected(),
+ Contains("second commit"),
+ Contains("third commit"),
+ Contains("fourth commit"),
+ )
+
+ t.Views().Main().Content(
+ Contains("first commit").
+ DoesNotContain("Co-authored-by: John Smith <jsmith@gmail.com>"),
+ )
+ },
+})
diff --git a/pkg/integration/tests/commit/reset_author_range.go b/pkg/integration/tests/commit/reset_author_range.go
new file mode 100644
index 000000000..9d7c764cf
--- /dev/null
+++ b/pkg/integration/tests/commit/reset_author_range.go
@@ -0,0 +1,52 @@
+package commit
+
+import (
+ "github.com/jesseduffield/lazygit/pkg/config"
+ . "github.com/jesseduffield/lazygit/pkg/integration/components"
+)
+
+var ResetAuthorRange = NewIntegrationTest(NewIntegrationTestArgs{
+ Description: "Reset author on a range of commits",
+ ExtraCmdArgs: []string{},
+ 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("fourth")
+ shell.EmptyCommit("third")
+ shell.EmptyCommit("second")
+ shell.EmptyCommit("first")
+
+ 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("first").IsSelected(),
+ Contains("BS").Contains("second"),
+ Contains("BS").Contains("third"),
+ Contains("BS").Contains("fourth"),
+ ).
+ SelectNextItem().
+ Press(keys.Universal.ToggleRangeSelect).
+ SelectNextItem().
+ Press(keys.Commits.ResetCommitAuthor).
+ Tap(func() {
+ t.ExpectPopup().Menu().
+ Title(Equals("Amend commit attribute")).
+ Select(Contains("Reset author")).
+ Confirm()
+ }).
+ PressEscape().
+ Lines(
+ Contains("BS").Contains("first"),
+ Contains("JS").Contains("second"),
+ Contains("JS").Contains("third").IsSelected(),
+ Contains("BS").Contains("fourth"),
+ )
+ },
+})
diff --git a/pkg/integration/tests/commit/set_author_range.go b/pkg/integration/tests/commit/set_author_range.go
new file mode 100644
index 000000000..e366ba05e
--- /dev/null
+++ b/pkg/integration/tests/commit/set_author_range.go
@@ -0,0 +1,57 @@
+package commit
+
+import (
+ "github.com/jesseduffield/lazygit/pkg/config"
+ . "github.com/jesseduffield/lazygit/pkg/integration/components"
+)
+
+var SetAuthorRange = NewIntegrationTest(NewIntegrationTestArgs{
+ Description: "Set author on a range of commits",
+ ExtraCmdArgs: []string{},
+ 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("fourth")
+ shell.EmptyCommit("third")
+ shell.EmptyCommit("second")
+ shell.EmptyCommit("first")
+ },
+ Run: func(t *TestDriver, keys config.KeybindingConfig) {
+ t.Views().Commits().
+ Focus().
+ Lines(
+ Contains("BS").Contains("first").IsSelected(),
+ Contains("BS").Contains("second"),
+ Contains("BS").Contains("third"),
+ Contains("BS").Contains("fourth"),
+ )
+
+ t.Views().Commits().
+ Focus().
+ SelectNextItem().
+ Press(keys.Universal.ToggleRangeSelect).
+ SelectNextItem().
+ 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")).
+ Type("John Smith <John@example.com>").
+ Confirm()
+ }).
+ PressEscape().
+ Lines(
+ Contains("BS").Contains("first"),
+ Contains("JS").Contains("second"),
+ Contains("JS").Contains("third").IsSelected(),
+ Contains("BS").Contains("fourth"),
+ )
+ },
+})