* feat(draw-image): add SVG template render engine * feat(draw-image): add opencode plugin and tool tests * test(draw-image): add vitest unit integration e2e suite * chore(draw-image): wire CI dependabot docs and ADR * docs(handoff): set PR number * docs(handoff): fix PR number placeholder in frontmatter * fix(ci): use tempfile and trailing newline in draw-image tests --------- Co-authored-by: opencode-agent <agent@opencode.local>
33 lines
No EOL
1.2 KiB
TypeScript
33 lines
No EOL
1.2 KiB
TypeScript
import { describe, test, expect, beforeAll } from "vitest"
|
|
import { existsSync, readFileSync, rmSync, mkdirSync } from "node:fs"
|
|
import path from "node:path"
|
|
import { fileURLToPath } from "node:url"
|
|
import { spawnSync } from "node:child_process"
|
|
|
|
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
|
const DRAW_IMAGE_DIR = path.resolve(__dirname, "..")
|
|
const TMP = "/tmp/draw-image-e2e-no-icon"
|
|
|
|
beforeAll(() => {
|
|
if (existsSync(TMP)) rmSync(TMP, { recursive: true, force: true })
|
|
mkdirSync(TMP, { recursive: true })
|
|
})
|
|
|
|
function runCli(args: string[]): { status: number; stdout: string; stderr: string } {
|
|
return spawnSync("node", ["--experimental-strip-types", path.join(DRAW_IMAGE_DIR, "cli.ts"), ...args], {
|
|
encoding: "utf-8",
|
|
cwd: DRAW_IMAGE_DIR,
|
|
})
|
|
}
|
|
|
|
describe("e2e — no icon render", () => {
|
|
test("exit 0 and valid PNG without icon slot", () => {
|
|
const out = path.join(TMP, "no-icon.png")
|
|
const r = runCli(["render", "cover", "--title", "Default Brand", "--out", out])
|
|
expect(r.status, `stderr: ${r.stderr}`).toBe(0)
|
|
expect(existsSync(out)).toBe(true)
|
|
const buf = readFileSync(out)
|
|
expect(buf[0]).toBe(0x89)
|
|
expect(buf[1]).toBe(0x50)
|
|
})
|
|
}) |