Skip to content

📦 [Consolidated] PR #60, #62~#65 のテスト統合・レビュー指摘対応#61

Merged
is0692vs merged 22 commits intomainfrom
testing/year-in-review-utils-16584521533216652745
Mar 14, 2026
Merged

📦 [Consolidated] PR #60, #62~#65 のテスト統合・レビュー指摘対応#61
is0692vs merged 22 commits intomainfrom
testing/year-in-review-utils-16584521533216652745

Conversation

@is0692vs
Copy link
Contributor

@is0692vs is0692vs commented Mar 13, 2026

概要

このPRは、同じくテスト追加・テスト補強を目的とした以下5個のPRを一つのブランチにて統合(マージ)し、さらにレビューコメントで妥当だった指摘を取り込んだうえで、テスト系の変更をまとめて確認できるようにするためのものです。

統合元のPR(これらは本作業に伴いクローズ対象です):

対応した修正点 (レビュー指摘への対応)

  1. src/lib/__tests__/yearInReviewUtils.test.ts (PR 🧪 add tests for yearInReviewUtils functions #60 指摘対応)

    • ヒートマップの期待値を部分一致ではなく 7x24 の完全な二次元配列比較に変更し、空入力・有効日時・無効日時の各ケースでゼロ埋め構造まで含めて回帰を検出できるようにしました。
  2. src/lib/__tests__/yearInReviewUtils.test.ts (PR 🧪 add tests for yearInReviewUtils functions #60 指摘対応)

    • 期待値の確認に副作用的な forEach を使う書き方を避け、toEqual ベースの明示的な比較へ寄せることで、可読性と lint/レビュー観点の妥当性を両立しました。
  3. API / ライブラリのテスト追加を一本化

    • src/app/api/dashboard/stats/route.test.ts
    • src/app/api/dashboard/summary/route.test.ts
    • src/app/api/dashboard/year/route.test.ts
    • src/lib/__tests__/githubViewer.test.ts
      上記の追加を同一ブランチへ集約し、関連するテスト変更を一つのPRで確認できるよう整理しました。

確認事項

google-labs-jules bot and others added 2 commits March 13, 2026 06:29
Co-authored-by: is0692vs <135803462+is0692vs@users.noreply.github.com>
Added comprehensive test cases for buildHourlyHeatmapFromCommitDates,
getMostActiveHour, and getMostActiveDayFromCalendar. Coverage includes
happy paths, empty states, invalid date strings, and edge-case behaviors
like tie-breaking logic.

Co-authored-by: is0692vs <135803462+is0692vs@users.noreply.github.com>
@google-labs-jules
Copy link
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Co-authored-by: is0692vs <135803462+is0692vs@users.noreply.github.com>
@vercel
Copy link

vercel bot commented Mar 13, 2026

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

Project Deployment Actions Updated (UTC)
github-user-summary Ready Ready Preview, Comment Mar 14, 2026 2:25pm

@gemini-code-assist
Copy link

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the reliability of the yearInReviewUtils.ts module by introducing a comprehensive suite of unit tests. The changes ensure that key utility functions, responsible for processing commit dates and determining activity patterns, behave as expected under various conditions, including edge cases and invalid inputs.

Highlights

  • Unit Test Coverage: Added comprehensive unit tests for yearInReviewUtils.ts, which previously lacked test coverage.
  • buildHourlyHeatmapFromCommitDates: Tested initialization with empty arrays, correct bucket assignment by UTC day and hour, ignoring invalid dates, and accurate sum of occurrences.
  • getMostActiveHour: Tested behavior with empty matrices, extraction of the maximum hour, and tie-breaking logic.
  • getMostActiveDayFromCalendar: Tested correct day resolution, parsing and tracking from input, ignoring invalid entries, and tie-breaking.
  • Improved Test Coverage: Introduced 10 new robust test cases using Vitest, maintaining 100% passing tests across the project.
Changelog
  • src/lib/tests/yearInReviewUtils.test.ts
    • Added a new test file to provide complete unit test coverage for yearInReviewUtils.ts.
Activity
  • PR created automatically by Jules for task 16584521533216652745, started by @is0692vs.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@coderabbitai
Copy link

coderabbitai bot commented Mar 13, 2026

Warning

Rate limit exceeded

@is0692vs has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 18 minutes and 59 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.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 5becf3f1-c2f3-415b-8a77-d70951bc0954

📥 Commits

Reviewing files that changed from the base of the PR and between 0d69259 and 8f3ffbb.

📒 Files selected for processing (2)
  • src/lib/__tests__/yearInReviewUtils.test.ts
  • src/lib/yearInReviewUtils.ts
📝 Walkthrough

Walkthrough

ダッシュボードAPIルート(stats、summary、year)に対する包括的なテスト群と、GitHubビューア取得・年間レビュー用ユーティリティの単体テストを追加。さらに yearInReviewUtils に入力検証の防御的ロジックを追加しました。

Changes

Cohort / File(s) Summary
ダッシュボードAPI ルートテスト
src/app/api/dashboard/stats/route.test.ts, src/app/api/dashboard/summary/route.test.ts, src/app/api/dashboard/year/route.test.ts
GET エンドポイント用の包括的なテストを追加。認証欠如で 401、無効パラメータで 400、API エラーで 500、成功で 200 を検証。NextAuth セッション、fetchViewerLogin、各種データ取得をモックし呼び出し経路を検証。
ライブラリユニットテスト
src/lib/__tests__/githubViewer.test.ts, src/lib/__tests__/yearInReviewUtils.test.ts
fetchViewerLogin の成功・失敗パターンを検証するテストを追加。yearInReviewUtilities のヒートマップ構築・最頻時間・最頻曜日判定ロジック用の単体テストを追加。
ユーティリティ変更
src/lib/yearInReviewUtils.ts
getMostActiveHour に対する 7x24 ヒートマップ形式の入力検証を追加。getMostActiveDayFromCalendar でカレンダー日付を防御的に解析(無効日付を無視)するロジックを追加。
マニフェスト / パッケージ
manifest_file, package.json
マニフェスト関連と package.json に変更がある行を追加(テスト・依存の追記やメタ情報の変更を含む可能性あり)。

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 新しいテストにぴょんと飛び込む
モックの草むらで動きを確かめる
ヒートマップも、ログインも、エラーも、みんなで踊る🐾
緑のチェックが光れば安心だよ
さあ、マージの祝杯をどうぞ!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed タイトルは複数のPR統合とレビュー指摘対応という実際の変更内容を正確に反映している。
Description check ✅ Passed 説明は統合されるPR番号、対応した修正点、変更対象ファイルを詳細に記述しており、変更内容と完全に関連している。

✏️ 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 testing/year-in-review-utils-16584521533216652745
📝 Coding Plan
  • Generate coding plan for human review comments

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: is0692vs <135803462+is0692vs@users.noreply.github.com>
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds a comprehensive set of tests for yearInReviewUtils, significantly improving test coverage. The tests are well-structured and cover many important scenarios, including empty inputs and tie-breaking logic. I've identified a couple of areas where the functions under test could be made more robust against malformed input, and have suggested adding test cases to cover these scenarios.

google-labs-jules bot and others added 10 commits March 13, 2026 06:32
Added missing test coverage for `src/app/api/dashboard/year/route.ts`
including the error path when `fetchYearInReviewData` throws, as well
as the happy path, 400, and 401 scenarios to fully cover the route.

Co-authored-by: is0692vs <135803462+is0692vs@users.noreply.github.com>
Co-authored-by: is0692vs <135803462+is0692vs@users.noreply.github.com>
Fixed TypeScript error in route.test.ts by casting `mockData` using
`Awaited<ReturnType<typeof fetchYearInReviewData>>` instead of `any`
to satisfy lint rules.

Co-authored-by: is0692vs <135803462+is0692vs@users.noreply.github.com>
Co-authored-by: is0692vs <135803462+is0692vs@users.noreply.github.com>
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: 5

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/app/api/dashboard/stats/route.test.ts`:
- Around line 1-26: Add a mock for "@/lib/auth" similar to the one in
src/app/api/dashboard/year/route.test.ts so the test file that exercises GET
(and imports authOptions) won't hit import errors; specifically, add a vi.mock
call that exports a stubbed authOptions object (matching the symbol name
authOptions) before running tests so GET's imports resolve consistently with the
other test file.

In `@src/app/api/dashboard/summary/route.test.ts`:
- Around line 1-21: The tests are missing a mock for the auth options used by
the route; add a vi.mock for "@/lib/auth" that exports the authOptions object
(used by src/app/api/dashboard/summary/route.ts) and/or any helper the route
imports so authentication behavior can be simulated, then update the GET route
tests to explicitly mock getServerSession to return a valid Session for the
success path and null/undefined for the unauthenticated path asserting a 401
response; reference the GET handler and authOptions/getServerSession mocks to
locate where to wire these mocks in route.test.ts.

In `@src/app/api/dashboard/year/route.test.ts`:
- Around line 35-51: Add boundary tests for year validation in
src/app/api/dashboard/year/route.test.ts: the current test only covers a
non-numeric year, but the implementation in GET (exported GET in ./route) checks
year < 2008 and year > new Date().getUTCFullYear(); add tests that call GET with
year=2007 (expect 400), year=2008 (expect success), year=currentYear (expect
success), and year=currentYear+1 (expect 400), reusing the same getServerSession
mock and NextRequest construction pattern used in the existing invalid-year test
so behavior and assertions (response.status and response.json()) match the other
tests.
- Around line 53-95: Add a test in src/app/api/dashboard/year/route.test.ts that
mirrors the non-Error-throwing case from stats tests: mock getServerSession as
in the other tests, mock fetchYearInReviewData to reject with a non-Error value
(e.g., a string), call the route GET handler with the same NextRequest, assert
the response.status is 500 and the JSON body equals { error: "Unknown error" }
so the GET route's non-Error exception path is covered.

In `@src/lib/__tests__/githubViewer.test.ts`:
- Around line 37-56: The test calls fetchViewerLogin twice to inspect the thrown
GitHubApiError; instead, call it once into a variable (e.g., const p =
fetchViewerLogin("invalid-token")) and run multiple Jest rejects assertions
against that single promise (e.g., await
expect(p).rejects.toBeInstanceOf(GitHubApiError); await
expect(p).rejects.toHaveProperty("status", 401); await
expect(p).rejects.toHaveProperty("message", "Failed to resolve current GitHub
user")). Update the final mockFetch assertion to expect one call
(expect(mockFetch).toHaveBeenCalledTimes(1)); this keeps mockFetch,
fetchViewerLogin, and GitHubApiError as the points of reference.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 4a24f01a-8486-4ecd-8be9-91399da25b2d

📥 Commits

Reviewing files that changed from the base of the PR and between ece22a0 and a4d4f47.

📒 Files selected for processing (5)
  • src/app/api/dashboard/stats/route.test.ts
  • src/app/api/dashboard/summary/route.test.ts
  • src/app/api/dashboard/year/route.test.ts
  • src/lib/__tests__/githubViewer.test.ts
  • src/lib/__tests__/yearInReviewUtils.test.ts

@is0692vs is0692vs changed the title 🧪 Add comprehensive tests for yearInReviewUtils 📦 [Consolidated] PR #60, #62~#65 のテスト統合・レビュー指摘対応 Mar 14, 2026
is0692vs added a commit that referenced this pull request Mar 14, 2026
Co-authored-by: is0692vs <135803462+is0692vs@users.noreply.github.com>
is0692vs added a commit that referenced this pull request Mar 14, 2026
Co-authored-by: is0692vs <135803462+is0692vs@users.noreply.github.com>
is0692vs and others added 3 commits March 14, 2026 22:11
Add invalid date checks in getMostActiveDayFromCalendar
and malformed matrix checks in getMostActiveHour.

Added corresponding tests to yearInReviewUtils.test.ts.

Co-authored-by: is0692vs <135803462+is0692vs@users.noreply.github.com>
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: 7

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/app/api/dashboard/stats/route.test.ts`:
- Around line 135-152: Add a test case that covers the failure path where
fetchViewerLogin rejects: mock getServerSession to return a session with no
user.login and accessToken "mock-token", mock fetchViewerLogin to reject (e.g.,
throw), and ensure fetchCommitActivityHeatmap is not called and the route
handler GET returns a 500 response; reference the existing test structure using
GET, getServerSession, fetchViewerLogin, fetchCommitActivityHeatmap, and
createRequest so the new it("should return 500 when fetchViewerLogin fails",
...) follows the same pattern and assertions for status and call expectations.

In `@src/app/api/dashboard/summary/route.test.ts`:
- Around line 62-87: Add a new test in route.test.ts that simulates
fetchViewerLogin rejecting and asserts GET returns a 500; mock getServerSession
to return an accessToken (as in the existing test), mock
vi.mocked(fetchViewerLogin).mockRejectedValueOnce(new Error("something")) and
ensure fetchUserSummary is not called, then call GET(), assert response.status
=== 500 and optionally assert error shape/message; use the same imports/mocking
pattern as the existing "returns summary using fetchViewerLogin if session user
login is missing" test so symbols to edit are GET, getServerSession,
fetchViewerLogin, and fetchUserSummary.

In `@src/app/api/dashboard/year/route.test.ts`:
- Around line 167-188: Add a test that covers the fallback path when
getServerSession returns a session without user.login: mock getServerSession to
return accessToken but no user.login, mock fetchViewerLogin (from
"@/lib/githubViewer") to resolve to a login string, and assert that
fetchViewerLogin is called with the session.accessToken and that
fetchYearInReviewData (from "@/lib/githubYearInReview") is subsequently called
with the resolved login; then call GET(req) and verify the response is 200 and
contains the mocked data. Ensure you reference the existing symbols
getServerSession, fetchViewerLogin, fetchYearInReviewData, and GET when adding
assertions and mocks.

In `@src/lib/__tests__/githubViewer.test.ts`:
- Around line 2-3: Replace the relative imports in the test with the project
alias: change import { fetchViewerLogin } from "../githubViewer" to import {
fetchViewerLogin } from "@/lib/githubViewer" and change import { GitHubApiError
} from "../types" to import { GitHubApiError } from "@/lib/types"; ensure the
module specifiers use the "@/..." alias (matching tsconfig/webpack settings) so
imports resolve from src.

In `@src/lib/__tests__/yearInReviewUtils.test.ts`:
- Around line 51-54: Add tests for non-finite values so getMostActiveHour
returns 0 for heatmaps containing NaN or Infinity: update
src/lib/__tests__/yearInReviewUtils.test.ts to include cases like
getMostActiveHour([[NaN, 1, 2]]) and getMostActiveHour([[1, Infinity, 2]]) (and
any nested/malformed shapes you already test) and assert they return 0; this
ensures the Number.isFinite branch in getMostActiveHour is covered and prevents
regressions.
- Around line 3-6: Update the import of buildHourlyHeatmapFromCommitDates,
getMostActiveHour, and getMostActiveDayFromCalendar to use the project `@/` path
alias instead of a relative import; locate the import that currently references
"../yearInReviewUtils" and replace it with the corresponding `@/` alias import
from the src tree (e.g., "@/lib/yearInReviewUtils") so all src imports in this
test file use the `@/` alias.

In `@src/lib/yearInReviewUtils.ts`:
- Around line 16-22: The current isValidHeatmap check can throw a TypeError when
a heatmap row is not an array because row.every is invoked unguarded; update the
validation used by isValidHeatmap so that it verifies heatmap is an array of
length 7 and each row passes Array.isArray(row) && row.length === 24 and then
uses row.every(count => Number.isFinite(count)); ensure this guarded check (used
where isValidHeatmap is computed) returns false for any non-array row so the
existing fallback return 0 remains safe.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: cfe51688-6cf9-4706-a438-40a4fda0f1fc

📥 Commits

Reviewing files that changed from the base of the PR and between a4d4f47 and 0d69259.

📒 Files selected for processing (6)
  • src/app/api/dashboard/stats/route.test.ts
  • src/app/api/dashboard/summary/route.test.ts
  • src/app/api/dashboard/year/route.test.ts
  • src/lib/__tests__/githubViewer.test.ts
  • src/lib/__tests__/yearInReviewUtils.test.ts
  • src/lib/yearInReviewUtils.ts

Add NaN/Infinity edge case assertions to yearInReviewUtils tests
and harden getMostActiveHour matrix validation with Array.isArray
and Number.isFinite checks.

Also updated test imports to use the project @/ alias consistently.

Co-authored-by: is0692vs <135803462+is0692vs@users.noreply.github.com>
@is0692vs
Copy link
Contributor Author

@coderabbitai review

@coderabbitai
Copy link

coderabbitai bot commented Mar 14, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Add NaN/Infinity edge case assertions to yearInReviewUtils tests
and harden getMostActiveHour matrix validation with Array.isArray
and Number.isFinite checks.

Also updated test imports to use the project @/ alias consistently.

Co-authored-by: is0692vs <135803462+is0692vs@users.noreply.github.com>
…52745

# Conflicts:
#	.github/copilot-instructions.md
@is0692vs is0692vs merged commit 78b1939 into main Mar 14, 2026
7 checks passed
@is0692vs is0692vs deleted the testing/year-in-review-utils-16584521533216652745 branch March 14, 2026 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant