Files
agent/scripts/verify-minis-render.mjs

24 lines
2.5 KiB
JavaScript

import assert from "node:assert/strict";
import { mkdtemp, readdir } from "node:fs/promises";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { MinisReportService, SafeWorkspace } from "../packages/harness/dist/index.js";
// Offline QA fixture only: no MCP call and no real business conclusions.
const root = await mkdtemp(join(tmpdir(), "minis-render-qa-"));
const service = new MinisReportService({ workspace: await SafeWorkspace.create(root), sessionId: "ses_renderqa", skillRoot: "/Users/wenxinduan/.codex/skills/drama-minis-diagnosis" });
const sourceId = service.recordQuery({ fixture: true }, { synthetic: true, spend: 12, revenue: 3 });
const output = await service.generate({ source_query_ids: [sourceId], data: {
title: "排版验证 · 合成测试数据(非经营报告)", report_type: "daily", period: "TEST DAY A", comparison_period: "TEST DAY B", currency: "USD", timezone: "UTC+0", data_status: "synthetic_qa",
conclusion: "此文件仅用于验证原始 Skill 渲染器、中文字体与 A4 PDF 下载链路,不代表真实账户情况。",
cards: [{ label: "投放消耗", value: "$12.00", note: "合成测试" }, { label: "D0 广告收入", value: "$3.00", note: "合成测试" }, { label: "站内广告曝光", value: "18", note: "合成测试" }],
issues: [{ priority: "P2", problem: "排版测试", evidence: "合成数值", hypothesis: "不作业务推断", action: "验证中文与图表", acceptance: "可读且无裁切" }],
funnel: [{ label: "测试曝光", value: 120, display: "120 次", basis: "合成事件", rate: "100%" }, { label: "测试点击", value: 12, display: "12 次", basis: "合成事件", rate: "10%" }, { label: "测试启动", value: 6, display: "6 人", basis: "合成用户", rate: "50%" }],
countries: [{ label: "Test Alpha", value: 8 }, { label: "Test Beta", value: 4 }], country_revenue: [{ label: "Test Alpha", value: 2 }, { label: "Test Beta", value: 1 }],
country_funnels: [], trend: [], creatives: [], footnote: "全部数据为人工构造的 QA fixture;未查询真实经营指标。",
} });
assert.equal(output.pdfStatus, "ready", output.warning);
assert.equal(output.files.length, 3);
for (const format of ["json", "html", "pdf"]) assert.ok((await service.read(output.reportId, format)).bytes.length > 0);
console.log(JSON.stringify({ status: "passed", synthetic: true, root: join(root, (await readdir(root)).find((name) => name.startsWith(".report-"))), files: output.files.map(({ format, byteSize }) => ({ format, byteSize })) }));