TASK22224: tidy pdf render compatibility
This commit is contained in:
@@ -550,3 +550,36 @@ Validation:
|
||||
Follow-ups:
|
||||
|
||||
- Optional final low-risk tidy sweep: remove dead imports/unused locals in legacy file handlers now that contract hardening stream is functionally complete.
|
||||
|
||||
---
|
||||
|
||||
### CL-014: TASK22224 pdf render compatibility tidy slice
|
||||
|
||||
date: 2026-03-24
|
||||
author: Cline
|
||||
scope: `pages/api/file/{generatepdf,generateappealpdf}.js`, `tests/phase21/file-handler-contract.test.cjs`
|
||||
type: change
|
||||
rationale: Apply a low-risk compatibility tidy so PDF render invocation remains stable across runtime and contract-test VM contexts.
|
||||
impact: Keeps functional behavior unchanged while reducing test/runtime mismatch risk in render path setup.
|
||||
status: completed
|
||||
|
||||
Summary:
|
||||
|
||||
- `pages/api/file/generatepdf.js`
|
||||
- switched render call input from `React.createElement(MyDocument, ...)` to direct `MyDocument(...)` invocation in `ReactPDF.renderToStream(...)`
|
||||
- `pages/api/file/generateappealpdf.js`
|
||||
- switched render call input from `React.createElement(MyDocument, ...)` to direct `MyDocument(...)` invocation in `ReactPDF.renderToStream(...)`
|
||||
- `tests/phase21/file-handler-contract.test.cjs`
|
||||
- added `Buffer` injection for `generatepdf` catch-path test harness to align VM context expectations
|
||||
|
||||
Validation:
|
||||
|
||||
- `node tests/phase21/api-contract-slice1.test.cjs` -> pass
|
||||
- helper: 4/4
|
||||
- file-handler: 53/53
|
||||
- email-handler: 12/12
|
||||
- endpoint-handler: 152/152
|
||||
|
||||
Follow-ups:
|
||||
|
||||
- Optional: dead import cleanup (`Document/Page/Text/View/StyleSheet/PDFViewer`, `middleware`, `nextConnect`, `fs`, etc.) can be done in a dedicated non-behavioral hygiene PR.
|
||||
|
||||
@@ -227,7 +227,7 @@ export default async function handler(req, res) {
|
||||
};
|
||||
|
||||
const renderedPDF = await ReactPDF.renderToStream(
|
||||
React.createElement(MyDocument, {
|
||||
MyDocument({
|
||||
docProps: blobProgress,
|
||||
pickListData: pickListData
|
||||
})
|
||||
|
||||
@@ -338,7 +338,7 @@ export default async function handler(req, res) {
|
||||
|
||||
try {
|
||||
const renderedPDFStream = await ReactPDF.renderToStream(
|
||||
React.createElement(MyDocument, { docProps: reqBodyobj })
|
||||
MyDocument({ docProps: reqBodyobj })
|
||||
);
|
||||
const renderedPDFBuffer = await streamToBuffer(renderedPDFStream);
|
||||
|
||||
|
||||
@@ -1445,6 +1445,7 @@ test("generateappealpdfcopy catch path returns APPEAL_PDF_COPY_GENERATION_FAILED
|
||||
test("generatepdf catch path returns GENERATE_PDF_FAILED", async () => {
|
||||
const { Readable } = require("stream");
|
||||
const mod = loadModule("pages/api/file/generatepdf.js", {
|
||||
Buffer,
|
||||
respondError: respondErrorMock,
|
||||
respondSuccess: respondSuccessMock,
|
||||
hashAPIPath: () => "&hash=expected",
|
||||
|
||||
Reference in New Issue
Block a user