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

@ -38,6 +38,7 @@ type IntegrationTest struct {
gitVersion GitVersionRestriction
width int
height int
isDemo bool
}
var _ integrationTypes.IntegrationTest = &IntegrationTest{}
@ -63,6 +64,8 @@ type NewIntegrationTestArgs struct {
// If these are set, the test must be run in headless mode
Width int
Height int
// If true, this is not a test but a demo to be added to our docs
IsDemo bool
}
type GitVersionRestriction struct {
@ -133,6 +136,7 @@ func NewIntegrationTest(args NewIntegrationTestArgs) *IntegrationTest {
gitVersion: args.GitVersion,
width: args.Width,
height: args.Height,
isDemo: args.IsDemo,
}
}
@ -156,6 +160,10 @@ func (self *IntegrationTest) Skip() bool {
return self.skip
}
func (self *IntegrationTest) IsDemo() bool {
return self.isDemo
}
func (self *IntegrationTest) ShouldRunForGitVersion(version *git_commands.GitVersion) bool {
return self.gitVersion.shouldRunOnVersion(version)
}
@ -178,9 +186,19 @@ func (self *IntegrationTest) Run(gui integrationTypes.GuiDriver) {
keys := gui.Keys()
testDriver := NewTestDriver(gui, shell, keys, KeyPressDelay())
if KeyPressDelay() > 0 {
// Setting caption to clear the options menu from whatever it starts with
testDriver.SetCaption("")
testDriver.SetCaptionPrefix("")
testDriver.Wait(1000)
}
self.run(testDriver, keys)
if KeyPressDelay() > 0 {
// Clear whatever caption there was so it doesn't linger
testDriver.SetCaption("")
testDriver.SetCaptionPrefix("")
// the dev would want to see the final state if they're running in slow mode
testDriver.Wait(2000)
}