← Back to Pull requests

test(utils): pin relative-time thresholds, file-size units, retry and storage #249

Closed
unknown closed this pull request without merging on Nov 25, 2026 11:07 UTC
View on GitHub
unknown unknown commented on Nov 25, 2026 10:56 UTC
Author

src/lib/utils.js had no tests. src/lib/utils.test.js adds the following:

  • formatRelativeTime: both sides of every threshold (just now, minutes, hours, yesterday, days, weeks) under a frozen clock, and the year-only-when-different date fallback;

  • formatFileSize: the 1023/1024 unit boundary and two-decimal trimming;

  • retry: it stops at the first success, makes exactly maxRetries attempts, and rethrows the last error;

  • storage: JSON round trip, with the default returned for missing or corrupt entries.
  • Mutation check: changing the yesterday bound from < to <= makes a test fail. The tests pass in both UTC and IST, and eslint is clean.

    Tests only. They were drafted with AI help (Z.ai GLM), then reviewed and run locally.

    <!-- devin-review-badge-begin -->

    ---

    <a href="https://app.devin.ai/review/mangeshraut712/assistme-virtualassistant/pull/249" target="_blank"><picture><source media="(prefers-color-scheme: dark)" srcset="https://static.devin.ai/assets/gh-devin-review-dark.svg?v=4"><img src="https://static.devin.ai/assets/gh-devin-review-light.svg?v=4" alt="Devin Review"></picture></a>
    <!-- devin-review-badge-end -->

    <!-- CURSOR_SUMMARY -->
    ---

    [!NOTE]

    Low Risk

    Test-only change with no runtime or API modifications.

    > Overview

    Adds src/lib/utils.test.js — the first automated tests for selected helpers in utils.js (no production code changes).

    > Coverage locks in formatRelativeTime with Vitest fake timers at boundary values (just now through weeks, plus date fallback with year when not current). formatFileSize checks 1024-based units and two-decimal formatting. retry asserts early success and exact attempt count / last-error behavior. storage exercises JSON get/set/remove and default values for missing or invalid localStorage entries.

    > <sup>Reviewed by Cursor Bugbot for commit a0af2e1d6de56c286c440b5b169d7315f6bd100d. Bugbot is set up for automated code reviews on this repo. Configure here.</sup>

    <!-- /CURSOR_SUMMARY -->

    Diff: 263 lines (+197 / -66) across 3 files Reviewer: mangeshraut712 Review duration: 11m
    All Vouch review confidence checks passed
    Residual risk 0.17 = Change Risk (0.44) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.44 · 263 lines diff across 3 files
    0.44
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.334
    Shallow Review Depth shallow_review_depth
    0.289
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    1 comments
    "Review active on #249"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 44.3% (MEDIUM) · Higher = larger blast radius
    44.3%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 17.5% · Safe to merge
    17.5%