test(openui-cli): add unit tests for CLI helper functions#611
Open
Shinyaigeek wants to merge 1 commit into
Open
test(openui-cli): add unit tests for CLI helper functions#611Shinyaigeek wants to merge 1 commit into
Shinyaigeek wants to merge 1 commit into
Conversation
Add a Vitest setup for the openui-cli package covering the isolated helper functions, which previously had no test coverage. - detectPackageManager(): asserts pnpm dlx / yarn dlx / bunx / npx selection based on npm_config_user_agent, plus unset/unknown and prefix-vs-substring edge cases - resolveArgs(): provided values returned without prompting, missing required arg exits 1 when non-interactive, interactive input/select prompting (inquirer mocked), user-cancel exits 0, and unexpected prompt errors rethrow Adds a `test` script and vitest devDependency, a tsconfig.test.json matching the other packages so typed ESLint can lint the tests, and excludes test files from the tsc build so they stay out of dist/. Closes thesysdev#554 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Summary
Closes #554.
Adds a Vitest test suite for
packages/openui-cli, which previously had no test coverage, covering the two isolated helper functions called out in the issue.Tests added
src/lib/__tests__/detect-package-manager.test.ts(7 tests) —detectPackageManager()returnspnpm dlx/yarn dlx/bunx/npxbased onnpm_config_user_agent, plus edge cases (unset agent, unrecognized agent, and that matching is prefix-based rather than substring). The env var is saved/restored around each test.src/lib/__tests__/resolve-args.test.ts(8 tests) —resolveArgs():{ value }args without prompting (interactive and non-interactive)1+ logs an error on a missing required arg when non-interactiveinputandselectwhen interactive (@inquirer/promptsmocked — no real input)0) on user cancel (ExitPromptError)Supporting changes
package.json: added atestscript (vitest run) andvitestdevDependency (matching the version used bylang-core).tsconfig.test.json: added to match the convention used by the other packages so the repo's typed ESLint config can lint the test files.tsconfig.json: excluded**/__tests__/**and**/*.test.tsfrom thetscbuild so test files don't leak into the publisheddist/.Acceptance criteria
process.exitmocked)build,lint:check,format:check/ciall pass;dist/stays free of test artifacts)🤖 Generated with Claude Code