Repository navigation
test(puppeteer): upload test files from the Browser Run download directory - #264
Conversation
There was a problem hiding this comment.
Superseded by the review of
dd42283c.
This review, of 865d4476
💬 Approved with comments — A clean, narrowly scoped test-build change. The only note is an optional suggestion about string rewrites that fail silently.
Findings: 1 suggestion (1 is an inline comment on the diff)
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
📋 Code Quality: 💬 1 suggestion
One optional robustness note. The new plugin matches the pattern of the existing tracing plugin.
Recommendation: 💬 Optional Nits
- [SUGGESTION] The
.replace/.replaceAllrewrites inuploadDirectoryPlugindo nothing, and say nothing, if the upstream test text changes (packages/puppeteer-cloudflare/utils/generate_worker_tests.js:141)
View full review
packages/puppeteer-cloudflare/utils/generate_worker_tests.js:140-147: the first.replacematches an exact multi-line string, newlines and indentation included. If the upstreaminput.test.tschanges its formatting, the rewrite silently does nothing and theDOM.setFileInputFilesprotocol error comes back, with no hint that the plugin is the cause. This is optional, because the tests would still fail visibly.tracingTempDirectoryPluginworks the same way.
✅ All other checks passed
🔒 Security: ✅ LGTM
The change only touches test-build tooling. It rewrites constant paths in input.test.ts and takes no external input.
📝 Documentation: ✅ LGTM
The inline comment explains why the plugin exists and why the files do not need to exist.
Reviewed commit: 865d4476
| transform(code, id) { | ||
| if (!id.endsWith('/input.test.ts')) { | ||
| return; | ||
| } |
There was a problem hiding this comment.
💬 SUGGESTION · Code Quality
The .replace/.replaceAll rewrites in uploadDirectoryPlugin do nothing, and say nothing, if the upstream test text changes
This replacement matches an exact multi-line string, including newlines and two-space indentation. If upstream input.test.ts reformats the FILE_TO_UPLOAD declaration, nothing gets rewritten and the tests fail again with the DOM.setFileInputFiles protocol error, with no hint that this plugin is the cause. You could throw when the transformed code still contains '/../assets/file-to-upload.txt', or use a regex that tolerates whitespace, so that drift shows up at build time.
There was a problem hiding this comment.
beep-boop-rui-agent-🤖 Fixed in cc553dc. Each rewrite in uploadDirectoryPlugin now throws if its pattern is not in input.test.ts. If upstream changes this text, the test build fails with the missing pattern.
I did not add the suggested check for '/../assets/file-to-upload.txt'. The upstream test "should not accept multiple files for single-file input" uses this path on purpose, so the check would always fail. A test with a changed pattern made the build fail with this message:
upload-directory: "'file-does-not-exist.txt'" not found in .../submodules/puppeteer/test/src/input.test.ts
|
npm i https://pkg.pr.new/cloudflare/browser-run/@cloudflare/puppeteer@cc553dc13cbcc9ab99beae7f739d7ab885d92b36Published by this workflow run. New pushes and reruns update this comment. |
There was a problem hiding this comment.
Superseded by the review of
cc553dc1.
This review, of dd42283c
✅ Approved — This is a small change to the test build only. The one earlier suggestion is fixed, and no new issues were found.
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
✅ All checks passed
🔒 Security: ✅ LGTM
This only changes the test build tooling. It rewrites constant paths in a test file and takes no external input.
📋 Code Quality: ✅ LGTM
The earlier suggestion is resolved. Each rewrite in uploadDirectoryPlugin in packages/puppeteer-cloudflare/utils/generate_worker_tests.js now throws if its pattern is missing from input.test.ts. Not checking '/../assets/file-to-upload.txt' is reasonable, because an upstream test uses that path on purpose.
📝 Documentation: ✅ LGTM
The inline comments explain why the plugin exists and why it fails when a pattern is missing.
Reviewed commit: dd42283c
…ctory Browser Run accepts DOM.setFileInputFiles paths only under /tmp/browser-run-downloads. The input tests used client-side paths, so 5 tests failed with a protocol error. The test build now rewrites the paths in input.test.ts to this directory. The files do not need to exist. The tests only check the name, type and events of the File that the page gets. Each rewrite throws if its pattern is not in input.test.ts. If upstream changes this text, the test build fails with the missing pattern. beep-boop-🤖
dd42283 to
cc553dc
Compare
There was a problem hiding this comment.
✅ Approved — This is a small change to the test build only. The one earlier suggestion is fixed, and no new issues were found.
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
✅ All checks passed
🔒 Security: ✅ LGTM
This only changes the test build tooling. It rewrites constant paths in a test file and takes no external input.
📋 Code Quality: ✅ LGTM
The earlier suggestion is resolved. Each rewrite in uploadDirectoryPlugin in packages/puppeteer-cloudflare/utils/generate_worker_tests.js now throws if its pattern is missing from input.test.ts. Not checking '/../assets/file-to-upload.txt' is reasonable, because an upstream test uses that path on purpose.
📝 Documentation: ✅ LGTM
The inline comments explain why the plugin exists and why it fails when a pattern is missing.
Reviewed commit: cc553dc1 — same changes as dd42283c, so this is that commit's review (no new review was run; line numbers are as of dd42283c)
Problem
The full test run on
mainfailed in 5 input tests:Failed run: https://github.com/cloudflare/browser-run/actions/runs/45219961719/job/137852100909
Browser Run accepts
DOM.setFileInputFilespaths only under/tmp/browser-run-downloads. The upstream input tests use client-side paths, so Browser Run refuses them.Change
The test build (
utils/generate_worker_tests.js) rewrites the paths ininput.test.ts:FILE_TO_UPLOADbecomes/tmp/browser-run-downloads/file-to-upload.txt.path.relative(process.cwd(), FILE_TO_UPLOAD)becomesFILE_TO_UPLOAD, so the path stays absolute.'file-does-not-exist.txt'becomes/tmp/browser-run-downloads/file-does-not-exist.txt.The files do not need to exist. These tests only check the name, type and events of the
Filethat the page gets. They passed before with paths that did not exist in the browser container. The 2 tests that read the file contents stay in the skip list.Tests fixed
ElementHandle.uploadFile > should upload the fileFileChooser.accept > should accept single fileFileChooser.accept > should be able to reset selected files with empty file listFileChooser.accept > should succeed even for non-existent filesFileChooser.accept > should error on read of non-existent filesThe other 5 tests in that run were flaky. Browser Run returned
410 Browser not running (state: unhealthy)and one test timed out. All 5 passed on retry. This PR does not change them.beep-boop-🤖