Skip to content

Commit 4636cff

Browse files
authored
Merge pull request #492 from geolonia/490/backport-minimal-style-fixture
test(e2e): backport maps-core PR #81 — robust minimal style fixture
2 parents c8d6d07 + 5372306 commit 4636cff

3 files changed

Lines changed: 44 additions & 4 deletions

File tree

docs/e2e/sample-basic-style.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"version": 8,
3+
"glyphs": "/glyphs/{fontstack}/{range}.pbf",
4+
"sources": {
5+
"fixture": {
6+
"type": "geojson",
7+
"data": { "type": "FeatureCollection", "features": [] },
8+
"attribution": "<a href=\"https://example.com\">Test fixture</a>"
9+
}
10+
},
11+
"layers": [
12+
{
13+
"id": "background",
14+
"type": "background",
15+
"paint": { "background-color": "#cccccc" }
16+
},
17+
{
18+
"id": "fixture",
19+
"type": "fill",
20+
"source": "fixture",
21+
"paint": { "fill-color": "#cccccc" }
22+
}
23+
]
24+
}

e2e/helper.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,12 @@ const GEOLONIA_TILE_PBF_REGEX = new RegExp(
9898
* Geolonia のスタイル/タイル/スプライト等を最小レスポンスでモックする。
9999
* テスト先頭の beforeEach で呼ぶ前提。
100100
*
101-
* 返すスタイルは layers=[background] のみのミニマル style v8。
101+
* 返すスタイルは maps-core の sample-basic-style.json (PR #81) に揃えた
102+
* minimal style v8。具体的には:
103+
* - `glyphs` フィールド (symbol layer が silently skip されないため必須)
104+
* - dummy `fixture` source + attribution (attribution テストで集計対象を作る)
105+
* - background + fixture fill レイヤ
106+
*
102107
* 認証URL検証など transformRequest の挙動は実リクエスト前にここで握る。
103108
*/
104109
export async function mockGeoloniaTiles(page: Page) {
@@ -109,15 +114,24 @@ export async function mockGeoloniaTiles(page: Page) {
109114
contentType: 'application/json',
110115
body: JSON.stringify({
111116
version: 8,
112-
sources: {},
117+
glyphs: '/glyphs/{fontstack}/{range}.pbf',
118+
sources: {
119+
fixture: {
120+
type: 'geojson',
121+
data: { type: 'FeatureCollection', features: [] },
122+
attribution: '<a href="https://example.com">Test fixture</a>',
123+
},
124+
},
113125
layers: [
114126
{ id: 'background', type: 'background', paint: { 'background-color': '#cccccc' } },
127+
{ id: 'fixture', type: 'fill', source: 'fixture', paint: { 'fill-color': '#cccccc' } },
115128
],
116129
}),
117130
}),
118131
);
119132

120-
// スプライト / グリフ / フォント関連は 404 でよい (background のみなので参照されない)
133+
// スプライト / グリフ / フォント関連は 404 でよい (実体は不要だが minimal style 内の
134+
// glyphs path に対するリクエストが net error にならないよう route で握る)
121135
await page.route(/cdn\.geolonia\.com\/(sprite|glyph|font)/, (route) =>
122136
route.fulfill({ status: 404, body: '' }),
123137
);

e2e/sample.spec.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ test.describe('PR0 helper sanity', () => {
2020

2121
expect(await hasMapInstance(page)).toBe(true);
2222
const layers = await getStyleLayerIds(page);
23-
expect(layers).toEqual(['background']);
23+
// mockGeoloniaTiles の minimal style に含まれるレイヤ
24+
// (background + fixture。fixture は attribution 検証用の dummy source)
25+
expect(layers).toEqual(['background', 'fixture']);
2426
});
2527

2628
test('recordRequests で geolonia 系へのリクエストを観測できる', async ({ page }) => {

0 commit comments

Comments
 (0)