Skip to content

feat(test): add "test open <test-id>" to jump from the terminal to the dashboard#226

Merged
zeshi-du merged 3 commits into
TestSprite:mainfrom
Andy00L:feat/test-open
Jul 18, 2026
Merged

feat(test): add "test open <test-id>" to jump from the terminal to the dashboard#226
zeshi-du merged 3 commits into
TestSprite:mainfrom
Andy00L:feat/test-open

Conversation

@Andy00L

@Andy00L Andy00L commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Reopens #182, which was closed by the July 9 release incident (see the
maintainer's comment there). Same branch, same commits (head bbc079f0).

What does this PR do?

Adds testsprite test open <test-id> — the CLI already computes the Portal
deep-link and prints it as text on several commands; this closes the last inch
(the gh browse / cypress open hop). The URL is ALWAYS printed to stdout
first (so headless use and piping compose), then the OS default browser is
spawned unless --no-browser. The opener uses an argv-array spawn (never a
shell 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

  • New feature (non-breaking change that adds functionality)

Checklist

  • PR targets the main branch.
  • Commits follow Conventional Commits.
  • npm run lint and npm run format:check pass.
  • npm run typecheck passes.
  • npm test passes and coverage stays at or above the 80% gate.
  • New behavior is covered by unit tests (mock-based; no network).
  • No secrets, API keys, internal endpoints, or personal data are included.

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), so
tests never spawn a real process; src/lib/browser.ts is at 100% coverage.

Andy00L added 3 commits July 6, 2026 19:04
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 zeshi-du left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!

@zeshi-du
zeshi-du merged commit 8db1882 into TestSprite:main Jul 18, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Hackathon] Add "test open <id>" / "--web" to jump from the terminal to the dashboard

2 participants