File: auto_wrap_message.go

package info (click to toggle)
lazygit 0.57.0%2Bds1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,748 kB
  • sloc: sh: 153; makefile: 76
file content (59 lines) | stat: -rw-r--r-- 1,940 bytes parent folder | download | duplicates (2)
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
54
55
56
57
58
59
package commit

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

var AutoWrapMessage = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Commit, and test how the commit message body is auto-wrapped",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupConfig: func(config *config.AppConfig) {
		// Use a ridiculously small width so that we don't have to use so much test data
		config.GetUserConfig().Git.Commit.AutoWrapWidth = 20
	},
	SetupRepo: func(shell *Shell) {
		shell.CreateFile("file", "file content")
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().Commits().
			IsEmpty()

		t.Views().Files().
			IsFocused().
			PressPrimaryAction(). // stage file
			Press(keys.Files.CommitChanges)

		t.ExpectPopup().CommitMessagePanel().
			Type("subject").
			SwitchToDescription().
			Type("Lorem ipsum dolor sit amet, consectetur adipiscing elit.").
			// See how it automatically inserted line feeds to wrap the text:
			Content(Equals("Lorem ipsum dolor \nsit amet, \nconsectetur \nadipiscing elit.")).
			SwitchToSummary().
			Confirm()

		t.Views().Commits().
			Lines(
				Contains("subject"),
			).
			Focus().
			Tap(func() {
				t.Views().Main().Content(Contains(
					"subject\n    \n    Lorem ipsum dolor\n    sit amet,\n    consectetur\n    adipiscing elit."))
			}).
			Press(keys.Commits.RenameCommit)

		// Test that when rewording, the hard line breaks are turned back into
		// soft ones, so that we can insert text at the beginning and have the
		// paragraph reflow nicely.
		t.ExpectPopup().CommitMessagePanel().
			InitialText(Equals("subject")).
			SwitchToDescription().
			Content(Equals("Lorem ipsum dolor \nsit amet, \nconsectetur \nadipiscing elit.")).
			GoToBeginning().
			Type("More text. ").
			Content(Equals("More text. Lorem \nipsum dolor sit \namet, consectetur \nadipiscing elit."))
	},
})