Skip to content

test(e2e): embed固有(wrapper-only)のE2Eを追加#496

Merged
niryuu merged 1 commit into
masterfrom
494/embed-only-e2e
Jun 8, 2026
Merged

test(e2e): embed固有(wrapper-only)のE2Eを追加#496
niryuu merged 1 commit into
masterfrom
494/embed-only-e2e

Conversation

@niryuu

@niryuu niryuu commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

概要

#494 の実装。maps-core が担保する表示・機能とは別に、embed (wrapper) 固有の挙動だけを守る E2E を追加する。
(責任分担: 機能・表示は maps-core e2e/、embed は wrapper グルー専任。詳細は E2E-for-Embed-Only-Features

複数のテストが1つの PR に混在するため、ファイル ↔ テスト ↔ #494 項目 の対応を以下に明記する。

ファイル対応表

spec(e2e/

spec ファイル 対応する fixture テスト内容 #494 項目
e2e/globals.spec.ts docs/e2e/basic.html(既存) window.geolonia の形(Map/Marker/SimpleStyle/registerPlugin/embedVersion)/ maplibreglmapboxgl が同一参照 window.geolonia 公開・後方互換
e2e/auto-render.spec.ts docs/e2e/multiple-maps.html 複数 .geolonia の独立描画 / DOMContentLoaded 後追加は auto-render されない(one-shot) .geolonia auto-render
e2e/data-attributes.spec.ts docs/e2e/data-attributes.html data-lat/lng/zoom/bearing/pitchGeoloniaMapOptions フォワーディング data-* → options フォワーディング
e2e/lazy-loading.spec.ts docs/e2e/lazy-loading.html data-lazy-loading="off" 即時初期化 / デフォルトは lazy(スクロールで初期化) IntersectionObserver lazy-loading
e2e/cleanup.spec.ts docs/e2e/cleanup.html コンテナ DOM 削除で map.remove() 発火 / 二重 new で同一インスタンス MutationObserver cleanup
e2e/plugin.spec.ts docs/e2e/plugin.html registerPlugin の callback が全 map に (map, target, atts) で発火 registerPlugin + DOMContentLoaded
e2e/iframe.spec.ts docs/e2e/basic.html(既存) 非 iframe では拒否されず描画(iframe 拒否メッセージが出ない) iframe checkPermission
e2e/pmtiles.spec.ts —(skip のみ) pmtiles 登録タイミング pmtiles 登録タイミング

fixture(docs/e2e/、新規)

fixture 使用 spec
docs/e2e/multiple-maps.html auto-render
docs/e2e/data-attributes.html data-attributes
docs/e2e/lazy-loading.html lazy-loading
docs/e2e/cleanup.html cleanup
docs/e2e/plugin.html plugin

※ すべての fixture はテスト用公開キー ?geolonia-api-key=YOUR-API-KEY を使用(API キーは必須)。

skip しているテスト(silent に落とさず明示)

テスト 理由
iframe.spec.ts「iframe + API key 無し → 拒否される」 ローカルで特例 origin + referrer を再現できず、child frame の console も capture しにくい。checkPermission() のユニットテストで担保すべき。
pmtiles.spec.ts「pmtiles プロトコル登録」 グローバルな protocol 登録は観測しづらく回帰検知の価値が低い。maps-core / ユニットで担保する想定。

結果

  • 新規: 13 passed / 2 skipped、既存 E2E 10 件も全てパス、eslint クリーン(chromium)

メモ

Closes #494
Part of #411

Summary by CodeRabbit

リリースノート

  • Documentation

    • E2E テスト用の複数の HTML ドキュメント例を追加しました(複数マップ表示、遅延読み込み、データ属性設定など)。
  • Tests

    • Playwright による包括的な E2E テストスイートを追加し、自動レンダリング、マップの初期化、属性設定、プラグイン統合など、主要な機能の動作を検証するようになりました。

maps-core が担保する表示・機能とは別に、embed (wrapper) 固有の挙動だけを
守る E2E を追加する。globals / auto-render / data-* フォワーディング /
lazy-loading / cleanup / plugin / iframe 許可チェック をカバー。
iframe 拒否ケースと pmtiles 登録タイミングは E2E 困難のため skip (理由付き)。

Refs #494, #411
@coderabbitai

coderabbitai Bot commented Jun 5, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c093345d-7aab-4fd5-be28-16a24ac67384

📥 Commits

Reviewing files that changed from the base of the PR and between 4636cff and f23e694.

📒 Files selected for processing (13)
  • docs/e2e/cleanup.html
  • docs/e2e/data-attributes.html
  • docs/e2e/lazy-loading.html
  • docs/e2e/multiple-maps.html
  • docs/e2e/plugin.html
  • e2e/auto-render.spec.ts
  • e2e/cleanup.spec.ts
  • e2e/data-attributes.spec.ts
  • e2e/globals.spec.ts
  • e2e/iframe.spec.ts
  • e2e/lazy-loading.spec.ts
  • e2e/plugin.spec.ts
  • e2e/pmtiles.spec.ts

📝 Walkthrough

Walkthrough

embed固有(wrapper-only)のE2Eテスト基盤を新規構築。グローバルAPI公開、DOM自動レンダリング、data属性フォワーディング、遅延読み込み、プラグインシステム、クリーンアップ、iframe権限、pmtilesプロトコルの8つの機能領域に対応するHTMLデモページ5つとPlaywrightテストスペック9つを追加。

Changes

Embed固有E2Eテストスイート

Layer / File(s) Summary
E2Eデモ用HTMLページ基盤
docs/e2e/multiple-maps.html, docs/e2e/data-attributes.html, docs/e2e/lazy-loading.html, docs/e2e/plugin.html, docs/e2e/cleanup.html
複数マップ表示、data属性指定、遅延読み込みデモ、プラグイン検証、クリーンアップ検証の各用途に対応したE2E用HTMLドキュメントを新規追加。各ページは../embedスクリプト読み込みと地図コンテナ要素で構成。
グローバルAPI公開検証
e2e/globals.spec.ts
window.geoloniaと主要メンバ(Map/Marker/SimpleStyle/registerPlugin/embedVersion)の公開確認、window.maplibregl/window.mapboxglとの同一参照による後方互換性をPlaywrightで検証。
DOM自動レンダリング検証
e2e/auto-render.spec.ts
スクリプト読込時の.geolonia要素自動スキャンと複数マップ独立レンダリング、DOMContentLoaded後の動的追加要素が一度きりのスキャンで拾われない特性を検証。
Data属性フォワーディング検証
e2e/data-attributes.spec.ts
data-lat/data-lng/data-zoom/data-bearing/data-pitchなどのHTML属性がGeoloniaMapOptionsへ正しく解析・転送され、地図の中心座標・ズーム・方位・ピッチが期待値で反映されることを確認。
遅延読み込みIntersectionObserver検証
e2e/lazy-loading.spec.ts
data-lazy-loading="off"は即座に初期化、デフォルト状態ではviewport外で未初期化のまま、スクロール後に初期化される動作をIntersectionObserverで検証。
RegisterPluginシステム検証
e2e/plugin.spec.ts
window.geolonia.registerPluginコールバック登録とDOM自動レンダリング時の呼び出しを検証。複数マップに対して正しい引数(targetIdlat等)で各コールバックが実行されることを確認。
MutationObserverによるクリーンアップ検証
e2e/cleanup.spec.ts
DOM要素削除時のMutationObserver検知とmap.remove()イベント発火を検証。同一コンテナの二重初期化防止(インスタンス再利用)についても確認。
Iframe権限チェック検証
e2e/iframe.spec.ts
iframe内での地図表示許可・拒否のチェック処理をE2Eで検証。許可パスでは地図描画と特定のconsoleエラー非発生を確認、拒否パスはユニットテストで担保する前提でtest.skipで明示。
Pmtilesプロトコル登録(スキップ)
e2e/pmtiles.spec.ts
pmtilesプロトコル登録タイミングのE2E検証はtest.skipにより実行スキップ。プロトコル登録の堅牢な観測が困難で、実描画検証はmaps-core側で担保する想定。

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • geolonia/embed#489: 新規追加のE2Eテストスペック(data-attributes/lazy-loading/plugin/cleanup/auto-renderなど)で使用されるヘルパーユーティリティ(mockGeoloniaTiles/waitForStyleLoad)が本PRで拡張・導入されているため、テスト基盤が直結。

Suggested reviewers

  • smellman
  • sanak

Poem

🐇 ラビットが楽しげに跳ねる
E2E基盤、整えたぞ
wrapper固有の挙動も、もう逃げられない
テストで捕まえ、品質保証!
🗺️✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed PRタイトルは「test(e2e): embed固有(wrapper-only)のE2Eを追加」であり、変更内容(embed固有のE2Eテスト追加)を正確に要約している。
Linked Issues check ✅ Passed PR #494で要求されたwrapper-only E2Eテスト全9項目について、対応するテストファイルが追加されており、実装要件をすべて満たしている。
Out of Scope Changes check ✅ Passed すべての変更がwrapper-only E2Eテストの追加に限定されており、PR目的外の変更は含まれていない。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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 494/embed-only-e2e

Comment @coderabbitai help to get the list of available commands and usage tips.

@niryuu
niryuu requested a review from a team June 5, 2026 03:52
@niryuu niryuu self-assigned this Jun 5, 2026

@smellman smellman left a comment

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.

LGTM!
どこがe2eで担保できないのかがわかりやすくなっていて良いと思いました。

@yuiseki
yuiseki self-requested a review June 7, 2026 23:55

@yuiseki yuiseki left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

E2E 追加ありがとうございます。各 spec の冒頭に「これは embed (wrapper) 固有の挙動で、表示・機能そのものは maps-core 側 E2E が担保する」という責任境界がコメントで明記されていて、#494 の分担意図がコードだけ読んでも追えるのがとても良いです 🙌

特に良かった点:

  • auto-render の「DOMContentLoaded 後に追加した .geolonia は拾われない (one-shot)」という negative test。ハッピーパスだけでなく挙動の境界を押さえていて、renderGeoloniaMap の一度きり走査という仕様を正確に固定できています。
  • cleanup の「同一コンテナへ再 new すると同一インスタンスが返る」で二重初期化防止まで担保している点。
  • skip した iframe 拒否ケース / pmtiles 登録を silent に落とさず、理由と「どこで担保すべきか(checkPermission のユニット / maps-core)」まで書いてあるのが誠実で助かります。

production コード変更ゼロ・削除ゼロで、狙いどおり wrapper-only の回帰検知に絞れています。E2E も CI で pass しているので LGTM です。

nit(ブロッキングではないです):

  • auto-render one-shot と lazy 未初期化の negative test で waitForTimeout(500/300) を使っている箇所は、「起きないこと」の確認なので固定待ちは妥当な判断だと思います。将来 flaky になるようなら、別の観測可能なシグナル待ちに置き換える余地はありそうです。ご判断にお任せします。

@niryuu
niryuu merged commit 871f5bf into master Jun 8, 2026
11 checks passed
@niryuu
niryuu deleted the 494/embed-only-e2e branch June 8, 2026 00:07
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.

embed固有(wrapper-only)のE2Eテストを追加する

3 participants