Skip to content

🧹 fix: remove any type usage in LayoutEditor.test.tsx#282

Closed
is0692vs wants to merge 1 commit into
mainfrom
fix/layout-editor-test-types-12368610608645337347
Closed

🧹 fix: remove any type usage in LayoutEditor.test.tsx#282
is0692vs wants to merge 1 commit into
mainfrom
fix/layout-editor-test-types-12368610608645337347

Conversation

@is0692vs
Copy link
Copy Markdown
Contributor

@is0692vs is0692vs commented May 22, 2026

🎯 What: Removed the usage of any type and @typescript-eslint/no-explicit-any comments in src/components/__tests__/LayoutEditor.test.tsx by introducing a concrete MockWindow interface.
💡 Why: Relying on any bypasses TypeScript's safety features and clutters the code with eslint-disable comments. Providing a strictly typed mock interface improves maintainability and robustness without affecting runtime execution.
Verification: Ran npm run lint and npm run test -- src/components/__tests__/LayoutEditor.test.tsx. All tests pass perfectly and the linter no longer complains about the explicit any types.
Result: A cleaner test file fully compliant with strict TypeScript rules.


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

Greptile Summary

テストファイル LayoutEditor.test.tsx から any 型と @typescript-eslint/no-explicit-any コメントを削除し、MockDragEvent 型と MockWindow インターフェースを導入することで型安全性を向上させました。

  • (window as any)(window as unknown as MockWindow) に置き換え、window 拡張に具体的な型を付与。
  • triggerDragEnd 変数の取得箇所でも同様の変換を実施し、非 null アサーション (!) を使用。

Confidence Score: 4/5

テストファイルのみの変更で、ランタイム動作に影響なし。全テストが引き続きパスする。

DndContext モックの onDragEndunknown のままで不要なキャストが残っている点はあるが、テストロジックには影響しない。スタイル面の軽微な残件があるものの、マージして問題ない変更内容。

特に注意が必要なファイルはなし。変更はすべてテストファイル 1 件のみ。

Important Files Changed

Filename Overview
src/components/tests/LayoutEditor.test.tsx any 型と eslint-disable コメントを削除し、MockDragEvent / MockWindow インターフェースを導入。DndContext モックの onDragEnd が依然 unknown 型のため不要なキャストが残っているが、テストの動作に影響なし。

Comments Outside Diff (1)

  1. src/components/__tests__/LayoutEditor.test.tsx, line 23-27 (link)

    P2 DndContext モックの onDragEnd パラメータがまだ unknown 型のままで、直後に as (event: MockDragEvent) => void でキャストしています。MockDragEvent を直接使えば、このキャストは不要になります。

    Prompt To Fix With AI
    This is a comment left during a code review.
    Path: src/components/__tests__/LayoutEditor.test.tsx
    Line: 23-27
    
    Comment:
    `DndContext` モックの `onDragEnd` パラメータがまだ `unknown` 型のままで、直後に `as (event: MockDragEvent) => void` でキャストしています。`MockDragEvent` を直接使えば、このキャストは不要になります。
    
    
    
    How can I resolve this? If you propose a fix, please make it concise.
Prompt To Fix All With AI
Fix the following 2 code review issues. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 2
src/components/__tests__/LayoutEditor.test.tsx:23-27
`DndContext` モックの `onDragEnd` パラメータがまだ `unknown` 型のままで、直後に `as (event: MockDragEvent) => void` でキャストしています。`MockDragEvent` を直接使えば、このキャストは不要になります。

```suggestion
    DndContext: ({ children, onDragEnd }: { children: React.ReactNode; onDragEnd: (event: MockDragEvent) => void }) => (
      <div data-testid="dnd-context" onClick={() => {
        // Expose a way to trigger onDragEnd via a synthetic event or global for testing
        // We'll attach it to window for easy triggering
        (window as unknown as MockWindow).triggerDragEnd = onDragEnd;
```

### Issue 2 of 2
src/components/__tests__/LayoutEditor.test.tsx:12-18
`MockWindow` インターフェース定義の後に空行が2行連続しています。1行に統一するとスタイルが揃います。

```suggestion
interface MockWindow {
  triggerDragEnd?: (event: MockDragEvent) => void;
  mockIsOverId?: string;
}

// Mock dnd-kit components
```

Reviews (1): Last reviewed commit: "🧹 fix(tests): remove any type and eslin..." | Re-trigger Greptile

Greptile also left 1 inline comment on this PR.

….tsx

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 May 22, 2026

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
github-user-summary Ignored Ignored May 22, 2026 6:55am

@qodo-code-review
Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 22, 2026

Review Change Stack

📝 Walkthrough

Summary by CodeRabbit

  • Tests
    • テスト の内部インフラストラクチャを改善しました。型安全性と保守性が向上しています。

注:このリリースに はユーザー向けの機能変更や改善はございません。

Walkthrough

LayoutEditor テストの window モック参照を型安全化するため、MockWindow インターフェイスを導入し、dnd-kit モックセットアップと全テストケース内の型キャストを統一する変更。

Changes

LayoutEditor テスト型安全性改善

Layer / File(s) Summary
MockWindow インターフェイス定義とモック設定
src/components/__tests__/LayoutEditor.test.tsx
triggerDragEndmockIsOverId プロパティを持つ MockWindow インターフェイスを追加。DndContext モックと useDroppable モックでこのインターフェイス経由の明示的な型キャストに変更し、beforeEach でのリセット処理も統一。
テストケース内の型キャスト置換
src/components/__tests__/LayoutEditor.test.tsx
複数のテストケース内で triggerDragEnd を取得する際の型キャストを window as any から window as MockWindow に統一。over null、同一 id、over ブロック未検出、下方向ドラッグ、空カラムのテストケースを含む。

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Suggested labels

size/XS

Poem

🐰 モック型も安全に整え、
MockWindow の道を歩み、
any から逃げて安心。
テスト堅牢、バグ少なし!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed PR タイトルは any 型の削除というファイル内容と関連性があり、主な変更内容を的確に要約しています。
Description check ✅ Passed PR 説明は MockWindow インターフェイス導入による any 型削除という実装内容と完全に関連しており、目的と検証方法も明記されています。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/layout-editor-test-types-12368610608645337347

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.

@coderabbitai coderabbitai Bot added the size/XS label May 22, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Comment on lines +12 to 18
interface MockWindow {
triggerDragEnd?: (event: MockDragEvent) => void;
mockIsOverId?: string;
}


// Mock dnd-kit components
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.

P2 MockWindow インターフェース定義の後に空行が2行連続しています。1行に統一するとスタイルが揃います。

Suggested change
interface MockWindow {
triggerDragEnd?: (event: MockDragEvent) => void;
mockIsOverId?: string;
}
// Mock dnd-kit components
interface MockWindow {
triggerDragEnd?: (event: MockDragEvent) => void;
mockIsOverId?: string;
}
// Mock dnd-kit components
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/components/__tests__/LayoutEditor.test.tsx
Line: 12-18

Comment:
`MockWindow` インターフェース定義の後に空行が2行連続しています。1行に統一するとスタイルが揃います。

```suggestion
interface MockWindow {
  triggerDragEnd?: (event: MockDragEvent) => void;
  mockIsOverId?: string;
}

// Mock dnd-kit components
```

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

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Copy link
Copy Markdown

@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: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/components/__tests__/LayoutEditor.test.tsx`:
- Line 36: The test mock for useDroppable currently sets isOver at module-load
time causing it to always be false; change the mock definition so isOver is a
getter evaluated at runtime (e.g. define isOver as a get accessor that returns
(window as unknown as MockWindow).mockIsOverId === id or use
Object.defineProperty to define a dynamic getter) so tests can toggle
MockWindow.mockIsOverId in beforeEach and observe isOver changes; update the
useDroppable mock where isOver is assigned and reference the MockWindow,
mockIsOverId, and id symbols in the change.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 188b722f-dce0-47fa-8c5c-1f07fdb92781

📥 Commits

Reviewing files that changed from the base of the PR and between 4020bb3 and 900b0f2.

📒 Files selected for processing (1)
  • src/components/__tests__/LayoutEditor.test.tsx

setNodeRef: vi.fn(),
// eslint-disable-next-line @typescript-eslint/no-explicit-any
isOver: (window as any).mockIsOverId === id,
isOver: (window as unknown as MockWindow).mockIsOverId === id,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

isOver がモック定義時に評価されるため、常に false になります。

isOver の値は useDroppable モックが定義される時点(モジュールロード時)で評価されますが、その時点では mockIsOverId はまだ undefined です(beforeEach で設定されるため)。結果として isOver は常に false となり、isOver の振る舞いをテストできません。

ランタイムで評価されるようにゲッターを使用してください。

🔧 ゲッターを使った修正案
     useDroppable: ({ id }: { id: string }) => ({
       setNodeRef: vi.fn(),
-      isOver: (window as unknown as MockWindow).mockIsOverId === id,
+      get isOver() {
+        return (window as unknown as MockWindow).mockIsOverId === id;
+      },
     }),
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
isOver: (window as unknown as MockWindow).mockIsOverId === id,
useDroppable: ({ id }: { id: string }) => ({
setNodeRef: vi.fn(),
get isOver() {
return (window as unknown as MockWindow).mockIsOverId === id;
},
}),
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/components/__tests__/LayoutEditor.test.tsx` at line 36, The test mock for
useDroppable currently sets isOver at module-load time causing it to always be
false; change the mock definition so isOver is a getter evaluated at runtime
(e.g. define isOver as a get accessor that returns (window as unknown as
MockWindow).mockIsOverId === id or use Object.defineProperty to define a dynamic
getter) so tests can toggle MockWindow.mockIsOverId in beforeEach and observe
isOver changes; update the useDroppable mock where isOver is assigned and
reference the MockWindow, mockIsOverId, and id symbols in the change.

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 improves type safety in the LayoutEditor tests by replacing 'any' casts and ESLint suppressions with a dedicated MockWindow interface and MockDragEvent type. These changes provide better structure for mocking dnd-kit behavior on the global window object. I have no further feedback to provide.

@is0692vs
Copy link
Copy Markdown
Contributor Author

Superseded by #299, which keeps the same LayoutEditor test cleanup scope with passing checks and no active review threads. Closing this duplicate to keep the open PR queue actionable.

@is0692vs is0692vs closed this May 24, 2026
@google-labs-jules
Copy link
Copy Markdown
Contributor

Superseded by #299, which keeps the same LayoutEditor test cleanup scope with passing checks and no active review threads. Closing this duplicate to keep the open PR queue actionable.

Understood. Acknowledging that this PR has been superseded and is now closed. Stopping further work on this task.

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