From 80ea7b675e918b930af01b82b60583d474bc0105 Mon Sep 17 00:00:00 2001 From: Elvis Claros Castro Date: Sat, 3 Oct 2026 23:29:44 -0300 Subject: Share and export a session's images with --images --- server/server_test.go | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'server/server_test.go') diff --git a/server/server_test.go b/server/server_test.go index 1ad36ee..9adfa3a 100644 --- a/server/server_test.go +++ b/server/server_test.go @@ -2,6 +2,7 @@ package main import ( "bytes" + "encoding/base64" "encoding/json" "net/http" "net/http/httptest" @@ -145,6 +146,35 @@ func TestBranchAndDirectoryChange(t *testing.T) { } } +func TestImages(t *testing.T) { + h := newHarness(t, nil) + png := "data:image/png;base64," + base64.StdEncoding.EncodeToString([]byte("\x89PNG\r\n\x1a\nrest")) + withImg := strings.Replace(session, `"c":[`, `"c":[{"r":"i","x":"[image]","src":"`+png+`"},{"r":"v","x":"[image]"},`, 1) + r := h.create(`{"payload":` + payload(withImg) + `}`) + if js := h.do("GET", "/share/"+r.ID+".json", "", "").Body.String(); !strings.Contains(js, png) { + t.Fatalf("image lost: %s", js) + } + txt := h.do("GET", "/share/"+r.ID+".txt", "", "").Body.String() + if !strings.Contains(txt, "> image attached\n> image from the tool\n") { + t.Fatalf("txt: %s", txt) + } + + svg := "data:image/svg+xml;base64," + base64.StdEncoding.EncodeToString([]byte("")) + fake := "data:image/png;base64," + base64.StdEncoding.EncodeToString([]byte("