summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2023-08-02 00:06:48 +1000
committerJesse Duffield <jessedduffield@gmail.com>2023-08-02 22:32:51 +1000
commitc43195efb6c7459ea24180ef464bc6e19942654f (patch)
tree74ffa27d2d95d80e8f7fe6fb46ce0cb669069444
parent17db918cba68f6973621231f6346ba68706e1773 (diff)
Add demo for amending old commit
-rw-r--r--pkg/integration/components/confirmation_driver.go6
-rw-r--r--pkg/integration/tests/demo/amend_old_commit.go62
-rw-r--r--pkg/integration/tests/test_list.go1
3 files changed, 69 insertions, 0 deletions
diff --git a/pkg/integration/components/confirmation_driver.go b/pkg/integration/components/confirmation_driver.go
index aad5cc248..7934b351c 100644
--- a/pkg/integration/components/confirmation_driver.go
+++ b/pkg/integration/components/confirmation_driver.go
@@ -40,6 +40,12 @@ func (self *ConfirmationDriver) Cancel() {
self.getViewDriver().PressEscape()
}
+func (self *ConfirmationDriver) Wait(milliseconds int) *ConfirmationDriver {
+ self.getViewDriver().Wait(milliseconds)
+
+ return self
+}
+
func (self *ConfirmationDriver) checkNecessaryChecksCompleted() {
if !self.hasCheckedContent || !self.hasCheckedTitle {
self.t.Fail("You must both check the content and title of a confirmation popup by calling Title()/Content() before calling Confirm()/Cancel().")
diff --git a/pkg/integration/tests/demo/amend_old_commit.go b/pkg/integration/tests/demo/amend_old_commit.go
new file mode 100644
index 000000000..b77a62bd1
--- /dev/null
+++ b/pkg/integration/tests/demo/amend_old_commit.go
@@ -0,0 +1,62 @@
+package demo
+
+import (
+ "github.com/jesseduffield/lazygit/pkg/config"
+ . "github.com/jesseduffield/lazygit/pkg/integration/components"
+)
+
+var AmendOldCommit = NewIntegrationTest(NewIntegrationTestArgs{
+ Description: "Amend old commit",
+ ExtraCmdArgs: []string{},
+ Skip: false,
+ IsDemo: true,
+ SetupConfig: func(config *config.AppConfig) {
+ // No idea why I had to use version 2: it should be using my own computer's
+ // font and the one iterm uses is version 3.
+ config.UserConfig.Gui.NerdFontsVersion = "2"
+ config.UserConfig.Gui.ShowFileTree = false
+ },
+ SetupRepo: func(shell *Shell) {
+ shell.CreateNCommitsWithRandomMessages(60)
+ shell.NewBranch("feature/demo")
+
+ shell.CloneIntoRemote("origin")
+
+ shell.SetBranchUpstream("feature/demo", "origin/feature/demo")
+
+ shell.UpdateFile("navigation/site_navigation.go", "package navigation\n\nfunc Navigate() {\n\tpanic(\"unimplemented\")\n}")
+ shell.CreateFile("docs/README.md", "my readme content")
+ },
+ Run: func(t *TestDriver, keys config.KeybindingConfig) {
+ t.SetCaptionPrefix("Amend an old commit")
+ t.Wait(1000)
+
+ t.Views().Files().
+ IsFocused().
+ SelectedLine(Contains("site_navigation.go")).
+ PressPrimaryAction()
+
+ t.Views().Commits().
+ Focus().
+ NavigateToLine(Contains("Improve accessibility of site navigation")).
+ Wait(500).
+ Press(keys.Commits.AmendToCommit).
+ Tap(func() {
+ t.ExpectPopup().Confirmation().
+ Title(Equals("Amend commit")).
+ Wait(1000).
+ Content(AnyString()).
+ Confirm()
+
+ t.Wait(1000)
+ }).
+ Press(keys.Universal.Push).
+ Tap(func() {
+ t.ExpectPopup().Confirmation().
+ Title(Equals("Force push")).
+ Content(AnyString()).
+ Wait(1000).
+ Confirm()
+ })
+ },
+})
diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go
index e59fd56e2..f5197f852 100644
--- a/pkg/integration/tests/test_list.go
+++ b/pkg/integration/tests/test_list.go
@@ -89,6 +89,7 @@ var tests = []*components.IntegrationTest{
custom_commands.OmitFromHistory,
custom_commands.SuggestionsCommand,
custom_commands.SuggestionsPreset,
+ demo.AmendOldCommit,
demo.Bisect,
demo.CherryPick,
demo.CommitAndPush,