Repository navigation
東京メトロ/TY系コンポーネントを小田急テーマ向けに抽象化 - #5696
Conversation
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.6 (1M context) <[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
Sequence Diagram(s)sequenceDiagram
participant Client as 呼び出し元
participant HeaderEast as HeaderEast
participant Atoms as JotaiAtoms
participant Anim as useHeaderAnimation
participant Gradient as LinearGradient
participant TrainType as TrainTypeBox
participant Numbering as NumberingIcon
Client ->> HeaderEast: render(props, config)
HeaderEast ->> Atoms: read currentLine, headerState, stationNumber
HeaderEast ->> Anim: request animated styles (headerState, config)
Anim -->> HeaderEast: animated styles
HeaderEast ->> Gradient: render with config.gradient (animated styles)
Gradient ->> TrainType: render TrainTypeBox (props ← config)
HeaderEast ->> Numbering: condition付きで NumberingIcon を render
HeaderEast ->> HeaderEast: render station/bound texts and divider
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 分 Possibly related PRs
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 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.
Actionable comments posted: 2
🧹 Nitpick comments (3)
src/components/LineBoardEast.test.tsx (1)
207-218: テストのアサーションを強化することを検討してください。このテストは
ChevronTYが呼び出されたことのみを検証していますが、カスタムchevronColorPair(['ORANGE', 'BLUE']) が実際に渡されたかどうかを確認していません。デフォルト値のテスト(220-235行目)と同様に、color プロパティの値も検証した方がより堅牢なテストになります。🔧 アサーションを強化する提案
it('カスタムchevronColorPairでレンダリングされる', () => { const { ChevronTY } = require('./ChevronTY'); render( <LineBoardEast stations={mockStations} lineColors={['#9acd32', '#9acd32']} hasTerminus={false} chevronColorPair={['ORANGE', 'BLUE']} /> ); - expect(ChevronTY).toHaveBeenCalled(); + expect(ChevronTY).toHaveBeenCalledWith( + expect.objectContaining({ + color: expect.stringMatching(/^(ORANGE|BLUE)$/), + }), + undefined + ); });🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/components/LineBoardEast.test.tsx` around lines 207 - 218, The test currently only asserts that the mocked ChevronTY was called; update the test for LineBoardEast (the 'カスタムchevronColorPairでレンダリングされる' case) to also assert that ChevronTY received the expected color props derived from chevronColorPair (['ORANGE','BLUE']). In the test locate the mocked ChevronTY (ChevronTY) and inspect its last call/props (e.g., ChevronTY.mock.calls or ChevronTY.mock.lastCall) and add assertions that the prop responsible for the rendered color (the color or colors prop passed by LineBoardEast to ChevronTY) equals the expected values for 'ORANGE' and 'BLUE', mirroring how the default-value test (lines ~220-235) verifies color props.src/components/TypeChangeNotify.test.tsx (1)
26-28: このテストではグラデーション周りの回帰を拾えません。
LinearGradientモックがcolorsを捨てていて、各ケースも「クラッシュしないこと」だけを見ています。今回の差分であるEastBarsの色計算やデフォルト分岐の差し替えが壊れても通ってしまうので、少なくとも 1 ケースはcolorsprop まで検証したいです。Also applies to: 95-151
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/components/TypeChangeNotify.test.tsx` around lines 26 - 28, The current LinearGradient mock used in TypeChangeNotify.test.tsx swallows the colors prop so gradient-related regressions (like color calc changes in EastBars and default-branch swaps) aren't detected; update the mock to capture the colors prop (e.g., make LinearGradient a jest.fn that returns children but stores its last call props) and add at least one assertion in the existing tests to verify the expected colors array for the EastBars rendering (or whichever test case covers default branching), so the test fails if colors change unexpectedly.src/components/HeaderTY.test.tsx (1)
138-143: 存在確認だけだと TY 固有の受け渡しは守れません。
TrainTypeBoxモックが引数を捨てていて、ここも描画有無しか見ていないので、localTypePrefix="ty"やnextTrainTypeColorの受け渡しが外れても気づけません。今回の変更点なら呼び出し引数まで検証したいです。Also applies to: 157-160
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/components/HeaderTY.test.tsx` around lines 138 - 143, The current TrainTypeBox mock (MockTrainTypeBox) discards its props so tests can't detect TY-specific prop passing (e.g., localTypePrefix and nextTrainTypeColor); update the jest.mock for TrainTypeBox so the mock component accepts props and either (a) renders them into identifiable attributes/text (e.g., <View testID="TrainTypeBox" accessibilityLabel={props.localTypePrefix} /* or include color */ />) so existing render-based assertions can verify values, or (b) replace the mock with a jest.fn wrapper that records calls and assert it was called with the expected props (check/mock the component by name TrainTypeBox and assert props.localTypePrefix === "ty" and props.nextTrainTypeColor matches expected). Ensure both occurrences of the mock (the block around MockTrainTypeBox and the similar block at lines noted in the review) are changed.
🤖 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/components/HeaderEast/HeaderEast.tsx`:
- Around line 23-28: styles.gradientRoot に overflow: 'hidden' があるため tyConfig の
gradientRootExtraStyle に shadow を指定すると iOS で影がクリップされます。修正するには
gradientRootExtraStyle に shadow を入れる代わりに、影用スタイルを config.rootStyle(または新しい別 prop
例えば shadowStyle)に移動して styles.root にマージするように変更してください;対象となる識別子は gradientRoot,
gradientRootExtraStyle, styles.gradientRoot, styles.root, config.rootStyle(参考実装:
tokyoMetroConfig)です。
In `@src/components/TypeChangeNotify.tsx`:
- Around line 193-206: EastBars currently accepts getBarGradient/getBoxGradient
but is only used internally with fixed arguments, so expose these theme hooks on
the parent TypeChangeNotify: add optional props getBarGradient?: ColorGradientFn
and getBoxGradient?: ColorGradientFn to TypeChangeNotify (defaulting to
defaultBarGradient/defaultBoxGradient), then pass those props through when
rendering EastBars (and the other internal instance mentioned) so external
themes can inject gradients while preserving existing defaults (use the same
defaultBarGradient/defaultBoxGradient symbols).
---
Nitpick comments:
In `@src/components/HeaderTY.test.tsx`:
- Around line 138-143: The current TrainTypeBox mock (MockTrainTypeBox) discards
its props so tests can't detect TY-specific prop passing (e.g., localTypePrefix
and nextTrainTypeColor); update the jest.mock for TrainTypeBox so the mock
component accepts props and either (a) renders them into identifiable
attributes/text (e.g., <View testID="TrainTypeBox"
accessibilityLabel={props.localTypePrefix} /* or include color */ />) so
existing render-based assertions can verify values, or (b) replace the mock with
a jest.fn wrapper that records calls and assert it was called with the expected
props (check/mock the component by name TrainTypeBox and assert
props.localTypePrefix === "ty" and props.nextTrainTypeColor matches expected).
Ensure both occurrences of the mock (the block around MockTrainTypeBox and the
similar block at lines noted in the review) are changed.
In `@src/components/LineBoardEast.test.tsx`:
- Around line 207-218: The test currently only asserts that the mocked ChevronTY
was called; update the test for LineBoardEast (the
'カスタムchevronColorPairでレンダリングされる' case) to also assert that ChevronTY received
the expected color props derived from chevronColorPair (['ORANGE','BLUE']). In
the test locate the mocked ChevronTY (ChevronTY) and inspect its last call/props
(e.g., ChevronTY.mock.calls or ChevronTY.mock.lastCall) and add assertions that
the prop responsible for the rendered color (the color or colors prop passed by
LineBoardEast to ChevronTY) equals the expected values for 'ORANGE' and 'BLUE',
mirroring how the default-value test (lines ~220-235) verifies color props.
In `@src/components/TypeChangeNotify.test.tsx`:
- Around line 26-28: The current LinearGradient mock used in
TypeChangeNotify.test.tsx swallows the colors prop so gradient-related
regressions (like color calc changes in EastBars and default-branch swaps)
aren't detected; update the mock to capture the colors prop (e.g., make
LinearGradient a jest.fn that returns children but stores its last call props)
and add at least one assertion in the existing tests to verify the expected
colors array for the EastBars rendering (or whichever test case covers default
branching), so the test fails if colors change unexpectedly.
🪄 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: CHILL
Plan: Pro
Run ID: 75fc9531-806e-405d-92df-9d06b170c22d
📒 Files selected for processing (13)
src/components/ChevronTY.tsxsrc/components/HeaderEast/HeaderEast.test.tsxsrc/components/HeaderEast/HeaderEast.tsxsrc/components/HeaderEast/config.tssrc/components/HeaderEast/index.tssrc/components/HeaderTY.test.tsxsrc/components/HeaderTY.tsxsrc/components/HeaderTokyoMetro.tsxsrc/components/LineBoardEast.test.tsxsrc/components/LineBoardEast.tsxsrc/components/TrainTypeBox.tsxsrc/components/TypeChangeNotify.test.tsxsrc/components/TypeChangeNotify.tsx
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/components/LineBoardEast.test.tsx (1)
207-240: アサーションをより厳密にすることを検討してください
useIntervalがモックされており実際には発火しないため、chevronColorの初期値は常にchevronColorPair[1]になります(context snippet 1 参照)。正規表現によるマッチングだと、初期値として常に index 0 の値が使われるバグがあっても検出できません。🔧 より厳密なアサーションの提案
it('カスタムchevronColorPairでレンダリングされる', () => { const { ChevronTY } = require('./ChevronTY'); render( <LineBoardEast stations={mockStations} lineColors={['#9acd32', '#9acd32']} hasTerminus={false} chevronColorPair={['ORANGE', 'BLUE']} /> ); expect(ChevronTY).toHaveBeenCalledWith( expect.objectContaining({ - color: expect.stringMatching(/^(ORANGE|BLUE)$/), + color: 'BLUE', // 初期値は chevronColorPair[1] }), undefined ); }); it('chevronColorPair未指定時はデフォルトのRED/BLUEが使われる', () => { const { ChevronTY } = require('./ChevronTY'); render( <LineBoardEast stations={mockStations} lineColors={['#9acd32', '#9acd32']} hasTerminus={false} /> ); expect(ChevronTY).toHaveBeenCalledWith( expect.objectContaining({ - color: expect.stringMatching(/^(RED|BLUE)$/), + color: 'BLUE', // 初期値は chevronColorPair[1] }), undefined ); });🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/components/LineBoardEast.test.tsx` around lines 207 - 240, The assertions are too loose; because useInterval is mocked so chevronColor never advances, the initial chevronColor is always chevronColorPair[1], so update the tests that reference ChevronTY to assert the exact initial color: in the test using chevronColorPair (LineBoardEast prop chevronColorPair), assert ChevronTY was called with color strictly equal to the second element of that array (chevronColorPair[1]); in the test without chevronColorPair, assert ChevronTY was called with color strictly equal to the default second color (the default BLUE used by LineBoardEast). Reference ChevronTY and the LineBoardEast prop chevronColorPair when making the change.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/components/LineBoardEast.test.tsx`:
- Around line 207-240: The assertions are too loose; because useInterval is
mocked so chevronColor never advances, the initial chevronColor is always
chevronColorPair[1], so update the tests that reference ChevronTY to assert the
exact initial color: in the test using chevronColorPair (LineBoardEast prop
chevronColorPair), assert ChevronTY was called with color strictly equal to the
second element of that array (chevronColorPair[1]); in the test without
chevronColorPair, assert ChevronTY was called with color strictly equal to the
default second color (the default BLUE used by LineBoardEast). Reference
ChevronTY and the LineBoardEast prop chevronColorPair when making the change.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: c85ed709-3d9e-497c-9606-07ef64c67d13
📒 Files selected for processing (5)
src/components/HeaderEast/config.tssrc/components/HeaderTY.test.tsxsrc/components/HeaderTokyoMetro.test.tsxsrc/components/LineBoardEast.test.tsxsrc/components/TypeChangeNotify.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
- src/components/TypeChangeNotify.tsx
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Summary
HeaderTokyoMetroとHeaderTYの共通構造をHeaderEastに統合し、configオブジェクトで差分を吸収TrainTypeBoxのisTYプロップをlocalTypePrefix/nextTrainTypeColorに汎用化LineBoardEastにシェブロン色ペアのカスタマイズ(chevronColorPair)を追加、ChevronTYにORANGEカラー追加TypeChangeNotifyのMetroBarsをEastBarsにリネームし、グラデーション生成関数(getBarGradient/getBoxGradient)を外部から注入可能にHeaderEast・TypeChangeNotify・LineBoardEastのテストを追加Test plan
npm run typecheckパスnpm run lintパスnpm test全145 suites / 1369 tests パス🤖 Generated with Claude Code
Summary by CodeRabbit
リリースノート
新機能
テスト
改良