1
0

release-notes.spec.mjs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import { describe, expect, it } from "vitest"
  2. import { execFileSync } from "node:child_process"
  3. import { mkdtempSync, readFileSync } from "node:fs"
  4. import { tmpdir } from "node:os"
  5. import { join } from "node:path"
  6. import { buildCurrentReleaseNotes } from "./release-notes.mjs"
  7. describe("release notes for updater manifest", () => {
  8. it("uses the full Chinese changelog for the current package version", async () => {
  9. const notes = await buildCurrentReleaseNotes()
  10. expect(notes).not.toMatch(/^QMAI [\d.]+ 发布版本$/)
  11. expect(notes).toContain("1. ")
  12. const lines = notes.split("\n").filter((line) => line.trim().length > 0)
  13. expect(lines.length).toBeGreaterThan(0)
  14. for (const line of lines) {
  15. expect(line).toMatch(/^\d+\. /)
  16. }
  17. expect(notes).not.toContain(".codex-temp")
  18. })
  19. it("can write release notes directly to a UTF-8 file for CI scripts", () => {
  20. const outDir = mkdtempSync(join(tmpdir(), "qmai-release-notes-"))
  21. const outPath = join(outDir, "release-notes.txt")
  22. execFileSync(process.execPath, ["scripts/release-notes.mjs", "2.1.0", "--out", outPath], {
  23. cwd: process.cwd(),
  24. stdio: "pipe",
  25. })
  26. const notes = readFileSync(outPath, "utf8")
  27. expect(notes).toContain("黄金三章")
  28. expect(notes).toContain("AI 审查")
  29. expect(notes.split("\n")).toHaveLength(18)
  30. })
  31. })