package render import ( "context" "strings" "testing" "git.dev.alexdunmow.com/block/core/blocks" "github.com/google/uuid" ) type testEmbedResolver struct{} func (testEmbedResolver) RenderEmbed(_ context.Context, blockID uuid.UUID, dataSource, layout string) string { return "embed:" + blockID.String() + ":" + dataSource + ":" + layout } func TestBlockNoteToHTMLUsesSDKContextResolvers(t *testing.T) { blockID := uuid.MustParse("11111111-1111-1111-1111-111111111111") ctx := blocks.WithEmbedResolver(context.Background(), testEmbedResolver{}) ctx = blocks.WithHumanProofBanner(ctx, &blocks.HumanProofBannerData{ ActiveTimeMinutes: 12, KeystrokeCount: 3456, SessionCount: 2, PostSlug: "proof-post", }) html := BlockNoteToHTML(ctx, map[string]any{ "blocks": []any{ map[string]any{ "type": "embed", "props": map[string]any{ "blockId": blockID.String(), "dataSource": "row:22222222-2222-2222-2222-222222222222", "layout": "card", }, }, map[string]any{"type": "humanProof"}, }, }) if !strings.Contains(html, "embed:"+blockID.String()+":row:22222222-2222-2222-2222-222222222222:card") { t.Fatalf("BlockNoteToHTML() did not render embed from SDK context: %s", html) } if !strings.Contains(html, `data-human-proof-banner`) || !strings.Contains(html, `proof-post`) { t.Fatalf("BlockNoteToHTML() did not render human proof banner from SDK context: %s", html) } }