internal/webfetchhelp/help_test.go
package webfetchhelp
import (
"strings"
"testing"
"unicode/utf8"
)
func TestHelpEmbeddedAssetsAndMetaMapping(t *testing.T) {
sections := []struct {
name string
text string
}{
{"meta:webfetch-help", General()},
{"meta:webfetch-help/http", HTTP()},
{"meta:webfetch-help/html", HTML()},
{"meta:webfetch-help/websocket", WebSocket()},
{"meta:webfetch-help/framed", Framed()},
{"meta:webfetch-help/mcp", MCP()},
{"meta:webfetch-help/all", All()},
}
for _, section := range sections {
t.Run(section.name, func(t *testing.T) {
if section.text == "" || !utf8.ValidString(section.text) || !strings.HasSuffix(section.text, "\n") {
t.Fatalf("invalid canonical help asset")
}
got, ok := Meta(section.name)
if !ok || got != section.text {
t.Fatalf("meta mapping differs from canonical bytes")
}
if strings.Contains(got, "\x1b[") {
t.Fatal("help contains ANSI escape")
}
})
}
if _, ok := Meta("meta:webfetch-help/unknown"); ok {
t.Fatal("unknown help suffix resolved")
}
}
func TestHelpAllAssemblyOrder(t *testing.T) {
all := All()
parts := []string{General(), HTTP(), HTML(), WebSocket(), Framed(), MCP()}
at := -1
for _, part := range parts {
next := strings.Index(all, strings.TrimSuffix(part, "\n"))
if next <= at {
t.Fatalf("section missing or out of order: position %d after %d", next, at)
}
at = next
}
if !strings.Contains(all, "EXIT STATUSES AND SECURITY NOTES") {
t.Fatal("all-help footer missing")
}
}