diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2023-02-12 17:40:53 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2023-02-12 18:12:01 +1100 |
commit | d7956c481d51fbb6820e0e4419c87427bbfd12bb (patch) | |
tree | 643853673128590ba9a91cb9f2c286658b261153 /pkg/integration/tests/submodule/enter.go | |
parent | 7a3291a1f78977cff6372f81e044675e88b25d46 (diff) |
migrate submodule enter test
Diffstat (limited to 'pkg/integration/tests/submodule/enter.go')
-rw-r--r-- | pkg/integration/tests/submodule/enter.go | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/pkg/integration/tests/submodule/enter.go b/pkg/integration/tests/submodule/enter.go new file mode 100644 index 000000000..c97e55a46 --- /dev/null +++ b/pkg/integration/tests/submodule/enter.go @@ -0,0 +1,69 @@ +package submodule + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var Enter = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Enter a submodule, add a commit, and then stage the change in the parent repo", + ExtraCmdArgs: "", + Skip: false, + SetupConfig: func(cfg *config.AppConfig) { + cfg.UserConfig.CustomCommands = []config.CustomCommand{ + { + Key: "e", + Context: "files", + Command: "git commit --allow-empty -m \"empty commit\"", + }, + } + }, + SetupRepo: func(shell *Shell) { + shell.EmptyCommit("first commit") + shell.RunCommand("git clone --bare . ../other_repo") + shell.RunCommand("git submodule add ../other_repo my_submodule") + shell.GitAddAll() + shell.Commit("add submodule") + }, + Run: func(t *TestDriver, keys config.KeybindingConfig) { + t.Views().Submodules().Focus(). + Lines( + Contains("my_submodule").IsSelected(), + ). + // enter the submodule + PressEnter() + + t.Views().Files().IsFocused(). + Press("e"). + Tap(func() { + t.Views().Commits().Content(Contains("empty commit")) + }). + // return to the parent repo + PressEscape() + + t.Views().Submodules().IsFocused() + + // we see the new commit in the submodule is ready to be staged in the parent repo + t.Views().Main().Content(Contains("> empty commit")) + + t.Views().Files().Focus(). + Lines( + MatchesRegexp(` M.*my_submodule \(submodule\)`).IsSelected(), + ). + Tap(func() { + // main view also shows the new commit when we're looking at the submodule within the files view + t.Views().Main().Content(Contains("> empty commit")) + }). + PressPrimaryAction(). + Press(keys.Files.CommitChanges). + Tap(func() { + t.ExpectPopup().CommitMessagePanel().Type("submodule change").Confirm() + }). + IsEmpty() + + t.Views().Submodules().Focus() + + // we no longer report a new commit because we've committed it in the parent repo + t.Views().Main().Content(DoesNotContain("> empty commit")) + }, +}) |