Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions docs/e2e/sample-basic-style.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"version": 8,
"glyphs": "/glyphs/{fontstack}/{range}.pbf",
"sources": {
"fixture": {
"type": "geojson",
"data": { "type": "FeatureCollection", "features": [] },
"attribution": "<a href=\"https://example.com\">Test fixture</a>"
}
},
"layers": [
{
"id": "background",
"type": "background",
"paint": { "background-color": "#cccccc" }
},
{
"id": "fixture",
"type": "fill",
"source": "fixture",
"paint": { "fill-color": "#cccccc" }
}
]
}
20 changes: 17 additions & 3 deletions e2e/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,12 @@ const GEOLONIA_TILE_PBF_REGEX = new RegExp(
* Geolonia のスタイル/タイル/スプライト等を最小レスポンスでモックする。
* テスト先頭の beforeEach で呼ぶ前提。
*
* 返すスタイルは layers=[background] のみのミニマル style v8。
* 返すスタイルは maps-core の sample-basic-style.json (PR #81) に揃えた
* minimal style v8。具体的には:
* - `glyphs` フィールド (symbol layer が silently skip されないため必須)
* - dummy `fixture` source + attribution (attribution テストで集計対象を作る)
* - background + fixture fill レイヤ
*
* 認証URL検証など transformRequest の挙動は実リクエスト前にここで握る。
*/
export async function mockGeoloniaTiles(page: Page) {
Expand All @@ -109,15 +114,24 @@ export async function mockGeoloniaTiles(page: Page) {
contentType: 'application/json',
body: JSON.stringify({
version: 8,
sources: {},
glyphs: '/glyphs/{fontstack}/{range}.pbf',
sources: {
fixture: {
type: 'geojson',
data: { type: 'FeatureCollection', features: [] },
attribution: '<a href="https://example.com">Test fixture</a>',
},
},
layers: [
{ id: 'background', type: 'background', paint: { 'background-color': '#cccccc' } },
{ id: 'fixture', type: 'fill', source: 'fixture', paint: { 'fill-color': '#cccccc' } },
],
}),
}),
);

// スプライト / グリフ / フォント関連は 404 でよい (background のみなので参照されない)
// スプライト / グリフ / フォント関連は 404 でよい (実体は不要だが minimal style 内の
// glyphs path に対するリクエストが net error にならないよう route で握る)
await page.route(/cdn\.geolonia\.com\/(sprite|glyph|font)/, (route) =>
route.fulfill({ status: 404, body: '' }),
);
Expand Down
4 changes: 3 additions & 1 deletion e2e/sample.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ test.describe('PR0 helper sanity', () => {

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

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