Repository navigation
フォアグラウンド測位にも精度フィルタを適用し、DevOverlayに生の精度を表示する - #6103
Conversation
Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthrough位置情報の精度チェックと生データ記録ロジックを新規の Changes位置情報処理統合と精度表示
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
src/utils/handleTrackingLocation.test.ts (1)
35-38: 💤 Low value
jest.clearAllMocks()はafterEachで呼び出してください。機能的には問題ありませんが、本リポジトリの規約ではモッククリアを
afterEachで行うことになっています。♻️ 提案
beforeEach(() => { - jest.clearAllMocks(); mockIsDevApp = false; }); + + afterEach(() => { + jest.clearAllMocks(); + });As per coding guidelines: 「テストの
afterEachでjest.clearAllMocks()を呼び出してください」🤖 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/utils/handleTrackingLocation.test.ts` around lines 35 - 38, Move the jest.clearAllMocks() call out of the beforeEach block and into an afterEach block to conform to repo test conventions: remove jest.clearAllMocks() from the existing beforeEach in src/utils/handleTrackingLocation.test.ts and add an afterEach(() => { jest.clearAllMocks(); }) so mocks are cleared after each test; keep other setup (e.g., mockIsDevApp = false) inside the current beforeEach.src/hooks/useStartBackgroundLocationUpdates.test.tsx (1)
27-29: ⚡ Quick win
handleTrackingLocationがコールバックとして渡されることを直接検証することを推奨します。現状のテストは
watchPositionAsyncの第2引数をexpect.any(Function)(Line 372, 448)でしか確認しておらず、本 PR の核心であるフォアグラウンド経路への精度フィルタ適用(setLocation直結からhandleTrackingLocationへの切替)が回帰しても検知できません。モックを変数に束ね、コールバック実体を断言すると契約が固定されます。💚 検証アサーション追加の例
+import { handleTrackingLocation } from '~/utils/handleTrackingLocation'; jest.mock('~/utils/handleTrackingLocation', () => ({ handleTrackingLocation: jest.fn(), }));+const mockHandleTrackingLocation = handleTrackingLocation as jest.Mock;expect(mockWatchPositionAsync).toHaveBeenCalledWith( LOCATION_WATCH_OPTIONS, - expect.any(Function) + mockHandleTrackingLocation );🤖 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/hooks/useStartBackgroundLocationUpdates.test.tsx` around lines 27 - 29, The test should assert that the actual handleTrackingLocation mock is passed as the callback to watchPositionAsync instead of just expect.any(Function); modify the jest.mock for '~/utils/handleTrackingLocation' to export a named jest.fn() variable (e.g., mockedHandleTrackingLocation), use that mock in the test that mounts useStartBackgroundLocationUpdates, and replace the expect(..., expect.any(Function)) assertions with an equality assertion that the second argument to watchPositionAsync is the mockedHandleTrackingLocation (or assert watchPositionAsync was called with mockedHandleTrackingLocation as the callback); this guarantees the hook now hands off to handleTrackingLocation instead of directly calling setLocation.
🤖 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.
Nitpick comments:
In `@src/hooks/useStartBackgroundLocationUpdates.test.tsx`:
- Around line 27-29: The test should assert that the actual
handleTrackingLocation mock is passed as the callback to watchPositionAsync
instead of just expect.any(Function); modify the jest.mock for
'~/utils/handleTrackingLocation' to export a named jest.fn() variable (e.g.,
mockedHandleTrackingLocation), use that mock in the test that mounts
useStartBackgroundLocationUpdates, and replace the expect(...,
expect.any(Function)) assertions with an equality assertion that the second
argument to watchPositionAsync is the mockedHandleTrackingLocation (or assert
watchPositionAsync was called with mockedHandleTrackingLocation as the
callback); this guarantees the hook now hands off to handleTrackingLocation
instead of directly calling setLocation.
In `@src/utils/handleTrackingLocation.test.ts`:
- Around line 35-38: Move the jest.clearAllMocks() call out of the beforeEach
block and into an afterEach block to conform to repo test conventions: remove
jest.clearAllMocks() from the existing beforeEach in
src/utils/handleTrackingLocation.test.ts and add an afterEach(() => {
jest.clearAllMocks(); }) so mocks are cleared after each test; keep other setup
(e.g., mockIsDevApp = false) inside the current beforeEach.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 79293cb1-2152-46f8-9441-b6fe39598459
📒 Files selected for processing (9)
index.jssrc/components/DevOverlay.test.tsxsrc/components/DevOverlay.tsxsrc/hooks/useStartBackgroundLocationUpdates.test.tsxsrc/hooks/useStartBackgroundLocationUpdates.tssrc/store/atoms/location.test.tssrc/store/atoms/location.tssrc/utils/handleTrackingLocation.test.tssrc/utils/handleTrackingLocation.ts
Co-Authored-By: Claude Opus 4.8 <[email protected]>
概要
DevOverlay の
LOCATION ACCURACYをMAX_PERMIT_ACCURACYフィルタに影響されない生の測位精度で表示し、許容値を超えた場合は赤字で警告するようにしました。あわせて、watchPositionAsync(フォアグラウンド監視)経路にMAX_PERMIT_ACCURACYフィルタが適用されていなかった考慮漏れを修正し、継続測位の2経路で精度フィルタを一貫させました。変更の種類
変更内容
watchPositionAsync経路でもMAX_PERMIT_ACCURACYフィルタが効くよう修正。これまでstartLocationUpdatesAsync(background)経路でしかフィルタしておらず、フォアグラウンド監視では許容精度を超える測位もそのまま採用していた。handleTrackingLocationを新設し、watch / background 双方の精度フィルタをここへ集約。経路ごとの適用漏れが構造的に起きないようにした(getCurrentPositionAsyncのワンショット取得・手動選択は従来どおりsetLocation直呼びでフィルタ対象外)。rawLocationAtomに変更。MAX_PERMIT_ACCURACYで棄却された測位の精度も診断表示できるようにした。MAX_PERMIT_ACCURACYを超える場合、数値・単位を赤字(#f87171)で表示する警告を追加。rawLocationAtomの更新はhandleTrackingLocation内でisDevAppのときだけ行う。DevOverlay はisDevApp時しか描画されないため、本番ビルドでは余計な atom 更新を発生させない。テスト
npm run lintが通ることnpm testが通ることnpm run typecheckが通ること関連Issue
スクリーンショット(任意)
Summary by CodeRabbit
New Features
Tests