defmodule FirehoseWeb.BlogTagsTest do
  use FirehoseWeb.ConnCase

  describe "engineering blog tags" do
    test "GET /blog/engineering/tag/:tag shows tag page with filtered posts", %{conn: conn} do
      body = conn |> get("/blog/engineering/tag/elixir") |> html_response(200)
      assert body =~ ~s(tagged "elixir")
      assert body =~ "Engineering Blog"
      assert body =~ "Hello World"
    end

    test "GET /blog/engineering/tag/:tag shows empty list for nonexistent tag", %{conn: conn} do
      body = conn |> get("/blog/engineering/tag/nonexistent-tag") |> html_response(200)
      assert body =~ ~s(tagged "nonexistent-tag")
    end
  end

  describe "release notes blog tags" do
    test "GET /blog/releases/tag/:tag shows tag page with filtered posts", %{conn: conn} do
      body = conn |> get("/blog/releases/tag/release") |> html_response(200)
      assert body =~ ~s(tagged "release")
      assert body =~ "Release Notes"
      assert body =~ "v0.1.0 Released"
    end

    test "GET /blog/releases/tag/:tag shows empty list for nonexistent tag", %{conn: conn} do
      body = conn |> get("/blog/releases/tag/nonexistent-tag") |> html_response(200)
      assert body =~ ~s(tagged "nonexistent-tag")
    end
  end

  describe "tag page structure" do
    test "engineering tag page has proper layout and back link", %{conn: conn} do
      body = conn |> get("/blog/engineering/tag/elixir") |> html_response(200)
      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 = conn |> get("/blog/releases/tag/release") |> html_response(200)
      assert body =~ "Release Notes"
      assert body =~ ~s(tagged "release")
      assert body =~ "All posts"
    end
  end
end
