// 사이트 테스트에서 fixture 렌더와 주소 수집을 마친 뒤 호출합니다.
// fieldDefinitions에는 flexible_content의 layouts도 그대로 전달합니다.
// 계약 컨테이너의 자식 주소는 실제 행 __layout에 맞는 정의로 검증됩니다.
// 운영 렌더에는 연결하지 않습니다. 클릭·포커스 도달 검사는 별도로 실행합니다.
import {
  coverageReport,
  type CoverageContract,
  type CoverageException,
  type CoverageObservations,
} from "@roottale/cms-core/visual-edit";

export function checkSiteEditCoverage(
  contract: CoverageContract,
  observations: CoverageObservations,
  exceptions: readonly CoverageException[],
) {
  const report = coverageReport(contract, observations, exceptions);
  if (report.missingFields.length || report.invalidAddresses.length
    || report.invalidSections.length || report.invalidExceptions.length) {
    throw new Error(`편집 주소 커버리지 실패: ${JSON.stringify(report)}`);
  }
  return report;
}
