Test graph PDF output with more than 1000 points - #3988
lorenzozanee wants to merge 2 commits into
Conversation
|
T4rk1n
left a comment
There was a problem hiding this comment.
This doesn't fix #3889 and the test would pass on dev as-is, so it can't guard against the bug. The 1000-point cutoff in the issue comes from px.line: with render_mode="auto", plotly express switches to scattergl once you pass 1000 rows (px.line(x=range(1001), y=range(1001)).data[0].type == "scattergl"). So the actual bug is about WebGL canvas content not making it into print or html2canvas output. This test hardcodes type: "scatter", which renders SVG at any point count, and it uses Chrome native print, which the issue already says works. I'd block on this: please drop the Fixes #3889 line. Either turn this into a real repro (scattergl, checking the printed output) or close it and leave the issue open.
| app.layout = dcc.Graph( | ||
| id="graph", | ||
| figure={ | ||
| "data": [{"type": "scatter", "mode": "lines", "x": points, "y": points}], |
There was a problem hiding this comment.
type: "scatter" never goes down the path that breaks. 1000 and 1001 points both render as SVG, so the parametrize doesn't test the threshold at all. The switch at 1001 happens because px picks scattergl. Can you use scattergl (or build the figure with px.line) so the test hits the WebGL path?
|
|
||
| driver.execute_cdp_cmd("Emulation.setEmulatedMedia", {"media": "print"}) | ||
| pdf = driver.execute_cdp_cmd( | ||
| "Page.printToPDF", {"printBackground": True, "preferCSSPageSize": True} |
There was a problem hiding this comment.
The issue says Chrome's native print works fine at 2000 points. The failing cases are Firefox print and html2pdf/html2canvas. A Chrome Page.printToPDF check passes whether the bug is there or not. What case is this meant to fail on?
| ) | ||
|
|
||
| pdf_bytes = base64.b64decode(pdf["data"]) | ||
| assert pdf_bytes.startswith(b"%PDF") |
There was a problem hiding this comment.
These assertions don't look at what got printed. Any page makes a PDF with a %PDF header that's over 1000 bytes, and the is_displayed() check reads the live DOM, not the PDF. An empty plot in the PDF (the reported symptom) passes all three. If you want to test print output, can you render the PDF, or a canvas snapshot of the graph, and check that the trace pixels are there?



Adds a deterministic browser integration fixture for 1000 and 1001 point graphs. The test emulates print media and exercises Chrome Page.printToPDF while preserving the existing graph and browser-log assertions.
The assertion verifies a valid non-empty PDF and a visible SVG trace; it does not inspect rendered PDF pixels, so cross-browser validation remains for CI and maintainers.
Contributor Checklist
optionals
CHANGELOG.mdFixes #3889