from grantflow.tests.demo_console_helpers import (
    assert_demo_console_tokens,
    demo_console_body,
)


def test_demo_console_exposes_critic_quality_and_export_controls():
    body = demo_console_body()
    assert_demo_console_tokens(
        body,
        [
            "criticSeverityFilter",
            "criticFindingStatusFilter",
            "criticCitationConfidenceFilter",
            "criticBulkTargetStatus",
            "criticBulkScope",
            "criticBulkApplyBtn",
            "criticBulkPreviewBtn",
            "criticBulkActionHint",
            "criticWorkflowFilterSuggestion",
            "criticBulkClearFiltersBtn",
            "criticSyncWorkflowFiltersBtn",
            "criticBulkResultJson",
            "criticBulkSummaryList",
            "Apply Bulk Status",
            "Preview Bulk Status",
            "finding bulk action:",
            "workflow filter suggestion:",
            "Clear Critic Filters",
            "Use Workflow Filters",
            "criticAdvisorySummaryList",
            "criticAdvisoryLabelsList",
            "criticAdvisoryNormalizationList",
            "Jump to Diff",
            "Create Comment",
            "criticContextList",
            "llm_advisory_diagnostics",
            "conf ",
            "thr ",
            "architect_threshold_hit_rate",
            "qualityBtn",
            "workerHeartbeatBtn",
            "workerHeartbeatPollSeconds",
            "workerHeartbeatPollToggleBtn",
            "HB Poll Interval",
            "Stop HB Poll",
            "workerHeartbeatPill",
            "workerHeartbeatJson",
            "qualityCards",
            "qualityPreflightMetaLine",
            "qualityGroundedGatePill",
            "qualityGroundedGateExplainBtn",
            "qualityGroundedGateReasonsWrap",
            "qualityGroundedGateReasonsList",
            "Why blocked?",
            "qualityMelSummaryList",
            "qualityCitationTypeCountsList",
            "qualityArchitectCitationTypeCountsList",
            "Grounding KPI",
            "groundingKpiCards",
            "groundingKpiMetaLine",
            "groundingKpiCountsList",
            "groundingKpiPolicyReasonsList",
            "Claim-support",
            "Architect fallback",
            "MEL claim-support",
            "MEL fallback",
            "Fallback rate",
            "Traceability complete",
            "Traceability gap",
            "qualityJson",
            "exportPayloadBtn",
            "copyExportPayloadBtn",
            "exportZipFromPayloadBtn",
            "exportProductionZipFromPayloadBtn",
            "Production Export (enforced)",
            "exportContractPill",
            "exportContractPillText",
            "exportContractMetaLine",
            "exportContractWarningsList",
            "rfqSubmissionReadinessPill",
            "rfqSubmissionReadinessPillText",
            "rfqSubmissionReadinessMetaLine",
            "rfqSubmissionReadinessCountsLine",
            "rfqSubmissionReadinessList",
            "sendGatePill",
            "sendGatePillText",
            "sendGateMetaLine",
            "sendGateAdvisoryLine",
            "productionExportMode",
            "allowUnsafeExport",
            "exportPayloadJson",
            "Send Gate",
            "RFQ Submission Readiness",
            "Submission completeness score",
            "Top RFQ submission gap",
            "external send gate pending portfolio workflow snapshot",
            "production_export",
            "allow_unsafe_export",
        ],
    )


def test_demo_console_includes_bulk_preview_summary_helpers():
    body = demo_console_body()
    assert "renderBulkPreviewSummary" in body
    assert "criticBulkSummaryList" in body
    assert "commentBulkSummaryList" in body
    assert "Preview Mode" in body
    assert "Apply Mode" in body
    assert "Scope" in body
    assert "Filter Basis" in body
    assert "Status Transition" in body
    assert "Queue Impact" in body
    assert "workflow policy:" in body
    assert "portfolio policy:" in body
    assert "external send blocked" in body
    assert "send with conditions" in body
    assert "send safe" in body
    assert "Matched" in body
    assert "Changed" in body
    assert "Unchanged" in body
    assert "Not Found" in body
    assert "Target Status" in body
    assert "Missing IDs" in body


def test_demo_console_includes_rfq_submission_readiness_helpers():
    body = demo_console_body()
    assert "renderRfQSubmissionReadiness" in body
    assert "rfqSubmissionReadinessPill" in body
    assert "rfqSubmissionReadinessList" in body
    assert "RFQ Submission Readiness" in body
    assert "Submission completeness score" in body
    assert "Top RFQ submission gap" in body
