From 5372306703c8949b38483c0b1876db9a40257b39 Mon Sep 17 00:00:00 2001 From: niryuu Date: Wed, 3 Jun 2026 01:56:00 +0900 Subject: [PATCH] =?UTF-8?q?test(e2e):=20backport=20maps-core=20PR=20#81=20?= =?UTF-8?q?=E2=80=94=20robust=20minimal=20style=20fixture?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit E2E flaky 対策。maps-core PR #81 と同じ解決策を embed の helper に backport。 - e2e/helper.ts の mockGeoloniaTiles が返す minimal style を強化: - glyphs フィールド (symbol layer が silently skip されないため必須) - dummy fixture source + attribution (attribution テストで集計対象を作る) - background + fixture fill レイヤ - e2e/sample.spec.ts の期待 layers を ['background', 'fixture'] に更新 - docs/e2e/sample-basic-style.json を新規追加。後続フェーズで data-style="./sample-basic-style.json" として参照可能 10/10 グリーン確認済み。external-style.spec.ts は smoke として外部 URL を保持。 Closes #490 Part of #411 --- docs/e2e/sample-basic-style.json | 24 ++++++++++++++++++++++++ e2e/helper.ts | 20 +++++++++++++++++--- e2e/sample.spec.ts | 4 +++- 3 files changed, 44 insertions(+), 4 deletions(-) create mode 100644 docs/e2e/sample-basic-style.json diff --git a/docs/e2e/sample-basic-style.json b/docs/e2e/sample-basic-style.json new file mode 100644 index 00000000..e58078d2 --- /dev/null +++ b/docs/e2e/sample-basic-style.json @@ -0,0 +1,24 @@ +{ + "version": 8, + "glyphs": "/glyphs/{fontstack}/{range}.pbf", + "sources": { + "fixture": { + "type": "geojson", + "data": { "type": "FeatureCollection", "features": [] }, + "attribution": "Test fixture" + } + }, + "layers": [ + { + "id": "background", + "type": "background", + "paint": { "background-color": "#cccccc" } + }, + { + "id": "fixture", + "type": "fill", + "source": "fixture", + "paint": { "fill-color": "#cccccc" } + } + ] +} diff --git a/e2e/helper.ts b/e2e/helper.ts index de9d7802..644264a4 100644 --- a/e2e/helper.ts +++ b/e2e/helper.ts @@ -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) { @@ -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: 'Test fixture', + }, + }, 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: '' }), ); diff --git a/e2e/sample.spec.ts b/e2e/sample.spec.ts index de989f04..7f335807 100644 --- a/e2e/sample.spec.ts +++ b/e2e/sample.spec.ts @@ -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 }) => {