Skip to content

[4.4] マイページ注文履歴詳細にお問い合わせ番号を表示 (#6818)#6826

Open
ttokoro20240902 wants to merge 4 commits into
4.4from
feature/mypage-history-tracking-number
Open

[4.4] マイページ注文履歴詳細にお問い合わせ番号を表示 (#6818)#6826
ttokoro20240902 wants to merge 4 commits into
4.4from
feature/mypage-history-tracking-number

Conversation

@ttokoro20240902

@ttokoro20240902 ttokoro20240902 commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

概要

フロント会員がマイページの注文履歴詳細画面(/mypage/history/{order_no})で、配送のお問い合わせ番号(追跡番号)を確認できるようにします。Issue #6818 の実装です。

データソースは既存の dtb_shipping.tracking_numberDB・エンティティ・コントローラ・ルートの変更は不要で、表示のみを追加します(Order.Shippings 経由で取得済みのため追加クエリ・N+1 なし)。

closes #6818

変更内容

  • history.twig: 配送情報ループ内、「お届け時間」の直後に表示ブロックを追加。値が未入力(null/空文字列)の場合は項目自体を非表示。複数配送先は配送先ごとに評価。{{ Shipping.tracking_number }}|raw 不使用)で自動エスケープ。
  • messages.ja/en.yaml: front.mypage.tracking_number を追加(お問い合わせ番号 / Tracking No.、既存 admin.order.tracking_number と統一)。
  • MypageControllerTest: 表示/null非表示/空文字非表示/複数配送/一部のみ入力/XSSエスケープ/翻訳定義 を追加。
  • front-mypage.spec.ts(E2E): 管理画面でお問い合わせ番号を設定→マイページで表示を確認。受注番号をキーに検索・直接遷移し一覧の並び順に依存しない。

スコープ外

  • フロントからの入力・更新(管理画面のみ)/追跡ページへのリンク化/注文履歴一覧への表示/管理画面側の変更。

動作確認

  • PHPUnit MypageControllerTest 全件パス(既存含む 17 件)
  • php-cs-fixer 違反 0 / Twig lint OK
  • Playwright MCP で実機確認(設定前は非表示、設定後は「お届け時間」直後に表示、XSS は <script> でエスケープ・未実行)

エビデンス画像

管理画面の受注編集でお問い合わせ番号を入力

pr6826-evidence-03-admin-set-tracking

マイページ注文履歴詳細(配送情報セクション拡大)

pr6826-evidence-04-after-tracking-detail

マイページ注文履歴詳細(ページ全体)

pr6826-evidence-05-after-tracking-fullpage

<script>alert(1)</script> を設定 → エスケープ表示で実行されない

pr6826-evidence-06-xss-escaped

tracking_number = NULL → 項目自体が非表示

pr6826-evidence-07-null-hidden

tracking_number = ''(空文字列)→ 項目自体が非表示

pr6826-evidence-08-empty-string-hidden

英語ラベル「Tracking No.」は MypageControllerTest::testTrackingNumberLabelTranslations で検証済みのため画像は省略。

受入基準(Issue §9)

  • 値あり → 「お届け時間」直後に表示
  • null/空文字列 → 項目非表示
  • 複数配送 → 入力済みの配送先のみ表示
  • 日本語「お問い合わせ番号」/英語「Tracking No.」
  • HTML 特殊文字は自動エスケープされ実行されない
  • 本人の注文のみ表示・仮受注は閲覧不可(既存機能、変更なし)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • 新機能

    • マイページの注文履歴詳細に「お問い合わせ番号(追跡番号)」を配送情報欄に表示(追跡番号がある場合のみ)。
  • ドキュメント(ローカライズ)

    • 表示ラベル用の翻訳キーを日本語・英語に追加。
  • テスト

    • 表示有無、空文字・複数配送先・XSS等を検証する単体テスト群と、該当挙動を確認するE2Eテストを追加。
  • CI

    • Playwright E2E の実行セットにフロント向けスイートを追加。

フロント会員がマイページの注文履歴詳細画面で配送のお問い合わせ番号
(追跡番号) を確認できるようにする。

- history.twig: 配送情報ループ内、お届け時間の直後に表示ブロックを追加。
  値が未入力 (null/空文字列) の場合は項目自体を非表示。複数配送先は
  配送先ごとに評価。出力は自動エスケープ (XSS 対策)。
- messages.ja/en.yaml: front.mypage.tracking_number を追加
  (お問い合わせ番号 / Tracking No.、admin.order.tracking_number と統一)。
- MypageControllerTest: 表示/null非表示/空文字非表示/複数配送/一部のみ入力/
  XSSエスケープ/翻訳定義 の主要ケースを追加。非表示判定はセレクタ件数で検証し、
  受注生成・配送追加・履歴取得をヘルパーへ集約。
- front-mypage.spec.ts: 管理画面でお問い合わせ番号を設定しマイページで
  表示を確認する E2E を追加。受注番号をキーに検索・直接遷移することで
  一覧の並び順に依存しない (フレーキー回避)。

データソースは既存の dtb_shipping.tracking_number。DB・エンティティ・
コントローラ・ルートの変更は不要 (表示のみ)。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

マイページ注文履歴詳細に、Shipping.tracking_number が存在する場合のみ「お問い合わせ番号」を表示するテンプレート追加、日英メッセージ追加、関連のユニットテストとE2Eテストを実装しました。

Changes

マイページ注文履歴詳細への追跡番号表示機能

Layer / File(s) Summary
フロント表示層:テンプレートとローカライズ定義
src/Eccube/Resource/template/default/Mypage/history.twig, src/Eccube/Resource/locale/messages.ja.yaml, src/Eccube/Resource/locale/messages.en.yaml
配送情報ループ内、お届け時間の直後に{% if Shipping.tracking_number %}の条件分岐を追加。追跡番号が存在する場合のみec-definitions--softで「お問い合わせ番号」ラベルと値を表示。日英のメッセージキーを追加。
ユニットテスト検証層
tests/Eccube/Tests/Web/Mypage/MypageControllerTest.php
マイページ履歴詳細での追跡番号表示要件を検証する複数の PHPUnit テストを追加(null・空文字・複数配送先・一部入力・XSS・翻訳検証)。インポート整理とテスト用ヘルパ追加を含む。
E2Eテスト統合層
e2e/tests/front-mypage.spec.ts, .github/workflows/e2e-test.yml
受注履歴から注文番号を取得するgetLatestOrderNoと、管理画面で追跡番号を設定するsetTrackingNumberViaAdminヘルパを実装。追跡番号設定時の表示(配置含む)と未設定時の非表示を検証するE2Eテストを追加。E2E ワークフローのテストマトリクスに関連スイートを追加。

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested labels

Status: ready-for-merge

Suggested reviewers

  • dotani1111
  • saori-kakiuchi
  • ji-eunsoo

Poem

🐰 小さな足で台帳辿り、
お問い合わせ番号、そっと見つけた。
言葉は二つで道しるべ、
テストで確かめ、安心して届け。
ぴょんと跳ねて、リリース祝い!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed PRタイトルは「マイページ注文履歴詳細にお問い合わせ番号を表示」と明確で、変更セットの主な目的を正確に反映している。
Linked Issues check ✅ Passed 全ての要件が実装されている。テンプレート修正で条件付き表示、ローカライズ追加で多言語対応、PHPユニットテストで表示/非表示/XSS対策/複数配送シナリオをカバー、E2Eテストで実機動作確認が実装されている。
Out of Scope Changes check ✅ Passed 全変更は#6818の要件範囲内である。テンプレート・ローカライズ・テストの追加のみで、管理画面変更・フロント入力・リンク化などのスコープ外項目は含まれていない。
Docstring Coverage ✅ Passed Docstring coverage is 92.86% which is sufficient. The required threshold is 80.00%.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ 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 feature/mypage-history-tracking-number

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 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
e2e/tests/front-mypage.spec.ts (1)

316-318: ⚡ Quick win

非表示検証はテキスト全体ではなくラベル要素不在で判定した方が安定します。

div.ec-orderDelivery 全体への not.toContainText は将来の文言変更に弱いので、dt ラベルの不在で直接判定する方が堅牢です。

修正例
-    const delivery = page.locator('div.ec-orderDelivery');
-    await expect(delivery).not.toContainText('お問い合わせ番号');
+    await expect(
+      page.locator('div.ec-orderDelivery dt', { hasText: 'お問い合わせ番号' })
+    ).toHaveCount(0);
🤖 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 `@e2e/tests/front-mypage.spec.ts` around lines 316 - 318, Replace the brittle
full-text assertion on the delivery block with a structural check for the absent
label: locate the existing delivery locator (delivery =
page.locator('div.ec-orderDelivery')) and then assert that the child dt element
with the label text 'お問い合わせ番号' does not exist (e.g., get delivery.locator for
the dt with that text and expect its count to be zero). This makes the check
robust to unrelated wording changes while still verifying the label is not
present.
🤖 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 `@e2e/tests/front-mypage.spec.ts`:
- Around line 185-189: 現在のコード uses adminPage.locator(...).first() to pick the
first order link which can target the wrong row; instead locate the table row
whose order number cell matches the expected orderNo and then select the anchor
within that row, e.g. find the tbody tr that contains orderNo (use the existing
orderNo variable) and call locator on that row to get the 'a[href*="/order/"]'
link, then read its href into orderEditHref and navigate; replace usages of
orderLink = adminPage.locator(...).first() and the blind navigation with this
targeted row-based lookup so only the matching order is followed.

In `@tests/Eccube/Tests/Web/Mypage/MypageControllerTest.php`:
- Around line 218-327: The listed test methods (testHistoryWithTrackingNumber,
testHistoryWithoutTrackingNumber, testHistoryWithEmptyTrackingNumber,
testHistoryWithMultipleShippings,
testHistoryWithMultipleShippingsPartiallyFilled, testHistoryTrackingNumberXss,
testTrackingNumberLabelTranslations) lack a return type; update each public
function declaration to include the void return type (e.g., change "public
function testHistoryWithTrackingNumber()" to "public function
testHistoryWithTrackingNumber(): void") so all tests in MypageControllerTest use
consistent ": void" signatures.

---

Nitpick comments:
In `@e2e/tests/front-mypage.spec.ts`:
- Around line 316-318: Replace the brittle full-text assertion on the delivery
block with a structural check for the absent label: locate the existing delivery
locator (delivery = page.locator('div.ec-orderDelivery')) and then assert that
the child dt element with the label text 'お問い合わせ番号' does not exist (e.g., get
delivery.locator for the dt with that text and expect its count to be zero).
This makes the check robust to unrelated wording changes while still verifying
the label is not present.
🪄 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: 4af7d162-7e20-4548-b7ed-8d92beb9c1de

📥 Commits

Reviewing files that changed from the base of the PR and between f2711b3 and f8bf5de.

📒 Files selected for processing (5)
  • e2e/tests/front-mypage.spec.ts
  • src/Eccube/Resource/locale/messages.en.yaml
  • src/Eccube/Resource/locale/messages.ja.yaml
  • src/Eccube/Resource/template/default/Mypage/history.twig
  • tests/Eccube/Tests/Web/Mypage/MypageControllerTest.php

Comment thread e2e/tests/front-mypage.spec.ts Outdated
Comment thread tests/Eccube/Tests/Web/Mypage/MypageControllerTest.php Outdated
ttokoro20240902 and others added 3 commits June 12, 2026 06:40
- MypageControllerTest: getContent() の string|false に (string) キャストを付与し
  Crawler を import 経由に変更 (rector StringCastAssertStringContainsStringRector)
- 追加したテストメソッドに : void 戻り値型を付与
- E2E: 受注一覧から .first() ではなく受注番号で行を特定してリンクを辿る
- E2E: お問い合わせ番号未表示の検証をラベル dt のカウント 0 へ構造化

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
e2e-test.yml の matrix は許可リストであり, 列挙されていない spec は CI で実行されない。
front-order(16件) / front-mypage(10件+skip 1) / front-invoice(2件) は
テストカバレッジ向上で追加された際から matrix 未登録のままで, 一度も CI で実行されていなかった。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@codecov

codecov Bot commented Jun 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.88%. Comparing base (2930d11) to head (d53f59d).
⚠️ Report is 3 commits behind head on 4.4.

Additional details and impacted files
@@           Coverage Diff           @@
##              4.4    #6826   +/-   ##
=======================================
  Coverage   74.88%   74.88%           
=======================================
  Files         463      463           
  Lines       24029    24029           
=======================================
+ Hits        17994    17995    +1     
+ Misses       6035     6034    -1     
Flag Coverage Δ
Unit 74.88% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dotani1111 dotani1111 added this to the 4.4.0 milestone Jun 17, 2026
@dotani1111 dotani1111 self-assigned this Jun 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[4.4] マイページ注文履歴お問い合わせ番号表示 — 実装設計

2 participants