//! Offline projection smoke test over the shared full-featured fixture (R2).
//!
//! The same `tests/fixtures/full-featured.org` the live push test (P7) sends to
//! Google is projected here purely offline: assigning `CUSTOM_ID`s, parsing the
//! body, and running the P3 projection must succeed, exercise every supported
//! element, and never panic. This ties the fixture to the offline tier so a
//! regression in the projection is caught in CI without network access.

use org_gdocs::custom_id::ensure_section_ids;
use org_gdocs::project::{self, Projection};

const FULL_FEATURED: &str = include_str!("fixtures/full-featured.org");

#[test]
fn full_featured_fixture_projects_cleanly() {
    let body = ensure_section_ids(FULL_FEATURED);
    let document = kb::parser::parse_document(&body).expect("fixture parses as org");
    let Projection {
        requests,
        positions,
    } = project::project(&document);

    // The fixture exercises every supported element, so the projection is
    // non-trivial on both axes.
    assert!(!requests.is_empty(), "projection produced no requests");
    assert!(!positions.is_empty(), "projection produced no positions");

    // Headings are keyed by their slugged `:CUSTOM_ID:`; the top-level sections
    // must all be present and anchorable.
    for section in [
        "sec-introduction",
        "sec-lists",
        "sec-a-table",
        "sec-code",
        "sec-example",
        "sec-a-quote",
        "sec-rule",
    ] {
        assert!(
            positions.contains_key(section),
            "missing projected section {section}"
        );
    }
}
