test: add SDK-to-CLI coverage audit snapshot tests#27
Draft
Conversation
Adds vitest snapshot tests that track which SDK functions the CLI imports vs what's available. Detects new endpoints, removed endpoints, and changes in CLI coverage as openapi.json evolves. Snapshots cover: - All exported SDK endpoint functions - CLI-imported SDK functions - Unused SDK functions (available but not used by CLI) - SDK imports by file (which CLI files import which functions) - Coverage metrics (total, imported, unused, percent) Co-Authored-By: romitgabani1 <romitgabani1.work@gmail.com>
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
6 tasks
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.
test: add SDK-to-CLI coverage audit snapshot tests
Summary
Adds vitest snapshot tests that track which of the 272 generated SDK endpoint functions the CLI actually imports (214, ~79% coverage) and which 59 remain unused. When
openapi.jsonchanges — endpoints added, removed, or renamed — the snapshot diffs will surface the change and whether the CLI needs updating.Changes:
packages/cli/src/__tests__/sdk-cli-coverage-audit.test.ts— 6 snapshot tests:packages/cli/package.json— addsvitestdevDependency,testandtest:updatescriptsbun.lock— updated with vitest dependency treeThis is PR 3 of 3:
Review & Testing Checklist for Human
packages/cli/package.json(branched off main). Merging the second/third will produce conflicts inpackage.jsonandbun.lock— plan the merge order accordingly.getExportedSdkFunctionsuses/^export const (\w+)\s*=/gmandgetImportedSdkFunctionsuses a regex to matchimport { ... } from '...generated/sdk.gen'. Verify these match the actual patterns insdk.gen.tsand the CLI command files. Edge cases: multi-line imports with inline comments, or future changes to@hey-api/openapi-tsoutput format could silently produce wrong results rather than failing.clientis hardcoded as the only non-endpoint export to skip. If@hey-api/openapi-tsintroduces other infrastructure exports, this filter will need updating — consider whether a more robust heuristic is preferable. Note:clientstill appears in the "CLI-imported" snapshot (tracked for completeness) but is excluded from the hard assertion that checks for non-existent SDK functions.Suggested test plan
cd packages/cli && bun run test— all 6 tests should passexport const fooBarController = ...line tosdk.gen.ts→ re-run → verify the "all SDK functions" and "unused functions" snapshots failsdk.genin a command file → re-run → verify the hard assertion (importedButMissing) failsNotes