Repository navigation
fix: order to pdf logo print - #1132
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
The narrowly scoped asset rules avoid loader conflicts, and no blocking issues remain.
No open issues 🎉
What changed in this PR
Fixes missing invoice PDF logos by embedding the header image instead of fetching it from the CDN.
Changes:
- Inline the invoice logo and exclude it from the generic image loader.
- Update the invoice download test to expect a PNG data URI.
| File | Description |
|---|---|
| webpack.common.js | Adds isolated inline handling for the invoice logo. |
| src/actions/__tests__/sponsor-purchases-actions.test.js | Mocks the embedded logo and checks its data URI format. |
Review effort: Balanced
caseylocker
left a comment
There was a problem hiding this comment.
Looks good. I built this branch in production mode and ran it against dev, generating invoices on the 2026 OCP Global Summit purchases list, and the ticket's acceptance checks pass:
- No request to
/images/fn-invoice-header.pngfor any of the 4 invoices I generated (checked the server access log) - Ran the forced cache fetch from the ticket, then generated 3 more invoices in the same tab without reloading. Every PDF has the logo embedded at 420x171.
- No
Not valid image extensionwarning in the console - The build emits no
images/fn-invoice-header.png, and the logo is inmain_*.jsas a PNG data URI
One caveat: localhost has no Cloudflare Polish, so the forced fetch came back as HTML, not a real WebP. Since the PDF never requests that URL anymore, it shouldn't matter, but the true WebP path can only be confirmed on a Polish host.
One non-blocking ask on the test, inline below.
| })); | ||
|
|
||
| // webpack inlines this asset as a data URI, the generic png file mock would return {} | ||
| jest.mock( |
There was a problem hiding this comment.
This mocks the logo import as a data URI, so the assertion still passes if the webpack rule is removed. I reverted webpack.common.js to master and all three invoice tests stayed green. It does catch the action passing a URL directly, but it doesn't guard the actual fix. Should we add a small check that fails when the inline rule stops applying? For example, compile the logo import and assert a PNG data URI comes out with no emitted image file. Otherwise a future edit to the rule brings the bug back with CI green.
Side note: because moduleNameMapper sends every .png to fileMock.js, this jest.mock makes every image import in this test file return the logo string, not just the logo.
| }, | ||
| { | ||
| // inline the invoice logo so react-pdf never fetches it (CDN may serve WebP, react-pdf caches failures) | ||
| test: /fn-invoice-header\.png$/, |
There was a problem hiding this comment.
Nit, fine as is since the ticket allows it: the filename regex is repeated in the inline rule and in the exclude, so renaming the asset quietly falls back to file-loader. An ?inline import with a resourceQuery rule would avoid keeping the two in sync.
https://app.clickup.com/t/9014802374/86bcmmft3
Summary by CodeRabbit