from __future__ import annotations

from typing import Any

from auto_test_domains.base import build_domain_report, run_pipeline_round


SUPPLIER_ID = "1ff5b102-2f9e-496c-8591-1a8e32407c7f"


def run_case(config: dict[str, Any], report_root) -> dict[str, Any]:
    """
    supplier domain 回归。

    supplier 当前只测读取/绑定，不支持 create/update/delete。
    同时借此确认 strategy 中没有通过“已绑定后直接跳过更新”来短路通过。
    """

    dataset_root = f"{config['project_root']}/tests/fixtures/auto_sync/datasource/supplier"
    common_root = f"{config['project_root']}/tests/fixtures/auto_sync/datasource/common_baseline"

    round_1 = run_pipeline_round(
        config=config,
        dataset_dir=f"{dataset_root}/round_1_bind",
        previous_dataset_dir=None,
        base_dataset_dir=common_root,
        base_dataset_files=["supplier_1.jsonl"],
        domain_name="supplier",
        round_name="round_1_bind",
        purpose="加载供应商列表并验证 supplier 绑定链路",
        required_bindings={
            "supplier": [SUPPLIER_ID],
        },
        expected_binding_pairs={
            "supplier": {SUPPLIER_ID: SUPPLIER_ID},
        },
        expected_bound_fields={
            "remote": {
                "supplier": {
                    SUPPLIER_ID: {
                        "name": "中国葛洲坝集团三峡建设工程有限公司",
                        "credit_code": "91420000615573462P",
                    }
                }
            }
        },
        coverage={
            "api": ["GET /supplier/list"],
            "notes": "supplier 为只读域，本用例验证远端加载、自动绑定和基础字段一致性。",
        },
    )

    return build_domain_report(
        domain="supplier",
        description="供应商 domain 的只读回归测试。验证 supplier 列表加载、绑定与关键字段对齐。",
        rounds=[round_1],
    )