CmdForge/tests/test_web_docs_content.py

126 lines
3.7 KiB
Python

"""Regression tests for user-facing documentation embedded in the web app."""
import re
from cmdforge.web.docs_content import DOCS, get_doc, get_toc
def test_getting_started_documents_agent_first_workflow():
content = get_doc("getting-started")["content"]
expected_commands = (
"cmdforge list --json --filter",
"cmdforge registry search",
"cmdforge run-once",
"cmdforge create classify-docs --project",
"forge-tool --name classify-docs --project",
"cmdforge mcp configure codex --dry-run",
"cmdforge mcp configure claude-code --dry-run",
)
for command in expected_commands:
assert command in content
def test_first_tool_explains_project_ownership():
content = get_doc("first-tool")["content"]
assert "cmdforge create explain --project" in content
assert "./.cmdforge/" in content
def test_every_document_appears_once_in_the_book_navigation():
slugs = []
for chapter in get_toc():
slugs.append(chapter.slug)
slugs.extend(page.slug for page in chapter.children)
assert len(slugs) == len(set(slugs))
assert set(slugs) == set(DOCS)
def test_internal_documentation_links_resolve():
links = set()
for page in DOCS.values():
links.update(re.findall(r'href="/docs/([^"#?]+)', page["content"]))
assert links <= set(DOCS)
def test_modern_architecture_has_dedicated_chapters():
expected = {
"mcp-overview",
"mcp-client",
"mcp-server",
"agent-integration",
"contracts-quality",
"provider-policy",
"skills-delegation",
"optimization-usage",
"forge-tool",
"trust-publishing",
}
assert expected <= set(DOCS)
def test_mcp_documentation_covers_both_directions_and_transports():
content = " ".join(
get_doc(slug)["content"]
for slug in ("mcp-overview", "mcp-client", "mcp-server")
)
for term in (
"type: mcp",
"transport: stdio",
"transport: streamable-http",
"result_mode",
"cmdforge mcp connect",
"cmdforge mcp serve",
"expose",
"deny",
):
assert term in content
def test_provider_documentation_covers_strict_execution_contract():
content = get_doc("providers")["content"] + get_doc("provider-policy")["content"]
for term in (
"subprocess",
"API",
"PTY",
"--no-fallback",
"--require-local",
"--require-capability",
"--data-classification",
"--require-model-identity",
"--require-model-digest",
"--result-envelope json",
):
assert term in content
def test_command_atlas_covers_every_top_level_cli_family():
content = get_doc("cli-reference")["content"]
commands = (
"list", "create", "edit", "delete", "test", "run", "run-once", "ui",
"refresh", "docs", "inspect", "optimize", "check", "providers", "registry",
"collections", "deps", "install", "lock", "verify", "add", "remove", "init",
"config", "settings", "system-deps", "mcp", "usage",
)
for command in commands:
assert f"cmdforge {command}" in content
def test_installation_matches_runtime_and_current_provider_onboarding():
installation = get_doc("installation")["content"]
provider_setup = get_doc("provider-setup")["content"]
assert "Python 3.10" in installation
assert "Python 3.8" not in installation
assert "cmdforge[mcp]" in installation
assert "cmdforge providers discover --add" in installation
assert "cmdforge providers discover --add" in provider_setup
assert "--type api" in provider_setup
assert "pip install claude-cli" not in provider_setup