Skip to content

test: add unit tests for buildProfile style analysis - #262

Merged
404-Page-Found merged 2 commits into
404-PF:mainfrom
Krshs90:feature/236-history-profile-tests
Aug 20, 2026
Merged

test: add unit tests for buildProfile style analysis#262
404-Page-Found merged 2 commits into
404-PF:mainfrom
Krshs90:feature/236-history-profile-tests

Conversation

@Krshs90

@Krshs90 Krshs90 commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Closes #236. This adds unit tests covering the profile-building logic including scope-usage ratio, body-usage ratio, and the empty history edge case.

Review in cubic

Summary by CodeRabbit

  • Tests
    • Expanded automated coverage for profile metrics derived from history data.
    • Added validation for scope-usage and body-usage ratios.
    • Added checks ensuring empty histories produce zero-valued profile metrics.
    • Improved test isolation by using temporary histories and restoring the test environment after execution.

@Krshs90
Krshs90 requested a review from 404-Page-Found as a code owner August 6, 2026 04:38
@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 6edadeaa-593f-4173-b030-530a35f457ef

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The test suite now validates buildProfile scope and body usage ratios. It also validates zero-valued metrics for empty histories, including commit count, imperative rate, and sentence-case rate.

Changes

Profile metric tests

Layer / File(s) Summary
Profile metric validation
tests/history-profile.test.mjs
Added tests for scoped commits, commits with bodies, and empty-history metrics. Tests verify the expected 0.5 ratios and zero defaults.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested reviewers: 404-page-found

Poem

I’m a rabbit checking commits in a row,
Scope and body rates now clearly show.
Empty histories return zeros neat,
Each profile metric stays complete.
Hop, hop—tests make the history sweet!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The tests cover scope usage, body usage, and empty history, but omit imperative-mood and common-prefix detection required by [#236]. Add assertions for imperative-mood detection and common-prefix detection using local JSONL history samples.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the added unit tests for buildProfile style analysis.
Out of Scope Changes check ✅ Passed The changes add tests directly related to buildProfile style analysis and contain no unrelated code changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 1 file

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Comment thread tests/history-profile.test.mjs Outdated

@404-Page-Found 404-Page-Found left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests mutate process-global environment variables (HOME, APPDATA, and XDG_CONFIG_HOME) around an asynchronous buildProfile() call. That can make the suite flaky if tests run concurrently or in a shared process, since other tests may observe the temporary paths. Please avoid global environment mutation by injecting the history/config path, or explicitly serialize these tests and centralize the setup/cleanup.

@Krshs90

Krshs90 commented Aug 20, 2026

Copy link
Copy Markdown
Contributor Author

Thank you for the review feedback! I have refactored ests/history-profile.test.mjs to centralize and isolate all environment setup and teardown into the withTempHome helper. This ensures process-global environment variables (HOME, APPDATA, XDG_CONFIG_HOME) and temporary directories are cleanly restored and deleted in a inally block for all tests, eliminating duplicate setup boilerplate and avoiding race conditions.

@sonarqubecloud

Copy link
Copy Markdown

@404-Page-Found 404-Page-Found left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — clean test-only PR that adds meaningful coverage for buildProfile's scope/body rates and empty-history edge case, while reducing duplication with the withTempHome helper.

@404-Page-Found
404-Page-Found merged commit 3661fc6 into 404-PF:main Aug 20, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add unit tests for buildProfile() style analysis

2 participants