fix blog tag clicks, and new post

This commit is contained in:
Firehose Bot
2026-03-19 22:14:19 +00:00
parent be4be118a3
commit 671add15bb
10 changed files with 208 additions and 176 deletions
@@ -0,0 +1,123 @@
defmodule FirehoseWeb.BlogTagsTest do
use FirehoseWeb.ConnCase
defp goto_engineering_tag_page(conn, tag) do
path = "/blog/engineering/tag/#{tag}"
conn = get(conn, path)
body = html_response(conn, 200)
assert body =~ ~s(tagged "#{tag}")
assert body =~ "Engineering Blog"
body
end
defp goto_releases_tag_page(conn, tag) do
path = "/blog/releases/tag/#{tag}"
conn = get(conn, path)
body = html_response(conn, 200)
assert body =~ ~s(tagged "#{tag}")
assert body =~ "Release Notes"
body
end
describe "engineering blog tags" do
test "GET /blog/engineering/tag/:tag shows tag page with all posts", %{conn: conn} do
body = goto_engineering_tag_page(conn, "elixir")
assert body =~ "Hello World"
end
test "GET /blog/engineering/tag/:tag page shows filtered posts", %{conn: conn} do
body = goto_engineering_tag_page(conn, "phoenix")
assert body =~ "Hello World"
end
test "GET /blog/engineering/tag/:tag page shows empty list for nonexistent tag", %{
conn: conn
} do
body = get(conn, "/blog/engineering/tag/nonexistent-tag")
assert html_response(body, 200) =~ ~s(tagged "nonexistent-tag")
end
end
describe "release notes blog tags" do
test "GET /blog/releases/tag/:tag shows tag page with all posts", %{conn: conn} do
body = goto_releases_tag_page(conn, "release")
assert body =~ "v0.1.0 Released"
end
test "GET /blog/releases/tag/:tag page shows filtered posts", %{conn: conn} do
body = get(conn, "/blog/releases/tag/nonexistent-tag")
assert html_response(body, 200) =~ ~s(tagged "nonexistent-tag")
end
end
describe "tag URL pattern" do
test "tag URLs follow pattern /blog/:blog_id/tag/:tag for engineering blog", %{conn: conn} do
# Test that the tag route exists and works correctly
conn = get(conn, "/blog/engineering/tag/elixir")
assert html_response(conn, 200) =~ ~s(tagged "elixir")
conn = get(conn, "/blog/engineering/tag/phoenix")
assert html_response(conn, 200) =~ ~s(tagged "phoenix")
end
test "tag URLs follow pattern /blog/:blog_id/tag/:tag for releases blog", %{conn: conn} do
# Test that the tag route exists and works correctly
conn = get(conn, "/blog/releases/tag/release")
assert html_response(conn, 200) =~ ~s(tagged "release")
end
test "nonexistent tags return 200 with empty post list", %{conn: conn} do
conn = get(conn, "/blog/engineering/tag/nonexistent-tag")
assert html_response(conn, 200)
end
end
describe "tag page structure" do
test "tag page has proper layout and back link", %{conn: conn} do
body = goto_engineering_tag_page(conn, "elixir")
assert body =~ "Engineering Blog"
assert body =~ ~s(tagged "elixir")
assert body =~ "All posts"
end
test "release tag page has proper layout and back link", %{conn: conn} do
body = goto_releases_tag_page(conn, "release")
assert body =~ "Release Notes"
assert body =~ ~s(tagged "release")
assert body =~ "All posts"
end
end
describe "clickable tags on index page" do
test "tags are rendered as clickable links on engineering blog index", %{
conn: conn
} do
conn = get(conn, "/blog/engineering")
body = html_response(conn, 200)
# Verify tag links exist with correct href pattern
assert body =~ ~r{href="/blog/engineering/tag/meta"}
assert body =~ ~r{href="/blog/engineering/tag/ai"}
end
test "tags are rendered as clickable links on releases blog index", %{
conn: conn
} do
conn = get(conn, "/blog/releases")
body = html_response(conn, 200)
# Verify tag link exists
assert body =~ ~r{href="/blog/releases/tag/release"}
end
test "tag links have proper styling classes", %{conn: conn} do
conn = get(conn, "/blog/engineering")
body = html_response(conn, 200)
# Verify blogex-tag-link class is present for tag links
assert body =~ ~r{class="[^"]*blogex-tag-link}
end
end
end