Skip to content

Commit 471ba9d

Browse files
committed
improve and adapt commit persistence test-cases
1 parent d6a5f23 commit 471ba9d

File tree

4 files changed

+43
-15
lines changed

4 files changed

+43
-15
lines changed

pkg/integration/components/commit_description_panel_driver.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
5560
func (self *CommitDescriptionPanelDriver) Title(expected *TextMatcher) *CommitDescriptionPanelDriver {
5661
self.getViewDriver().Title(expected)
5762

pkg/integration/components/commit_message_panel_driver.go

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,7 @@ func (self *CommitMessagePanelDriver) SwitchToDescription() *CommitDescriptionPa
3939
}
4040

4141
func (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

pkg/integration/components/view_driver.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff 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.

pkg/integration/tests/commit/preserve_commit_message.go

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff 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\nsecond paragraph"))
40+
Content(Equals("first paragraph\n\nsecond 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
})

0 commit comments

Comments
 (0)