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


def test_demo_console_exposes_review_workflow_controls():
    body = demo_console_body()
    assert_demo_console_tokens(
        body,
        [
            "Click to filter",
            "clearFiltersBtn",
            "Acknowledge",
            "Resolve Finding",
            "Reopen Finding",
            "linkedFindingId",
            "/critic/findings/bulk-status",
            "/comments/bulk-status",
            "ackCommentBtn",
            "commentBulkApplyBtn",
            "criticSelectedFindingIds",
            "criticSelectedFindingId",
            "criticAddSelectedFindingBtn",
            "criticCopySelectedFindingIdsBtn",
            "criticLoadFindingIdsFromWorkflowBtn",
            "commentSelectedCommentIds",
            "commentAddSelectedCommentBtn",
            "commentCopySelectedCommentIdsBtn",
            "commentLoadCommentIdsFromWorkflowBtn",
            "commentBulkPreviewBtn",
            "commentBulkActionHint",
            "commentWorkflowFilterSuggestion",
            "commentSyncWorkflowFiltersBtn",
            "commentBulkSummaryList",
            "selected finding ids",
            "selected comment ids",
            "Copy Selected IDs",
            "Fill From Workflow View",
            "comment bulk action:",
            "No bulk preview yet.",
            "reviewActionQueueCards",
            "Next Primary Action",
            "reviewWorkflowBtn",
            "reviewWorkflowSummaryLine",
            "reviewWorkflowPolicyLine",
            "reviewWorkflowTrendsSummaryLine",
            "reviewWorkflowTimelineList",
            "reviewWorkflowTrendSparkline",
            "reviewWorkflowTrendsList",
            "reviewWorkflowJson",
            "reviewWorkflowTrendsJson",
            "reviewWorkflowEventTypeFilter",
            "reviewWorkflowFindingIdFilter",
            "reviewWorkflowFindingCodeFilter",
            "reviewWorkflowFindingSectionFilter",
            "reviewWorkflowCommentStatusFilter",
            "reviewWorkflowStateFilter",
            "reviewWorkflowOverdueHoursFilter",
            "reviewWorkflowClearFiltersBtn",
        ],
    )


def test_demo_console_exposes_end_to_end_bulk_review_controls():
    body = demo_console_body()
    required_tokens = [
        "criticBulkScope",
        "criticBulkPreviewBtn",
        "criticBulkApplyBtn",
        "criticSelectedFindingIds",
        "criticCopySelectedFindingIdsBtn",
        "criticLoadFindingIdsFromWorkflowBtn",
        "criticBulkSummaryList",
        "commentBulkScope",
        "commentBulkPreviewBtn",
        "commentBulkApplyBtn",
        "commentSelectedCommentIds",
        "commentCopySelectedCommentIdsBtn",
        "commentLoadCommentIdsFromWorkflowBtn",
        "commentBulkSummaryList",
        "criticBulkActionHint",
        "criticWorkflowFilterSuggestion",
        "criticSyncWorkflowFiltersBtn",
        "commentBulkActionHint",
        "commentWorkflowFilterSuggestion",
        "commentSyncWorkflowFiltersBtn",
        "reviewWorkflowPolicyLine",
        "reviewWorkflowSuggestedActionsList",
        "reviewWorkflowPostApplySummaryList",
        "applySuggestedFindingActionBtn",
        "applySuggestedCommentActionBtn",
        "portfolioReviewWorkflowPolicyLine",
        "sendGatePill",
        "sendGateMetaLine",
        "sendGateAdvisoryLine",
        "reviewWorkflowJson",
        "renderBulkPreviewSummary",
        "collectWorkflowFindingIds",
        "collectWorkflowCommentIds",
        "updateCriticBulkActionUi",
        "updateCommentBulkActionUi",
        "describeBulkAction",
        "describeBulkScope",
        "describeCriticFilterBasis",
        "describeCommentFilterBasis",
        "describeStatusTransition",
        "renderSendGate",
        "renderSuggestedOpsActions",
        "renderPostApplySummary",
        "refreshWorkflowAfterBulkApply",
        "findingActionPresetFromQueue",
        "commentActionPresetFromQueue",
        "applySuggestedFindingActionPreset",
        "applySuggestedCommentActionPreset",
        "applyCurrentSuggestedPrimaryActionPreset",
        "sendClassificationForGoNoGo",
        "syncCriticFiltersFromWorkflow",
        "syncCommentFiltersFromWorkflow",
        "Suggested Ops Actions",
        "Post-Apply Summary",
        "No applied bulk action yet.",
        "Queue Delta",
        "currentQueueSnapshotFromCards",
        'const label = index === 0 ? "Primary" : "Follow-up";',
        "Use Suggested Finding Action",
        "Use Suggested Comment Action",
        "Copy Selected IDs",
        "Fill From Workflow View",
        "workflow filter suggestion:",
        "item severity-medium mono",
        "Scope",
        "Filter Basis",
        "Status Transition",
        "Queue Impact",
        "finding bulk action: scope=",
        "comment bulk action: scope=",
        "No bulk preview yet.",
    ]
    for token in required_tokens:
        assert token in body
    assert "reviewWorkflowExportJsonBtn" in body
    assert "reviewWorkflowExportCsvBtn" in body
    assert "reviewWorkflowTrendsBtn" in body
    assert "reviewWorkflowTrendsExportJsonBtn" in body
    assert "reviewWorkflowTrendsExportCsvBtn" in body
    assert "reviewWorkflowSlaBtn" in body
    assert "reviewWorkflowSlaHotspotsBtn" in body
    assert "reviewWorkflowSlaHotspotsTrendsBtn" in body
    assert "reviewWorkflowSlaTrendsBtn" in body
    assert "reviewWorkflowSlaProfileBtn" in body
    assert "reviewWorkflowSlaRecomputeBtn" in body
    assert "reviewWorkflowSlaExportJsonBtn" in body
    assert "reviewWorkflowSlaExportCsvBtn" in body
    assert "reviewWorkflowSlaTrendsExportJsonBtn" in body
    assert "reviewWorkflowSlaTrendsExportCsvBtn" in body
    assert "reviewWorkflowSlaHotspotsExportJsonBtn" in body
    assert "reviewWorkflowSlaHotspotsExportCsvBtn" in body
    assert "reviewWorkflowSlaHotspotsTrendsExportJsonBtn" in body
    assert "reviewWorkflowSlaHotspotsTrendsExportCsvBtn" in body
    assert "copyReviewWorkflowSlaHotspotsJsonBtn" in body
    assert "downloadReviewWorkflowSlaHotspotsJsonBtn" in body
    assert "downloadReviewWorkflowSlaHotspotsCsvBtn" in body
    assert "copyReviewWorkflowSlaHotspotsTrendsJsonBtn" in body
    assert "downloadReviewWorkflowSlaHotspotsTrendsJsonBtn" in body
    assert "downloadReviewWorkflowSlaHotspotsTrendsCsvBtn" in body
    assert "reviewWorkflowSlaHighHours" in body
    assert "reviewWorkflowSlaMediumHours" in body
    assert "reviewWorkflowSlaLowHours" in body
    assert "reviewWorkflowSlaCommentDefaultHours" in body
    assert "reviewWorkflowSlaUseSavedProfile" in body
    assert "reviewWorkflowSlaHotspotKindFilter" in body
    assert "reviewWorkflowSlaHotspotSeverityFilter" in body
    assert "reviewWorkflowSlaMinOverdueHoursFilter" in body
    assert "reviewWorkflowSlaTopLimitFilter" in body
    assert "reviewWorkflowSlaSummaryLine" in body
    assert "reviewWorkflowSlaTrendsSummaryLine" in body
    assert "reviewWorkflowSlaHotspotsList" in body
    assert "reviewWorkflowSlaHotspotsSummaryLine" in body
    assert "reviewWorkflowSlaTrendSparkline" in body
    assert "reviewWorkflowSlaTrendsList" in body
    assert "reviewWorkflowSlaHotspotsTrendSparkline" in body
    assert "reviewWorkflowSlaHotspotsTrendsSummaryLine" in body
    assert "reviewWorkflowSlaHotspotsTrendsList" in body
    assert "reviewWorkflowSlaJson" in body
    assert "reviewWorkflowSlaTrendsJson" in body
    assert "reviewWorkflowSlaHotspotsJson" in body
    assert "reviewWorkflowSlaHotspotsTrendsJson" in body
    assert "reviewWorkflowSlaProfileSummaryLine" in body
    assert "reviewWorkflowSlaProfileJson" in body
    assert "grantflow_demo_review_workflow_event_type" in body
    assert "grantflow_demo_review_workflow_finding_id" in body
    assert "grantflow_demo_review_workflow_finding_code" in body
    assert "grantflow_demo_review_workflow_finding_section" in body
    assert "grantflow_demo_review_workflow_comment_status" in body
    assert "grantflow_demo_review_workflow_state" in body
    assert "grantflow_demo_review_workflow_overdue_hours" in body
    assert "grantflow_demo_review_workflow_sla_hotspot_kind" in body
    assert "grantflow_demo_review_workflow_sla_hotspot_severity" in body
    assert "grantflow_demo_review_workflow_sla_min_overdue_hours" in body
    assert "grantflow_demo_review_workflow_sla_top_limit" in body
    assert "grantflow_demo_review_workflow_sla_use_saved_profile" in body
    assert 'params.set("finding_code",' in body
    assert 'params.set("finding_section",' in body
    assert 'params.set("workflow_state",' in body
    assert 'params.set("overdue_after_hours",' in body
    assert "buildReviewWorkflowSlaFilterQueryString" in body
    assert "/status/${encodeURIComponent(jobId)}/review/workflow" in body
    assert "/status/${encodeURIComponent(jobId)}/review/workflow/trends" in body
    assert "/status/${encodeURIComponent(jobId)}/review/workflow/sla" in body
    assert "/status/${encodeURIComponent(jobId)}/review/workflow/sla/hotspots" in body
    assert "/status/${encodeURIComponent(jobId)}/review/workflow/sla/hotspots/trends" in body
    assert "/status/${encodeURIComponent(jobId)}/review/workflow/sla/trends" in body
    assert "/status/${encodeURIComponent(jobId)}/review/workflow/sla/export" in body
    assert "/status/${encodeURIComponent(jobId)}/review/workflow/sla/hotspots/export" in body
    assert "/status/${encodeURIComponent(jobId)}/review/workflow/sla/hotspots/trends/export" in body
    assert "/status/${encodeURIComponent(jobId)}/review/workflow/sla/trends/export" in body
    assert "/status/${encodeURIComponent(jobId)}/review/workflow/sla/profile" in body
    assert "/status/${encodeURIComponent(jobId)}/review/workflow/sla/recompute" in body
    assert "finding_sla_hours" in body
    assert "default_comment_sla_hours" in body
    assert "/status/${encodeURIComponent(jobId)}/review/workflow/export" in body
    assert "/status/${encodeURIComponent(jobId)}/review/workflow/trends/export" in body
