defmodule MicrowavepropWeb.ApiDocsLiveTest do use MicrowavepropWeb.ConnCase, async: true import Phoenix.LiveViewTest test "renders the API reference at /docs/api", %{conn: conn} do {:ok, _view, html} = live(conn, ~p"/docs/api") assert html =~ "Microwaveprop API" assert html =~ "/api/v1" assert html =~ "/auth/tokens" end test "renders the protocol-style two-pane layout shell", %{conn: conn} do {:ok, _view, html} = live(conn, ~p"/docs/api") assert html =~ ~s(class="api-docs-shell") assert html =~ ~s(class="api-docs-sidebar") assert html =~ ~s(class="api-docs-main") end test "renders sidebar nav links to in-page sections", %{conn: conn} do {:ok, _view, html} = live(conn, ~p"/docs/api") assert html =~ ~s(href="#quickstart") assert html =~ ~s(href="#authentication") assert html =~ ~s(href="#contacts") assert html =~ ~s(href="#scores") end test "renders endpoint cards with HTTP method tags", %{conn: conn} do {:ok, _view, html} = live(conn, ~p"/docs/api") assert html =~ "api-docs-method" assert html =~ "is-get" assert html =~ "is-post" assert html =~ "is-delete" end test "renders code samples without literal Elixir interpolation curly tokens", %{conn: conn} do {:ok, _view, html} = live(conn, ~p"/docs/api") # The JSON sample inside the curl call must round-trip the literal # braces — HEEx must not have eaten them as interpolation. HTML # escapes the surrounding double-quotes to ". assert html =~ ~s("station1": "W5XD") assert html =~ ~s("type": "about:blank") end end