1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-07-30 03:23:08 +03:00

Add demo test variant

We're piggybacking on our existing integration test framework to record  demos that we can include in our docs
This commit is contained in:
Jesse Duffield
2023-07-31 18:32:38 +10:00
parent 71d2fd37e2
commit 9cc1d65280
32 changed files with 891 additions and 12 deletions

View File

@ -3,6 +3,7 @@ package popup
import (
"context"
"strings"
"time"
"github.com/jesseduffield/gocui"
"github.com/jesseduffield/lazygit/pkg/common"
@ -25,6 +26,7 @@ type PopupHandler struct {
toastFn func(message string)
getPromptInputFn func() string
onWorker func(func(gocui.Task))
inDemo func() bool
}
var _ types.IPopupHandler = &PopupHandler{}
@ -40,6 +42,7 @@ func NewPopupHandler(
toastFn func(message string),
getPromptInputFn func() string,
onWorker func(func(gocui.Task)),
inDemo func() bool,
) *PopupHandler {
return &PopupHandler{
Common: common,
@ -53,6 +56,7 @@ func NewPopupHandler(
toastFn: toastFn,
getPromptInputFn: getPromptInputFn,
onWorker: onWorker,
inDemo: inDemo,
}
}
@ -144,6 +148,11 @@ func (self *PopupHandler) WithLoaderPanel(message string, f func(gocui.Task) err
}
self.onWorker(func(task gocui.Task) {
// emulating a delay due to network latency
if self.inDemo() {
time.Sleep(500 * time.Millisecond)
}
if err := f(task); err != nil {
self.Log.Error(err)
}