refactor(cli): route assertion-stable strings through messages.ts#371
refactor(cli): route assertion-stable strings through messages.ts#371
Conversation
Introduces `packages/cli/src/messages.ts` as a single typed `as const` object grouping user-facing copy that E2E tests assert on, so a wording tweak only needs to land in one place and tests stay green automatically. - New `messages.ts` covers cli-level (version banner prefix, usage prefix, unknown-command), auth (usage prefix, unknown-subcommand, region-prompt label, cancellation), and db (unknown-subcommand, migrate stub) handles. Scope is intentionally narrow — only strings the E2E suite asserts on. - Migrated production call sites in `bin/stash.ts`, `commands/auth/index.ts`, and `commands/auth/login.ts` to reference the constants. Strings tests don't touch (e.g. command names, schema-subcommand error, full HELP body) stay inline. - Migrated `tests/e2e/smoke.e2e.test.ts` and `tests/e2e/auth-login-cancel.e2e.test.ts` to import the same handles the production code uses. Stable phrase + token assertion pattern preserved. - Updated `packages/cli/AGENTS.md`: drops the "phase 2 planned" pointer, documents the messages-module rule (extract only what tests assert on, add to messages.ts not the test).
|
📝 WalkthroughWalkthroughThis PR centralizes user-facing CLI message strings into a new Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Review rate limit: 0/1 reviews remaining, refill in 60 minutes.Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/cli/AGENTS.md (1)
83-84:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winRemove stale “phase-2 messages module” wording.
This now conflicts with the current state (the module is implemented in this PR), so the plan section should reference it as existing, not planned.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/cli/AGENTS.md` around lines 83 - 84, Update the sentence in AGENTS.md that currently calls the "phase-2 messages module" a future/planned item so it reflects the module is implemented; locate the phrase "phase-2 messages module" and the linked docs/plans/cli-pty-integration-tests.md reference and change wording to reference the module as existing (e.g., "and the phase-2 messages module is documented in docs/plans/cli-pty-integration-tests.md" or similar), removing any "planned" or "phase-2" implication that it is not yet implemented.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@packages/cli/AGENTS.md`:
- Around line 83-84: Update the sentence in AGENTS.md that currently calls the
"phase-2 messages module" a future/planned item so it reflects the module is
implemented; locate the phrase "phase-2 messages module" and the linked
docs/plans/cli-pty-integration-tests.md reference and change wording to
reference the module as existing (e.g., "and the phase-2 messages module is
documented in docs/plans/cli-pty-integration-tests.md" or similar), removing any
"planned" or "phase-2" implication that it is not yet implemented.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 2db3f6d2-c750-45c9-855d-944a7cb078b6
📒 Files selected for processing (7)
packages/cli/AGENTS.mdpackages/cli/src/bin/stash.tspackages/cli/src/commands/auth/index.tspackages/cli/src/commands/auth/login.tspackages/cli/src/messages.tspackages/cli/tests/e2e/auth-login-cancel.e2e.test.tspackages/cli/tests/e2e/smoke.e2e.test.ts
Summary
Phase 2 of the CLI testing work (planned in
docs/plans/cli-pty-integration-tests.md). Introduces a small typed message handles module so E2E test assertions and production call sites share the exact same string constants — a copy tweak only needs to land in one place.packages/cli/src/messages.ts— singleas constobject grouped by area (cli,auth,db). Scope is deliberately narrow: only strings the E2E suite asserts on. No i18n framework, no codegen, no runtime cost.bin/stash.ts,commands/auth/index.ts,commands/auth/login.ts. Strings tests don't touch (command names, the schema-subcommand error, full HELP bodies) stay inline.tests/e2e/**import the same handles. Stable-phrase + token assertion pattern preserved (e.g.expect(out).toContain(messages.cli.unknownCommand)plus a separatetoContain('definitely-not-a-command')).packages/cli/AGENTS.mdupdated: drops the "phase 2 planned" pointer and documents the rule (add tomessages.tsonly when a test asserts on the string; don't hard-code wording in tests).Test plan
pnpm --filter @cipherstash/cli buildcleanpnpm --filter @cipherstash/cli test— 76 unit tests passpnpm --filter @cipherstash/cli test:e2e— 8 E2E tests passbiome checkclean on changed filesSummary by CodeRabbit