mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-10-31 09:14:02 -05:00
Send the two clicks of a double click in tests without waiting between
The test enter_and_double_click_focus_file_diff fails occasionally on CI. After it double-clicks a file, the files panel still has the focus instead of the main view. The test double-clicks by calling Click twice. Click waits for lazygit to become idle after the press and again after the release, and the first wait includes the git diff that the click starts for the main view. gocui only counts the second click as a double click if it handles it within 500ms of the first one. On a busy CI runner, where many integration tests run in parallel, the waits can take longer than that, and the second click counts as a single click. Add DoubleClick to the test driver. It replays both clicks without waiting in between, as a terminal reports a double click, and waits for lazygit to become idle only after the second one. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
883c893911
commit
9e76ed7c03
6 files changed
+37
-6
No files matched your search
@@ -63,6 +63,16 @@ func (self *GuiDriver) ClickWithModifier(x, y int, modifier gocui.Modifier) {
|
||||
self.replayMouseEvent(x, y, tcell.ButtonNone, modifier)
|
||||
}
|
||||
|
||||
func (self *GuiDriver) DoubleClick(x, y int) {
|
||||
self.CheckAllToastsAcknowledged()
|
||||
|
||||
for range 2 {
|
||||
self.replayMouseEventWithoutWaiting(x, y, tcell.ButtonPrimary, gocui.ModNone)
|
||||
self.replayMouseEventWithoutWaiting(x, y, tcell.ButtonNone, gocui.ModNone)
|
||||
}
|
||||
self.waitTillIdle()
|
||||
}
|
||||
|
||||
func (self *GuiDriver) ClickAndHold(x, y int) {
|
||||
self.CheckAllToastsAcknowledged()
|
||||
self.replayMouseEvent(x, y, tcell.ButtonPrimary, gocui.ModNone)
|
||||
|
||||
@@ -61,6 +61,12 @@ func (self *TestDriver) click(x, y int) {
|
||||
self.Wait(self.inputDelay)
|
||||
}
|
||||
|
||||
func (self *TestDriver) doubleClick(x, y int) {
|
||||
self.SetCaption(fmt.Sprintf("Double-clicking %d, %d", x, y))
|
||||
self.gui.DoubleClick(x, y)
|
||||
self.Wait(self.inputDelay)
|
||||
}
|
||||
|
||||
func (self *TestDriver) clickWithModifier(x, y int, modifier gocui.Modifier, what string) {
|
||||
self.SetCaption(fmt.Sprintf("%s-clicking %d, %d", what, x, y))
|
||||
self.gui.ClickWithModifier(x, y, modifier)
|
||||
|
||||
@@ -51,6 +51,10 @@ func (self *fakeGuiDriver) ClickWithModifier(x, y int, modifier gocui.Modifier)
|
||||
self.clickedCoordinates = append(self.clickedCoordinates, coordinate{x: x, y: y})
|
||||
}
|
||||
|
||||
func (self *fakeGuiDriver) DoubleClick(x, y int) {
|
||||
self.clickedCoordinates = append(self.clickedCoordinates, coordinate{x: x, y: y})
|
||||
}
|
||||
|
||||
func (self *fakeGuiDriver) ClickAndHold(x, y int) {
|
||||
self.heldCoordinates = append(self.heldCoordinates, coordinate{x: x, y: y})
|
||||
}
|
||||
@@ -207,6 +211,7 @@ func TestViewDriverPointerCoordinates(t *testing.T) {
|
||||
AltClick(2, 3).
|
||||
ShiftClick(4, 5).
|
||||
FocusInAndClick(3, 4).
|
||||
DoubleClick(6, 7).
|
||||
ClickAndHold(5, 6).
|
||||
MouseMove(7, 8).
|
||||
MouseMoveToBottom(9).
|
||||
@@ -214,12 +219,12 @@ func TestViewDriverPointerCoordinates(t *testing.T) {
|
||||
ScrollWheelDown()
|
||||
|
||||
assert.Equal(t,
|
||||
[]coordinate{{12, 23}, {13, 24}, {15, 26}, {14, 25}},
|
||||
[]coordinate{{12, 23}, {13, 24}, {15, 26}, {14, 25}, {17, 28}},
|
||||
guiDriver.clickedCoordinates)
|
||||
assert.Equal(t, []coordinate{{16, 27}}, guiDriver.heldCoordinates)
|
||||
assert.Equal(t, []coordinate{{18, 29}, {20, 30}, {51, 62}}, guiDriver.movedCoordinates)
|
||||
assert.Equal(t, []coordinate{{11, 21}}, guiDriver.scrolledCoordinates)
|
||||
assert.Equal(t, 9, guiDriver.onUIThreadCallCount)
|
||||
assert.Equal(t, 10, guiDriver.onUIThreadCallCount)
|
||||
}
|
||||
|
||||
func TestFailingFixture(t *testing.T) {
|
||||
|
||||
@@ -735,6 +735,14 @@ func (self *ViewDriver) Click(x, y int) *ViewDriver {
|
||||
return self
|
||||
}
|
||||
|
||||
func (self *ViewDriver) DoubleClick(x, y int) *ViewDriver {
|
||||
offsetX, offsetY, _ := self.viewGeometry()
|
||||
|
||||
self.t.doubleClick(offsetX+1+x, offsetY+1+y)
|
||||
|
||||
return self
|
||||
}
|
||||
|
||||
// AltClick and ShiftClick click with a modifier held down. Both modifiers are
|
||||
// bound to the same gestures, because no single one of them reaches lazygit in
|
||||
// every terminal.
|
||||
|
||||
@@ -32,8 +32,7 @@ var EnterAndDoubleClickFocusFileDiff = NewIntegrationTest(NewIntegrationTestArgs
|
||||
|
||||
t.Views().Files().
|
||||
IsFocused().
|
||||
Click(3, 0).
|
||||
Click(3, 0)
|
||||
DoubleClick(3, 0)
|
||||
t.Views().Main().
|
||||
IsFocused().
|
||||
SelectedLines(Contains("-base")).
|
||||
@@ -60,8 +59,7 @@ var EnterAndDoubleClickFocusFileDiff = NewIntegrationTest(NewIntegrationTestArgs
|
||||
|
||||
t.Views().CommitFiles().
|
||||
IsFocused().
|
||||
Click(3, 0).
|
||||
Click(3, 0)
|
||||
DoubleClick(3, 0)
|
||||
t.Views().Main().
|
||||
IsFocused().
|
||||
SelectedLines(Contains("+base"))
|
||||
|
||||
@@ -31,6 +31,10 @@ type GuiDriver interface {
|
||||
// Click with a keyboard modifier held down, for the gestures that only exist
|
||||
// as a modified click.
|
||||
ClickWithModifier(int, int, gocui.Modifier)
|
||||
// Two clicks in immediate succession, waiting for lazygit to become idle only
|
||||
// after the second one. If it waited after the first one too, the second click
|
||||
// could come too late to count as a double click.
|
||||
DoubleClick(int, int)
|
||||
ClickAndHold(int, int)
|
||||
MouseMove(int, int)
|
||||
MouseRelease(int, int)
|
||||
|
||||
Reference in new issue
Block a user