fix(swads): make daily report generation resilient
This commit is contained in:
@@ -48,6 +48,14 @@ describe("HarnessClientStore reducer", () => {
|
||||
});
|
||||
|
||||
describe("generated report events", () => {
|
||||
it("adds a generated Markdown fallback when the model returned no visible report text", () => {
|
||||
const store = new HarnessClientStore(); const base = { sessionId: "ses_report", runId: "run_report", timestamp: new Date().toISOString() };
|
||||
const accountKey = "acct_0123456789abcdef01234567", reportDate = "2026-09-06", reportId = "12345678-1234-4234-8234-123456789abc";
|
||||
const url = `/api/reports/${accountKey}/${reportDate}/${reportId}`; const artifact = { accountKey, reportDate, reportId, downloads: { json: `${url}/json`, html: `${url}/html` } };
|
||||
store.reduce({ ...base, eventId: "fallback_1", sequence: 1, type: "tool.requested", payload: { toolCallId: "render", toolName: "render_swads_daily_report", arguments: {} } });
|
||||
store.reduce({ ...base, eventId: "fallback_2", sequence: 2, type: "report.generated", payload: { assistantMessageId: "assistant", artifact, markdown: "## 自动日报摘要" } });
|
||||
const content = store.getSnapshot().messages[0]?.content; expect(content).toEqual(expect.arrayContaining([{ type: "text", text: "## 自动日报摘要" }]));
|
||||
});
|
||||
it("deduplicates images and merges provisional tool messages with the correct assistant", async () => {
|
||||
vi.stubGlobal("fetch", vi.fn(async () => new Response(new Blob(["png"], { type: "image/png" }), { headers: { "content-type": "image/png" } })));
|
||||
Object.defineProperty(URL, "createObjectURL", { configurable: true, value: vi.fn(() => "blob:report-image") });
|
||||
|
||||
Reference in New Issue
Block a user