Repository navigation
test: 地図のロジックに回帰テストを追加する - #558
Merged
Merged
Conversation
vue-mapbox 撤去で触る serializeBounds/deserializeBounds/inBounds を固定。 serialize と deserialize は緯度が入れ替わる非対称があり、URLハッシュ互換のため 直さない。jsdom に createObjectURL が無いので jest.setup.js で補う。
KML 解析が壊れると例外を出さずマーカー0件になる。静かに壊れる経路なので固定する。
印刷される POI 一覧の中身を決めている部分。地図ライブラリには依存しないので Mgl* をスタブしてマウントする。CSS/SVG の moduleNameMapper も併せて追加。
This was referenced Jul 30, 2026
This was referenced Jul 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要 | About
lib/MapHelper.tsとcomponents/PrintableMap.vueに回帰テストを追加します。本体コードの変更はありません。テストは 6件 → 35件になります。
紙マップの中核は「取り込んだ地点を表示範囲で絞り込み、カテゴリごとに並べて印刷する」流れですが、ここが壊れても例外が出ないため印刷するまで気づけません。
この後 vue-mapbox の撤去と Nuxt 4 移行を予定しているので、先に安全網を用意したいです。
追加したもの
MapHelper.bounds.spec.js(10件)URLハッシュとマーカー絞り込みに使うserializeBounds/deserializeBounds/inBoundsMapHelper.kml.spec.js(2件)static/data/kml/2024-noto.kmlを実際に読んで座標とカテゴリを検証。ネットワークは使いませんPrintableMap.markers.spec.js(9件)印刷されるPOI一覧の中身。表示範囲での絞り込み、エリアのチェック、カテゴリ分類、ロケール別の名前jest.setup.jsはmaplibre-glが import 時に参照するwindow.URL.createObjectURLを jsdom に補うためのものです。jest.config.jsには CSS・SVG・@/のmoduleNameMapperを追加しました。PrintableMapが CSS と SVG を import しているため、これがないとマウントできません。serializeBoundsとdeserializeBoundsが非対称(経度は復元されるが緯度が_sw/_neで入れ替わる)なことに気づきましたが、用途がfitBoundsとinBoundsに限られ両方とも角の順序に依存しないため実害はありません。直すとURLハッシュの解釈が変わって既に配布された印刷物の表示範囲がずれるので、直さずテスト側で範囲として比較しています。
Nuxt 4 では jest が使えなくなるため、これらのテストは移行PRで vitest 向けに書き換わります。
動作確認方法 | How to check
本体コードを変更していないので
yarn run generateの出力も変わりません。スクリーンショット | Screenshot
なし(見た目に影響しません)