Replace the markdown-rendered /docs/api page with a structured LiveView modelled on the Tailwind UI Protocol template — fixed left sidebar with grouped section nav, hero with metadata dl, two-column rows where prose sits next to a sticky code sample, and endpoint cards with color-coded HTTP method tags.
49 lines
1.6 KiB
Elixir
49 lines
1.6 KiB
Elixir
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
|