Files
lazygit/pkg/integration/components/commit_description_panel_driver.go
Stefan HallerandClaude Opus 5.5 dec9e49162 Add support for pasting text in integration tests
The commit message panel handles pasted text differently from typed
text (see ba6cfc1f85), but integration tests couldn't simulate a
paste, so this had no tests. Let tests replay the events that a
terminal sends for a bracketed paste: the start of the paste, a key
press for each character, and the end of the paste.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 10:22:50 +01:00

77 lines
2.0 KiB
Go

package components
type CommitDescriptionPanelDriver struct {
t *TestDriver
}
func (self *CommitDescriptionPanelDriver) getViewDriver() *ViewDriver {
return self.t.Views().CommitDescription()
}
// asserts on the current context of the description
func (self *CommitDescriptionPanelDriver) Content(expected *TextMatcher) *CommitDescriptionPanelDriver {
self.getViewDriver().Content(expected)
return self
}
func (self *CommitDescriptionPanelDriver) Type(value string) *CommitDescriptionPanelDriver {
self.t.typeContent(value)
return self
}
// Paste the text the way a terminal does it, as opposed to pasting it with the
// commit menu
func (self *CommitDescriptionPanelDriver) Paste(text string) *CommitDescriptionPanelDriver {
self.t.paste(text)
return self
}
func (self *CommitDescriptionPanelDriver) SwitchToSummary() *CommitMessagePanelDriver {
self.getViewDriver().PressTab()
return &CommitMessagePanelDriver{t: self.t}
}
func (self *CommitDescriptionPanelDriver) AddNewline() *CommitDescriptionPanelDriver {
self.t.pressFast("<enter>")
return self
}
func (self *CommitDescriptionPanelDriver) GoToBeginning() *CommitDescriptionPanelDriver {
numLines := len(self.getViewDriver().getView().BufferLines())
for range numLines {
self.t.pressFast("<up>")
}
self.t.pressFast("<ctrl+a>")
return self
}
func (self *CommitDescriptionPanelDriver) AddCoAuthor(author string) *CommitDescriptionPanelDriver {
self.t.press(self.t.keys.CommitMessage.CommitMenu[0])
self.t.ExpectPopup().Menu().Title(Equals("Commit Menu")).
Select(Contains("Add co-author")).
Confirm()
self.t.ExpectPopup().Prompt().Title(Contains("Add co-author")).
Type(author).
Confirm()
return self
}
func (self *CommitDescriptionPanelDriver) Clear() *CommitDescriptionPanelDriver {
self.getViewDriver().Clear()
return self
}
func (self *CommitDescriptionPanelDriver) Title(expected *TextMatcher) *CommitDescriptionPanelDriver {
self.getViewDriver().Title(expected)
return self
}
func (self *CommitDescriptionPanelDriver) Cancel() {
self.getViewDriver().PressEscape()
}