# tests/test_pack_basic.py
from __future__ import annotations

from pathlib import Path

import oceansguard.cli as cli
from tests.conftest import read_text, repo_ctx, ux, write_aiguard_yml


def test_pack_generates_markdown(repo_ctx, ux, patch_subprocess_for_pack):
    repo = repo_ctx.repo
    write_aiguard_yml(repo, max_files=200, max_kb_each=64, include_frontend_in_roots=True)

    cli.cmd_pack(ux, repo, strict=False)

    out = repo / "ai_context_pack.md"
    assert out.exists()
    txt = read_text(out)

    # ヘッダ
    assert "# OceansGuard Context Pack" in txt
    # small 由来
    assert "## Context (small)" in txt
    assert "README.md" in txt
    assert "backend/app/main.py" in txt
    assert "frontend/package.json" in txt

    # large 由来
    assert "## Context (large, capped)" in txt
    # backend / frontend が含まれる（中身の行があることだけ見る）
    assert "### backend/app/main.py" in txt
    assert "### frontend/package.json" in txt
