import { describe, expect, it } from "vitest";

import {
  formatElapsedSeconds,
  getElapsedNotice,
  getProgressStages,
} from "../progress";

describe("progress helpers", () => {
  it("formats elapsed seconds as short Chinese text", () => {
    expect(formatElapsedSeconds(0)).toBe("0 秒");
    expect(formatElapsedSeconds(39)).toBe("39 秒");
    expect(formatElapsedSeconds(65)).toBe("1 分 5 秒");
  });

  it("uses a neutral 10-40 second expectation without naming a model", () => {
    expect(getElapsedNotice(5)).toBe("通常需要 10-40 秒，请保持页面打开。");
    expect(getElapsedNotice(45)).toBe("仍在处理中，请保持页面打开。");
    expect(getElapsedNotice(75)).toBe("耗时较长，仍在等待服务返回。");
    expect(getElapsedNotice(5)).not.toMatch(/DeepSeek|OpenAI|模型|model/i);
  });

  it("returns stage labels for analyze and optimize actions", () => {
    expect(getProgressStages("analyze").map((stage) => stage.label)).toEqual([
      "读取文章输入",
      "提取事实卡",
      "生成待确认信息",
    ]);
    expect(getProgressStages("optimize").map((stage) => stage.label)).toEqual([
      "生成优化稿",
      "质量检查",
      "等待后端步骤更新",
      "整理结果",
    ]);
  });
});
