Skip to content

🧪 Add Edge Case Tests for normalizeCardLayout#166

Open
is0692vs wants to merge 3 commits intomainfrom
jules-17319656040937975915-c9d5c1a7
Open

🧪 Add Edge Case Tests for normalizeCardLayout#166
is0692vs wants to merge 3 commits intomainfrom
jules-17319656040937975915-c9d5c1a7

Conversation

@is0692vs
Copy link
Copy Markdown
Contributor

@is0692vs is0692vs commented Apr 17, 2026

🎯 What: The testing gap in normalizeCardLayout for validating invalid inputs (null, undefined, empty object, primitive types) and missing/invalid fields on the blocks array.

📊 Coverage:

  • Tests all invalid root inputs (returns cloned default layout).
  • Tests blocks with missing id.
  • Tests blocks with duplicate IDs.
  • Tests missing column or visible field falling back to default values.
  • Validates the return output maps exactly to what is expected.

Result: Improved edge case coverage directly addressing the problem described, keeping our normalization logic fully tested.


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

Greptile Summary

normalizeCardLayout の既存テストを describe ブロックにまとめ直し、無効ルート入力・非オブジェクト要素・重複 ID・無効フィールドのフォールバックを網羅するエッジケーステストを追加した PR です。テストロジック自体は実装と合致しており、正確です。インデントの不整合、%j フォーマット時の undefined 表示、および PR 説明に記載されている「id 欠落ブロック」テストの漏れがありますが、いずれも P2 の改善提案です。

Confidence Score: 5/5

テストの追加のみで、プロダクションコードへの変更はなく、マージは安全です。

すべての指摘は P2(スタイル・補完の提案)であり、テストロジック自体は実装と正しく対応しています。ブロッカーになる問題はありません。

特に注意が必要なファイルはありません。cardLayout.test.ts のインデント整理は任意です。

Important Files Changed

Filename Overview
src/lib/tests/cardLayout.test.ts normalizeCardLayout のテストを describe ブロックで整理し、無効な入力・重複 ID・デフォルトフォールバックのエッジケースを追加。describe("toggleBlockVisibility") のインデント不揃い(既存問題)、undefined%j フォーマット、および id 欠落オブジェクトのテスト漏れという P2 課題あり。

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[normalizeCardLayout入力] --> B{オブジェクト?}
    B -- いいえ --> C[cloneDefaultCardLayout を返す]
    B -- はい --> D{blocks が配列?}
    D -- いいえ --> C
    D -- はい --> E[各 block を反復]
    E --> F{非オブジェクト?}
    F -- はい --> G[スキップ]
    F -- いいえ --> H{有効な id?}
    H -- いいえ --> G
    H -- はい --> I{重複 ID?}
    I -- はい --> G
    I -- いいえ --> J{column / visible が有効?}
    J -- いいえ --> K[デフォルト値にフォールバック]
    J -- はい --> L[ブロックを追加 & seen に記録]
    K --> L
    E --> M[未登場のデフォルトブロックを追加]
    M --> N[返す: 正規化済みレイアウト]
    L --> E
Loading
Prompt To Fix All With AI
This is a comment left during a code review.
Path: src/lib/__tests__/cardLayout.test.ts
Line: 118

Comment:
**`describe("toggleBlockVisibility")` のインデントが不揃い**

この行は 0 スペースで始まっており、外側の `describe("cardLayout utilities")` の内側(2 スペース)に収まっていません。PR がこのブロックの直前を大きく整理したため、合わせて修正しておくと読みやすくなります(既存の問題ですが今回直すのが自然なタイミングです)。

```suggestion
  describe("toggleBlockVisibility", () => {
```

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__/cardLayout.test.ts
Line: 52-65

Comment:
**`undefined``%j` でフォーマットするとテスト名が分かりにくい**

`%j` は JSON.stringify を使うため、`undefined` をフォーマットすると `"undefined"` という文字列になります(一方 `null``"null"` になります)。`%p`(pretty-format)または `%s` に変更すると、`undefined``undefined` として明示的に表示できます。

```suggestion
    ])("returns cloned default layout for invalid input: %p", (input) => {
```

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__/cardLayout.test.ts
Line: 67-82

Comment:
**`id` フィールドが欠落したオブジェクトのテストケースが未カバー**

PR 説明には「Tests blocks with missing `id`」とありますが、この `it` では `null``"string"``123`(非オブジェクト)のみをテストしており、`{ visible: false, column: "full" }` のような **`id` を持たないオブジェクト** のケースが含まれていません。実装は `!block.id` でスキップしているため、明示的なテストを追加するとカバレッジが PR 説明と一致します。

```suggestion
    it("ignores non-object items and objects missing id in blocks array", () => {
      const normalized = normalizeCardLayout({
        blocks: [
          null,
          "string",
          123,
          { visible: false, column: "full" }, // id なし
          { id: "avatar", visible: false, column: "full" },
        ],
      });
```

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

Reviews (1): Last reviewed commit: "🧪 Add Edge Case Tests for normalizeCard..." | Re-trigger Greptile

Greptile also left 3 inline comments on this PR.

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

@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:46am

@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 18 minutes and 12 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 18 minutes and 12 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: b1617794-28ec-433c-880d-9d943272a277

📥 Commits

Reviewing files that changed from the base of the PR and between 3be157d and 9d3767f.

📒 Files selected for processing (1)
  • src/lib/__tests__/cardLayout.test.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch jules-17319656040937975915-c9d5c1a7

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 enhances the test coverage for the normalizeCardLayout utility by introducing a describe block and several new test cases. These tests address edge cases such as invalid input types, non-object elements in the blocks array, duplicate block IDs, and the application of default values when properties are invalid. The feedback recommends adding a test case to ensure that objects missing an 'id' property are also filtered out.

Comment thread src/lib/__tests__/cardLayout.test.ts
Comment thread src/lib/__tests__/cardLayout.test.ts
Comment thread src/lib/__tests__/cardLayout.test.ts
Comment thread src/lib/__tests__/cardLayout.test.ts
Co-authored-by: is0692vs <135803462+is0692vs@users.noreply.github.com>
@is0692vs
Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 17, 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.

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