test(cli): cover the domain command (domains, DNS, SSL)#186
Merged
Conversation
Rish-it
force-pushed
the
test/cli-domain-coverage
branch
from
July 24, 2026 02:51
8b95ea3 to
f682986
Compare
Member
|
amazing fr, goat these are important tests |
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.
Problem
The CLI test suite (#182) covered
server,token,deployment,project, and the rawapipassthrough, butdomain— the largest remaining API-shaped command, 9 subcommands spanning custom domains, DNS verification, and SSL — still has no coverage beyondtsc --noEmit. Its contracts are exactly the kind that drift silently: the per-subcommand method/path/body, theverify200-vs-422 handling, and the non-zero exits that gate scripting (verify/verify-sslexit 1 when a domain isn't verified). A refactor that repoints a route, reshapes a body, or drops an unverified-exit ships green today.Follows #181; builds on the harness merged in #182.
Summary
test/e2e/domain.test.ts(27 tests) drivesdomainCommandover the same stubbed-socket harness the rest of the suite uses — the command action and the realapi-client(URL building,/apiprefix, auth header,ApiErrormapping) run for real; onlyfetchand the config/caps seams are stubbed.GET /domains?projectId=…(project id URL-encoded), table vs JSON rows, empty result.POST /domains { projectId, hostname, isPrimary },--primarytoggles the flag, theopenship domain verify <id>next-step hint, and the{ domain, records }JSON shape.POST /domains/preview { hostname }, DNS-record table, JSON.POST /domains/:id/verifyviaapiRaw: 200 verified → exit 0; 422 (DNS not propagated) → exit 1 without throwing; json mode prints the body and does not exit; a non-422 (500) surfaces and exits 1.POST /domains/:id/primary, JSON.GET /domains/:id/records, DNS-record table, JSON.POST /domains/:id/renew, SSL status, JSON.POST /domains/:id/verify-ssl: valid → exit 0; not-valid → exit 1; json mode does not exit.POST /domains/renew-all, per-domain results table vs the "Nothing needed renewal" note, JSON.{error}is surfaced and exits 1; the bearer token is sent when logged in.Design notes
fetchStub.callsand the exit code, so they hold regardless of spinner rendering. Each test is a real regression sentinel, not a coverage number — verified by mutation: removing both unverified-exit lines fromdomain.tsfails exactly the two exit tests and nothing else.server/mail/service,domain.tshas no pre-flight login guard — when logged out it issues the request with noAuthorizationheader and lets the API reject it, rather than short-circuiting. One test pins that (request still made, no auth header, API 401 surfaced) so adding a pre-flight guard later is a deliberate, visible change. Left as-is; out of scope for a test-only PR.test/helpers/*) and vitest runner from test(cli): add a vitest suite for the CLI package #182 — no runner or dependency changes, lockfile untouched.Verification
Run twice, clean, both green:
bun run --cwd apps/cli test→ 12 files, 76 tests passed (49 prior + 27 domain) ×2bun run --cwd apps/cli lint(tsc --noEmit) → clean (exit 0)bun install --frozen-lockfile→ no changes (lockfile matches)!verified → process.exit(1)lines fails exactly theverify422 andverify-sslinvalid tests, then reverted.Reproduced against committed
HEAD: working tree matchesHEAD, full suite green.Commits
Ten atomic commits, one per subcommand plus the shared auth/error concern; each adds a self-contained
describeblock and is green in isolation:Not in scope
Commands that need a new test seam the harness doesn't yet provide:
lib/service(ssh2/dockerode) forstop/service/status, achild_processseam fordeploy/doctor/install/update, an interactive@clackstdin seam forup/wizard/reset-admin, and a$HOMEconfig-file seam forcontext/config/cache/backup/system/login/logout/init. Each seam is a separate follow-up.mail installis covered on its own branch pending #141.