import assert from "node:assert/strict";
import test from "node:test";
import { translate } from "../../shared/i18n.js";
import { approvalDisplay } from "./approval-display.js";

test("localizes app-owned approval copy and status", () => {
  const t = (key, values) => translate("ko", key, values);
  const display = approvalDisplay({
    kind: "command",
    status: "pending",
    title: "Command approval required",
    reason: "Codex requests permission to run this command.",
    reasonKey: "approval.reason.command",
    commandPreview: "Command details unavailable",
    commandPreviewKey: "approval.preview.commandUnavailable"
  }, t);

  assert.deepEqual(display, {
    title: "명령 실행 승인 필요",
    status: "승인 대기 중",
    reason: "Codex가 이 명령을 실행할 권한을 요청했습니다.",
    commandPreview: "명령 세부 정보를 확인할 수 없습니다."
  });
});

test("preserves model-provided approval reasons and command previews", () => {
  const display = approvalDisplay({
    kind: "file_change",
    status: "pending",
    reason: "Need to update the shared config",
    commandPreview: "shared/config.json"
  }, (key, values) => translate("ko", key, values));

  assert.equal(display.reason, "Need to update the shared config");
  assert.equal(display.commandPreview, "shared/config.json");
});
