test(ui): cover the file-upload path (backend contract + frontend flow)#173
Merged
Conversation
The "upload failed: Failed to fetch" surfaced because no test exercised the upload path: the Playwright specs only used "current folder" (no upload), and the web server's /upload endpoint had no standalone test. Close both gaps. - server.py: OUTPUT_DIR is now overridable via SBOM_OUTPUT_DIR (default unchanged), so the server can run standalone for testing. - tests/test-web-ui.sh: No-Docker contract test — runs server.py standalone and checks /capabilities, /results, the /upload round-trip (token + file saved under .uploads/<token>/, bad-kind 400, wrong-extension 415), /file traversal guard, and /git-cred. Wired into the CI postprocess job. - Playwright upload.spec.ts: drives the ZIP-upload UI flow (select source, attach a file, run) and asserts it posts to /upload then renders the result; plus a failed-upload case that surfaces the error instead of scanning.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes the testing gap that let "upload failed: Failed to fetch" slip through: no test exercised the upload path. The Playwright specs only used "current folder" (no upload), and the web server's
/uploadendpoint had no standalone test.Changes
server.py:OUTPUT_DIRis now overridable viaSBOM_OUTPUT_DIR(default/host-outputunchanged), so the server can run standalone for testing.tests/test-web-ui.sh(new, No-Docker, CI postprocess job): runsserver.pystandalone and checks/capabilities,/results, the/uploadround-trip (token returned + file saved under.uploads/<token>/, unknown-kind → 400, wrong-extension → 415), the/filetraversal guard, and/git-cred.upload.spec.ts(new Playwright): drives the ZIP-upload UI flow — select source, attach a file, run — and asserts it posts to/uploadthen renders the result (no "Failed to fetch"); plus a failed-upload case that surfaces the error instead of scanning.Verification
bash tests/test-web-ui.sh→ 9 passed.npm run test:ui→ 6 passed (4 vendored + 2 upload). shellcheck clean.This is part (a) of the follow-up to the upload bug; part (b) — reducing mis-attribution noise on real full uploads — follows separately.