Skip to content

Conversation

@naheel0
Copy link
Contributor

@naheel0 naheel0 commented Feb 11, 2026

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

  • Logic change in ...
  • New UI component added: ...
  • Database schema updated: ...

🧪 Quality Assurance (QA)

  • Linting: Code style matches the BeyteFlow grid.
  • Build: npm run build executed without errors.
  • Testing: New logic has been verified and tested.
  • Dark Mode: UI is high-contrast and neon-optimized.

🖼️ Visual Evidence

If this PR affects the UI, drop a screenshot or GIF below:


📡 Developer Authorization

  • I have performed a self-review of my code.
  • My changes generate no new warnings in the console.
  • I have updated the documentation (if applicable).

Authorized by: @naheel0
Timestamp: {{ 11/2/2026 }}


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.
@naheel0 naheel0 requested a review from adithyanmkd as a code owner February 11, 2026 09:13
@naheel0 naheel0 added the ci/cd Automated workflows for building, testing, and deploying code. label Feb 11, 2026
@vercel
Copy link

vercel bot commented Feb 11, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
readme-gen-ai Ready Ready Preview, Comment Feb 11, 2026 9:28am

@coderabbitai
Copy link

coderabbitai bot commented Feb 11, 2026

Warning

Rate limit exceeded

@naheel0 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 16 minutes and 25 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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.

📝 Walkthrough

Walkthrough

Adds 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

Cohort / File(s) Summary
CI Workflow
.github/workflows/test.yml
Add GitHub Actions workflow to run tests on pushes and PRs to main, set up Node 20, install deps, run npm test -- --coverage, and upload coverage to Codecov.
Test runner & deps
package.json
Add test script (vitest run --coverage) and devDependencies: vitest, @vitest/coverage-v8, @testing-library/react, @testing-library/jest-dom.
API unit tests
__tests__/apiGenerate.test.ts
Add tests for POST /api/generate: success case with mocked Octokit/Gemini, invalid JSON body (400), and non-GitHub URL rejection (400).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

area: ai-logic, area: backend

Suggested reviewers

  • adithyanmkd

Poem

🐰
I hopped through code with tiny feet,
Added tests so builds stay neat,
CI hums and coverage gleams,
Readme dreams and testing beams,
Hop, commit — the pipeline's sweet. 🥕

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main changes: adding a CI workflow and tests for the /api/generate endpoint.
Description check ✅ Passed The description is related to the changeset, detailing the CI workflow, unit tests, package.json updates, and file removal.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch test

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Co-Authored-By: Amal Krishna <[email protected]>
Copy link

@coderabbitai coderabbitai bot left a 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-dom and @testing-library/react are 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 from vitest. 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 the test branch.

The workflow only triggers on pushes to main and PRs targeting main. This is fine for the merge workflow, but during development on the test branch, 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.ts has 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.

@naheel0 naheel0 merged commit 5f3a885 into main Feb 11, 2026
4 checks passed
@naheel0 naheel0 deleted the test branch February 11, 2026 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci/cd Automated workflows for building, testing, and deploying code.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant