feat(test): add "test open <test-id>" to jump from the terminal to the dashboard#226
Merged
Merged
Conversation
openInBrowser threw a plain Error for a non-http(s) URL, which fell through the top-level handler and exited 1. Route it through localValidationError so it is classified as VALIDATION_ERROR and maps to the documented exit code 5, matching every other bad-argument path. Test asserts the exit code, not the message string.
zeshi-du
approved these changes
Jul 18, 2026
zeshi-du
left a comment
Contributor
There was a problem hiding this comment.
All the safety properties from the original #182 are preserved: argv-array spawn (never a shell string), http(s)-only scheme allowlist validated before any process spawn, rundll32 on Windows, and the async ENOENT listener degrading to a stderr hint. Dashboard URL construction reuses resolvePortalUrl byte-for-byte. Thanks @Andy00L!
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.
What does this PR do?
Adds
testsprite test open <test-id>— the CLI already computes the Portaldeep-link and prints it as text on several commands; this closes the last inch
(the
gh browse/cypress openhop). The URL is ALWAYS printed to stdoutfirst (so headless use and piping compose), then the OS default browser is
spawned unless
--no-browser. The opener uses an argv-array spawn (never ashell string) so a URL can never be shell-injected, refuses non-http(s)
schemes before any process is spawned, and is detached/unref'd so the CLI
exits immediately. A missing opener (containers, SSH) downgrades to a stderr
hint, never a failure; an endpoint with no known portal mapping is a hard
error pointing at TESTSPRITE_PORTAL_URL.
Related issue
Fixes #121
Type of change
Checklist
mainbranch.npm run lintandnpm run format:checkpass.npm run typecheckpasses.npm testpasses and coverage stays at or above the 80% gate.Notes for reviewers
Platform openers:
open(darwin),rundll32 url.dll,FileProtocolHandler(win32 — avoids
cmd /c start, whose re-parsing mangles&in URLs),xdg-open(elsewhere). The opener is injectable (runOpen's third param), sotests never spawn a real process;
src/lib/browser.tsis at 100% coverage.