summaryrefslogtreecommitdiffstats
path: root/pkg/integration/tests/submodule/remove.go
blob: f4f1cd04ffaeaf3f94eaafdb58a46b696a141bc8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package submodule

import (
	"github.com/jesseduffield/lazygit/pkg/config"
	. "github.com/jesseduffield/lazygit/pkg/integration/components"
)

var Remove = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Remove a submodule",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupConfig:  func(config *config.AppConfig) {},
	SetupRepo: func(shell *Shell) {
		shell.EmptyCommit("first commit")
		shell.CloneIntoSubmodule("my_submodule_name", "my_submodule_path")
		shell.GitAddAll()
		shell.Commit("add submodule")
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		gitDirSubmodulePath := ".git/modules/my_submodule_name"
		t.FileSystem().PathPresent(gitDirSubmodulePath)

		t.Views().Submodules().Focus().
			Lines(
				Contains("my_submodule_name").IsSelected(),
			).
			Press(keys.Universal.Remove).
			Tap(func() {
				t.ExpectPopup().Confirmation().
					Title(Equals("Remove submodule")).
					Content(Equals("Are you sure you want to remove submodule 'my_submodule_name' and its corresponding directory? This is irreversible.")).
					Confirm()
			}).
			IsEmpty()

		t.Views().Files().Focus().
			Lines(
				MatchesRegexp(`M.*\.gitmodules`).IsSelected(),
				MatchesRegexp(`D.*my_submodule_path`),
			)

		t.Views().Main().Content(
			Contains("-[submodule \"my_submodule_name\"]").
				Contains("-   path = my_submodule_path").
				Contains("-   url = ../other_repo"),
		)

		/* EXPECTED:
		t.FileSystem().PathNotPresent(gitDirSubmodulePath)
		ACTUAL: */
		t.FileSystem().PathPresent(gitDirSubmodulePath)
	},
})