Add Telegram file upload directive
This commit is contained in:
@@ -252,6 +252,24 @@ func TestSplitAssistantMessageSegmentsWithPhotoDirective(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestSplitAssistantMessageSegmentsWithFileDirective(t *testing.T) {
|
||||
filePath := filepath.Join(string(filepath.Separator), "workspace", "report.pdf")
|
||||
text := fmt.Sprintf("before\n<!-- telegram-file {\"path\":%q,\"caption\":\"report\"} -->\nafter", filePath)
|
||||
segments := splitAssistantMessageSegments(text)
|
||||
if len(segments) != 3 {
|
||||
t.Fatalf("segments = %d, want 3: %#v", len(segments), segments)
|
||||
}
|
||||
if segments[0].Text != "before\n" || segments[0].File != nil {
|
||||
t.Fatalf("unexpected first segment: %#v", segments[0])
|
||||
}
|
||||
if segments[1].File == nil || segments[1].File.Path != filePath || segments[1].File.Caption != "report" {
|
||||
t.Fatalf("unexpected file segment: %#v", segments[1])
|
||||
}
|
||||
if segments[2].Text != "after" || segments[2].File != nil {
|
||||
t.Fatalf("unexpected final segment: %#v", segments[2])
|
||||
}
|
||||
}
|
||||
|
||||
func TestInvalidPhotoDirectiveStaysVisible(t *testing.T) {
|
||||
text := "<!-- telegram-photo not-json -->"
|
||||
segments := splitAssistantMessageSegments(text)
|
||||
@@ -261,7 +279,7 @@ func TestInvalidPhotoDirectiveStaysVisible(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAssistantStreamPreviewHidesDirectives(t *testing.T) {
|
||||
text := "before\n<!-- telegram-photo {\"path\":\"/workspace/photo.jpg\"} -->\nafter\n<!-- codex-thread-rename "
|
||||
text := "before\n<!-- telegram-file {\"path\":\"/workspace/report.pdf\"} -->\n<!-- telegram-photo {\"path\":\"/workspace/photo.jpg\"} -->\nafter\n<!-- codex-thread-rename "
|
||||
got := assistantStreamPreview(text)
|
||||
want := "before\nafter\n"
|
||||
if got != want {
|
||||
|
||||
Reference in New Issue
Block a user