Skip to content

🧪 Add tests for default card settings loading and layout normalization#173

Open
is0692vs wants to merge 4 commits intomainfrom
fix-test-coverage-11670068293511897604
Open

🧪 Add tests for default card settings loading and layout normalization#173
is0692vs wants to merge 4 commits intomainfrom
fix-test-coverage-11670068293511897604

Conversation

@is0692vs
Copy link
Copy Markdown
Contributor

@is0692vs is0692vs commented Apr 17, 2026

🎯 What: The testing gap addressed: Missing tests for default card settings loading and robustness against semantically invalid JSON structures in localStorage.
📊 Coverage: Added test cases for layout normalization handling semantically invalid but valid-JSON layouts (e.g., missing blocks or incorrect column types).
Result: Improved test coverage and reliability for loadCardSettings by applying normalizeCardLayout from cardLayout.ts.


PR created automatically by Jules for task 11670068293511897604 started by @is0692vs

Greptile Summary

loadCardSettings が localStorage から取得したレイアウトに normalizeCardLayout を適用し、意味的に不正なJSON構造(未知のブロックIDや無効な column 値)を自動修正するよう変更されました。テストファイルも同様に更新され、新しいカバレッジが追加されています。残る指摘はすべてスタイル面(インデントの乱れ・型アサーションで使用する型の誤り・テスト間の空行欠落)で、機能的な問題はありません。

Confidence Score: 5/5

機能的な問題はなく、マージ可能です。

すべての指摘はP2(スタイル・型アサーションの誤り・空行欠落)であり、ランタイムの動作には影響しません。cardSettings.ts の変更は正確で、正規化ロジックも既存の normalizeCardLayout を再利用しているため安全です。

src/lib/tests/cardSettings.test.ts — インデントと型アサーションのスタイル修正が推奨されます。

Important Files Changed

Filename Overview
src/lib/tests/cardSettings.test.ts テストカバレッジを拡充し、意味的に不正なレイアウト構造の正規化を検証する新テストを追加。ただしインデントの乱れ・型アサーションの誤り・空行欠落の3点あり。
src/lib/cardSettings.ts loadCardSettings が localStorage から読み取ったレイアウトに normalizeCardLayout を適用するよう変更。ガード条件も正しく、変更はクリーン。

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[loadCardSettings 呼び出し] --> B{window が存在するか?}
    B -- いいえ --> C[DEFAULT_CARD_LAYOUT + DEFAULT_DISPLAY_OPTIONS を返す]
    B -- はい --> D[localStorage から card-layout を取得]
    D --> E{safeParse 成功?}
    E -- いいえ / null --> F[DEFAULT_CARD_LAYOUT を使用]
    E -- はい --> G[normalizeCardLayout 適用\n不正IDを除去 / 欠損ブロックを補完 / 無効columnを修正]
    F --> H[localStorage から card-display-options を取得]
    G --> H
    H --> I{safeParse 成功?}
    I -- いいえ / null --> J[DEFAULT_DISPLAY_OPTIONS を使用]
    I -- はい --> K[DEFAULT_DISPLAY_OPTIONS にマージ]
    J --> L[layout + options を返す]
    K --> L
Loading
Prompt To Fix All With AI
This is a comment left during a code review.
Path: src/lib/__tests__/cardSettings.test.ts
Line: 8-12

Comment:
**インデントの乱れ**

`getItemMock` の宣言(8行目)と初期化(12行目)に余分なスペースが混入しています。周囲の `setItemMock` や他の変数は正しい4スペースインデントを使用しているため、このPRで`originalWindow`の削除と同時に誤ったスペースが残ってしまった状態です。

How can I resolve this? If you propose a fix, please make it concise.

---

This is a comment left during a code review.
Path: src/lib/__tests__/cardSettings.test.ts
Line: 146

Comment:
**型アサーションで誤った型を使用**

`b.id``CardBlockId``types.ts` 由来)ですが、アサーション先が `CardBlockType``cardOptions.ts` 由来)になっています。2つは別の型です。`CardBlockType` のインポートはこの1行のためだけに追加されており、正しい型は `CardBlockId` を使うべきです。

How can I resolve this? If you propose a fix, please make it concise.

---

This is a comment left during a code review.
Path: src/lib/__tests__/cardSettings.test.ts
Line: 123-124

Comment:
**テストケース間の空行が抜けている**

直前のテストの `});` の直後に空行なく新しいテストが続いています。他のテストケースはすべて空行で区切られているため、可読性を合わせるために1行追加することを推奨します。

How can I resolve this? If you propose a fix, please make it concise.

Reviews (1): Last reviewed commit: "🧪 fix(cardSettings): apply layout norma..." | Re-trigger Greptile

Greptile also left 3 inline comments on this PR.

…and improve test coverage

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

vercel bot commented Apr 17, 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 Apr 17, 2026 8:48am

@google-labs-jules
Copy link
Copy Markdown
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.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 17, 2026

Warning

Rate limit exceeded

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

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 11 minutes and 26 seconds.

⌛ 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: 93d4137b-3fc5-4d73-a973-fcb7039cb6c1

📥 Commits

Reviewing files that changed from the base of the PR and between 3be157d and 666a6de.

📒 Files selected for processing (2)
  • src/lib/__tests__/cardSettings.test.ts
  • src/lib/cardSettings.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-test-coverage-11670068293511897604

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.

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown

@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 implements layout normalization when loading card settings from local storage by integrating the normalizeCardLayout function into loadCardSettings. The test suite has been updated to include a new test case for semantically invalid layout structures and to ensure existing tests align with the normalization logic. Feedback suggests replacing the CardBlockType import and type cast with CardBlockId in the test file to correctly match the layout block property types.

Comment thread src/lib/__tests__/cardSettings.test.ts
Comment thread src/lib/__tests__/cardSettings.test.ts
Comment thread src/lib/__tests__/cardSettings.test.ts Outdated
Comment thread src/lib/__tests__/cardSettings.test.ts
Comment thread src/lib/__tests__/cardSettings.test.ts
google-labs-jules bot and others added 2 commits April 17, 2026 08:39
…and improve test coverage

Co-authored-by: is0692vs <135803462+is0692vs@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…and improve test coverage

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