wip chat sessions 2
This commit is contained in:
92 files changed
+3692
-22
No files matched your search
@@ -0,0 +1,63 @@
|
||||
package mujica
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/egoist/mygo/ui"
|
||||
)
|
||||
|
||||
func TestArtifactCardOpens(t *testing.T) {
|
||||
opens := 0
|
||||
tt := chatTester(480, 160, func(c *ui.Context) {
|
||||
if ArtifactCard(c, ArtifactCardOptions{Kind: ArtifactDocument, Title: "Decree", Detail: "2 pages"}).Changed() {
|
||||
opens++
|
||||
}
|
||||
})
|
||||
if !tt.HasText("Document · 2 pages") {
|
||||
t.Fatalf("texts %q", tt.Texts())
|
||||
}
|
||||
_ = tt.Click("Decree")
|
||||
tt.Key(0, ui.KeyTab)
|
||||
tt.Key(0, ui.KeyEnter)
|
||||
if opens != 2 {
|
||||
t.Fatalf("opens %d", opens)
|
||||
}
|
||||
}
|
||||
|
||||
func TestArtifactCardStreamingDisabledAndChecks(t *testing.T) {
|
||||
opens := 0
|
||||
tt := chatTester(480, 160, func(c *ui.Context) {
|
||||
if ArtifactCard(c, ArtifactCardOptions{Kind: ArtifactWeb, Title: "Menu", Streaming: true, Disabled: true}).Changed() {
|
||||
opens++
|
||||
}
|
||||
})
|
||||
_ = tt.Click("Menu")
|
||||
tt.Key(0, ui.KeyTab)
|
||||
tt.Key(0, ui.KeyEnter)
|
||||
if opens != 0 || !tt.HasText("Web page") {
|
||||
t.Fatalf("opens %d texts %q", opens, tt.Texts())
|
||||
}
|
||||
for _, opts := range []ArtifactCardOptions{{}, {Title: "x", Kind: 7}} {
|
||||
func() {
|
||||
defer func() {
|
||||
if recover() == nil {
|
||||
t.Errorf("%+v: no panic", opts)
|
||||
}
|
||||
}()
|
||||
ui.Render(func(c *ui.Context) {
|
||||
Use(c, Settings{})
|
||||
ArtifactCard(c, opts)
|
||||
}, 100, 100, 1)
|
||||
}()
|
||||
}
|
||||
}
|
||||
|
||||
func TestArtifactCardSnapshot(t *testing.T) {
|
||||
snapshot(t, "artifact_card", 460, 210, func(c *ui.Context) {
|
||||
ui.Column(c).Padding(16).Gap(8).Children(func() {
|
||||
ArtifactCard(c, ArtifactCardOptions{Kind: ArtifactCode, Title: "seating.go", Detail: "Go · 120 lines"})
|
||||
ArtifactCard(c, ArtifactCardOptions{Kind: ArtifactDocument, Title: "Royal decree", Streaming: true})
|
||||
ArtifactCard(c, ArtifactCardOptions{Kind: ArtifactWeb, Title: "Ball invitation", Disabled: true})
|
||||
})
|
||||
})
|
||||
}
|
||||
Reference in new issue
Block a user