Conversation
Signed-off-by: Maximilian Mayer <office@maximilianmayer.at>
Signed-off-by: Maximilian Mayer <office@maximilianmayer.at>
Signed-off-by: Maximilian Mayer <office@maximilianmayer.at>
| const context = await browser.newContext({ | ||
| ...devices['Desktop Chrome'], | ||
| locale: 'en-US', | ||
| viewport: { width: 1280, height: 900 }, |
There was a problem hiding this comment.
The current CI is showing 1.9069% difference because the committed screenshot was generated on macOS and the CI generates it on Linux.
Could we make screenshots:update and screenshots:check generate the image in the same reproducible environment? For example, both could use the same Linux/Playwright environment.
I don't think increasing the tolerance is enough here, because the PR description says that moving the signature by 20px gives only 0.24%. A tolerance high enough to accept the macOS/Linux difference could also hide real visual changes.
| import { generateScreenshot, packageRoot, screenshotPath } from './generate-screenshots.mjs' | ||
|
|
||
|
|
||
| const maxDiffRatio = 0.001 |
There was a problem hiding this comment.
Could we use a smaller viewport here, closer to the screenshot that we have in the README today?
With 1280x900 there is a lot of empty space on the sides and at the bottom. A smaller viewport would keep the screenshot more focused on the PDF and the elements.
| **[Demo](https://libresign.github.io/pdf-elements/)** · [Examples](examples/) | ||
|
|
||
| <img width="754" height="607" alt="image" src="https://github.com/user-attachments/assets/65009896-21ab-4ec5-9548-2707f8d16cdf" /> | ||
|  |
There was a problem hiding this comment.
Could you regenerate this screenshot after #107 is merged?
The current image still has the invisible action icon above the signature. Since this image will be shown in the README, I think we should avoid committing that visual issue in the final screenshot.
Signed-off-by: Maximilian Mayer <office@maximilianmayer.at>
Signed-off-by: Maximilian Mayer <office@maximilianmayer.at>
|
Thanks, makes sense. 2, 3 and 4: agreed. 4 is in the latest commit, the generated image now goes to For 1, you're right that a bigger tolerance is the wrong fix. Idea: generate inside Is that roughly what you meant or were you after something lighter? Also merged current main into the branch. The PDF.js CSP changes did not move the screenshot, still zero pixels difference locally. |
|
I think your container idea can work, but before deciding I would prefer to measure the cost. Since this check will run on pull requests, could you test both approaches in CI?
Then we can compare the workflow time and see if the extra container setup and Without measuring it in this repository, I think we would just be guessing which approach is better. |
| const currentImage = await generateScreenshot() | ||
| const current = PNG.sync.read(currentImage) | ||
|
|
||
| if (committed.width !== current.width || committed.height !== current.height) { |
There was a problem hiding this comment.
Could we also save the generated screenshot when the image dimensions are different?
Right now this throws before demo-screenshot-current.png is written to test-results/. A viewport change can cause exactly this case, so the generated image would not be available in the CI artifacts when we need to inspect it.
|
I also noticed that you updated the branch by merging For this kind of update, I suggest using rebase instead of merge. It keeps the PR history linear and avoids an extra merge commit that is only there to bring the branch up to date with A common flow would be: git fetch upstream
git rebase upstream/main
git push --force-with-leaseIf there are conflicts, resolve them during the rebase, run git rebase --continueUsing |
Closes #83.
Screenshot is now a file in the repo,
npm run screenshots:updateregenerates it andnpm run screenshots:checkcompares. The check is a step in the existing Playwright workflow, and the diff image lands intest-results/, which already gets uploaded.I went with plain scripts instead of a spec, because a test writing into the repo felt wrong: every local
test:e2ewould quietly rewrite the committed image. Put them inscripts/next to the other two. Viewport and locale come fromdevices['Desktop Chrome']so nothing is copy-pasted out of the Playwright config.Tolerance is 0.1%. Two runs here give a byte-identical file, and shifting the signature by 20px gives 0.24%, so that felt like a reasonable spot. My reference image is from macOS though and CI regenerates on Linux, so the first run might say otherwise.
One thing: the empty white box above the signature is the invisible icon from #107. If that goes in first I'll regenerate.