Mobile Safari and WeChat drop a download started after an await. The export sheet now asks for its code on open; the click marks and downloads at once, then confirms the code in the background (confirm_report_export: edition, scope, exported_at). With no code at hand the file is exported unmarked, no error toast, and the server logs one [ops-signal] export_unmarked line (monitor threshold 3 per window, Feishu wording added). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DbBXp2Vp62Ur3C7yRWQdSq
23 lines
1.3 KiB
TypeScript
23 lines
1.3 KiB
TypeScript
// BUG-2359: the export sheet asks POST /api/report-exports for a code when it opens, then confirms
|
|
// it (or reports an unmarked file) after the click. Component tests answer those requests; every
|
|
// other fetch is left alone. `offline` makes the code request fail like a dropped network.
|
|
export const STUB_EXPORT_CODE = "0f1e2d3c4b5a69788796a5b4";
|
|
|
|
export type ExportCodeStub = { restore: () => void; bodies: Record<string, unknown>[] };
|
|
|
|
export function installReportExportCodeStub(options: { offline?: boolean } = {}): ExportCodeStub {
|
|
const original = globalThis.fetch;
|
|
const bodies: Record<string, unknown>[] = [];
|
|
globalThis.fetch = (async (input: RequestInfo | URL, init?: RequestInit) => {
|
|
if (String(input) === "/api/report-exports") {
|
|
const body = JSON.parse(String(init?.body ?? "{}")) as Record<string, unknown>;
|
|
bodies.push(body);
|
|
if (options.offline && body.action === "issue") throw new TypeError("Failed to fetch");
|
|
if (body.action === "issue") return new Response(JSON.stringify({ exportId: STUB_EXPORT_CODE }), { status: 200 });
|
|
return new Response(null, { status: body.action === "unmarked" ? 204 : 200 });
|
|
}
|
|
return original(input, init);
|
|
}) as typeof fetch;
|
|
return { restore: () => { globalThis.fetch = original; }, bodies };
|
|
}
|