File tree Expand file tree Collapse file tree 4 files changed +43
-15
lines changed
Expand file tree Collapse file tree 4 files changed +43
-15
lines changed Original file line number Diff line number Diff line change @@ -52,6 +52,11 @@ func (self *CommitDescriptionPanelDriver) AddCoAuthor(author string) *CommitDesc
5252 return self
5353}
5454
55+ func (self * CommitDescriptionPanelDriver ) Clear () * CommitDescriptionPanelDriver {
56+ self .getViewDriver ().Clear ()
57+ return self
58+ }
59+
5560func (self * CommitDescriptionPanelDriver ) Title (expected * TextMatcher ) * CommitDescriptionPanelDriver {
5661 self .getViewDriver ().Title (expected )
5762
Original file line number Diff line number Diff line change @@ -39,20 +39,7 @@ func (self *CommitMessagePanelDriver) SwitchToDescription() *CommitDescriptionPa
3939}
4040
4141func (self * CommitMessagePanelDriver ) Clear () * CommitMessagePanelDriver {
42- // clearing multiple times in case there's multiple lines
43- // (the clear button only clears a single line at a time)
44- maxAttempts := 100
45- for i := 0 ; i < maxAttempts + 1 ; i ++ {
46- if self .getViewDriver ().getView ().Buffer () == "" {
47- break
48- }
49-
50- self .t .press (ClearKey )
51- if i == maxAttempts {
52- panic ("failed to clear commit message panel" )
53- }
54- }
55-
42+ self .getViewDriver ().Clear ()
5643 return self
5744}
5845
Original file line number Diff line number Diff line change @@ -40,6 +40,24 @@ func (self *ViewDriver) Title(expected *TextMatcher) *ViewDriver {
4040 return self
4141}
4242
43+ func (self * ViewDriver ) Clear () * ViewDriver {
44+ // clearing multiple times in case there's multiple lines
45+ // (the clear button only clears a single line at a time)
46+ maxAttempts := 100
47+ for i := 0 ; i < maxAttempts + 1 ; i ++ {
48+ if self .getView ().Buffer () == "" {
49+ break
50+ }
51+
52+ self .t .press (ClearKey )
53+ if i == maxAttempts {
54+ panic ("failed to clear view buffer" )
55+ }
56+ }
57+
58+ return self
59+ }
60+
4361// asserts that the view has lines matching the given matchers. One matcher must be passed for each line.
4462// If you only care about the top n lines, use the TopLines method instead.
4563// If you only care about a subset of lines, use the ContainsLines method instead.
Original file line number Diff line number Diff line change @@ -28,13 +28,31 @@ var PreserveCommitMessage = NewIntegrationTest(NewIntegrationTestArgs{
2828 Type ("second paragraph" ).
2929 Cancel ()
3030
31+ t .FileSystem ().PathPresent (".git/LAZYGIT_PENDING_COMMIT" )
32+
3133 t .Views ().Files ().
3234 IsFocused ().
3335 Press (keys .Files .CommitChanges )
3436
3537 t .ExpectPopup ().CommitMessagePanel ().
3638 Content (Equals ("my commit message" )).
3739 SwitchToDescription ().
38- Content (Equals ("first paragraph\n \n second paragraph" ))
40+ Content (Equals ("first paragraph\n \n second paragraph" )).
41+ Clear ().
42+ SwitchToSummary ().
43+ Clear ().
44+ Cancel ()
45+
46+ t .FileSystem ().PathNotPresent (".git/LAZYGIT_PENDING_COMMIT" )
47+
48+ t .Views ().Files ().
49+ IsFocused ().
50+ Press (keys .Files .CommitChanges )
51+
52+ t .ExpectPopup ().CommitMessagePanel ().
53+ Type ("my new commit message" ).
54+ Confirm ()
55+
56+ t .FileSystem ().PathNotPresent (".git/LAZYGIT_PENDING_COMMIT" )
3957 },
4058})
You can’t perform that action at this time.
0 commit comments