-
Notifications
You must be signed in to change notification settings - Fork 0
Add CI workflow and tests for /api/generate #22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Add a GitHub Actions workflow to run tests on push and PRs to main (Node 20, npm ci, Vitest with coverage, upload to Codecov). Add unit tests for POST /api/generate (mocks octokit and gemini) covering valid GitHub URL, invalid JSON, and non-GitHub URL scenarios. Update package.json to include test-related deps/scripts. Remove unused src/lib/prompts.ts.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📝 WalkthroughWalkthroughAdds a GitHub Actions workflow to run Node.js tests with coverage, introduces Vitest and testing libraries in package.json, and adds unit tests for the POST /api/generate endpoint that mock Octokit and external generation behavior. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 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. Comment |
Co-Authored-By: Amal Krishna <132085414+Amal-24@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
🤖 Fix all issues with AI agents
In `@__tests__/apiGenerate.test.ts`:
- Around line 5-25: Vitest can't resolve the '@/...' path used by the mocks
(e.g., vi.mock('@/lib/octokit', ...) and vi.mock('@/lib/gemini', ...)), so add a
Vitest config file named vitest.config.ts that exports a defineConfig with a
resolve.alias mapping for '@' to your project's src directory (use
path.resolve(__dirname, 'src')) so the '@' alias is resolved at test runtime;
import defineConfig from 'vitest/config' and path from 'path', export default
the config, then restart Vitest so the vi.mock calls will correctly intercept
those imports.
In @.github/workflows/test.yml:
- Around line 29-32: The Codecov upload step using codecov/codecov-action@v4
requires a CODECOV_TOKEN secret; update the workflow step that uses
codecov/codecov-action@v4 (the "Upload coverage to Codecov" step) to pass the
token from repository secrets (e.g., reference secrets.CODECOV_TOKEN) and ensure
fail_ci_if_error: true remains if you want the job to fail on upload errors;
create the CODECOV_TOKEN repo secret first if it doesn't exist and then
reference it in the action inputs so the upload succeeds.
- Around line 26-27: The CI workflow step named "Run Vitest with Coverage" runs
"npm test -- --coverage" but is missing a Vitest coverage provider dependency;
add a coverage provider (for example "@vitest/coverage-v8") to package.json
devDependencies so the "--coverage" flag won't prompt or fail in CI, and run npm
install/dev-install to ensure the provider is available before the workflow step
executes.
🧹 Nitpick comments (3)
package.json (1)
24-25: Unused dev dependencies added.
@testing-library/jest-domand@testing-library/reactare not used by any test in this PR. The only test file (__tests__/apiGenerate.test.ts) tests a Next.js API route and only imports fromvitest. Consider deferring these dependencies until you actually add component/DOM tests to avoid unnecessary install time in CI..github/workflows/test.yml (1)
3-7: Workflow won't trigger on pushes to thetestbranch.The workflow only triggers on pushes to
mainand PRs targetingmain. This is fine for the merge workflow, but during development on thetestbranch, pushes won't trigger CI. Consider whether you want CI feedback on feature branch pushes as well.__tests__/apiGenerate.test.ts (1)
27-69: Consider adding tests for other error branches.The route handler in
route.tshas several additional error paths not covered: empty/missing URL, malformed URL (not parseable), URL missing owner/repo segments, and the 500 catch block. These would be good to add for more robust coverage — especially since the CI workflow is uploading coverage metrics.
Add a GitHub Actions workflow to run tests on push and PRs to main (Node 20, npm ci, Vitest with coverage, upload to Codecov). Add unit tests for POST /api/generate (mocks octokit and gemini) covering valid GitHub URL, invalid JSON, and non-GitHub URL scenarios. Update package.json to include test-related deps/scripts. Remove unused src/lib/prompts.ts.
🚀 BΞYTΞFLʘW | Pull Request Protocol
PR Type: (Choose one:
feat|fix|refactor|docs|perf)Issue Link: Fixes #
📝 System Summary
Provide a concise brief of the changes introduced to the stream.
🛠️ Technical Changes
.........🧪 Quality Assurance (QA)
npm run buildexecuted without errors.🖼️ Visual Evidence
If this PR affects the UI, drop a screenshot or GIF below:
📡 Developer Authorization
Authorized by: @naheel0
Timestamp: {{ 11/2/2026 }}