;; lib/host/tests/blog.sx — blog on the editor's content model. Posts are ;; {slug,title,sx_content,status} records in the durable KV; a post page is ;; render-to-html(parse sx_content). Covers read/render, home index, JSON list, ;; slugify, the form-urlencoded editor ingest, and JSON CRUD (auth+ACL guarded). (define host-bl-pass 0) (define host-bl-fail 0) (define host-bl-fails (list)) (define host-bl-test (fn (name actual expected) (if (= actual expected) (set! host-bl-pass (+ host-bl-pass 1)) (begin (set! host-bl-fail (+ host-bl-fail 1)) (append! host-bl-fails {:name name :actual actual :expected expected}))))) (define host-bl-req (fn (target) (dream-request "GET" target {} ""))) (define host-bl-app (host/make-app (list host/feed-routes host/blog-routes))) ;; ── slugify ───────────────────────────────────────────────────────── (host-bl-test "slugify" (host/blog-slugify "Hello World") "hello-world") (host-bl-test "slugify trims spaces" (host/blog-slugify " A B ") "a-b") ;; ── render a stored post ──────────────────────────────────────────── (host/blog-use-store! (persist/open)) (host/blog-put! "hello" "Hello World" "(article (h1 \"Hello World\") (p \"A \" (strong \"bold\") \" word.\"))" "published") (host-bl-test "post 200" (dream-status (host-bl-app (host-bl-req "/hello/"))) 200) (host-bl-test "post content-type html" (contains? (dream-resp-header (host-bl-app (host-bl-req "/hello/")) "content-type") "text/html") true) (host-bl-test "post renders sx_content markup" (contains? (dream-resp-body (host-bl-app (host-bl-req "/hello/"))) "bold") true) (host-bl-test "post title in page" (contains? (dream-resp-body (host-bl-app (host-bl-req "/hello/"))) "