/** Accessibility smoke — design-system primitives expose expected ARIA roles/labels. */
import fs from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";

const DS = path.join(path.dirname(fileURLToPath(import.meta.url)), "..", "design-system");

const checks = [
  { file: "ExperienceChart.tsx", mustInclude: ['role="img"', "aria-label"] },
  { file: "ExperienceMap.tsx", mustInclude: ['role="region"', "aria-label"] },
  { file: "ExperienceTimeline.tsx", mustInclude: ['aria-label="خط زمانی"', "<time"] },
  { file: "ExperienceKanban.tsx", mustInclude: ['role="list"', "aria-label"] },
  { file: "ExperienceThemeProvider.tsx", mustInclude: ["data-experience-dir", "direction"] },
];

const errors = [];
for (const c of checks) {
  const content = fs.readFileSync(path.join(DS, c.file), "utf8");
  for (const needle of c.mustInclude) {
    if (!content.includes(needle)) {
      errors.push(`${c.file}: missing ${needle}`);
    }
  }
}

if (errors.length) {
  console.error("Experience a11y smoke failed:\n" + errors.map((e) => "  - " + e).join("\n"));
  process.exit(1);
}
console.log("experience a11y-smoke OK");
