Skip to content

Commit 1c9d315

Browse files
authored
Merge pull request #466 from geolonia/fix-fail-e2e-test
fix: E2Eテストが失敗する問題を修正
2 parents d9abfa7 + bb7d274 commit 1c9d315

2 files changed

Lines changed: 13 additions & 62 deletions

File tree

e2e/external-style.spec.ts

Lines changed: 13 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,25 @@
11
import { test, expect } from '@playwright/test';
2+
import { TEST_URL, waitForMapLoad } from './helper';
23

3-
test.describe('External Style Support', () => {
4-
test('should render map with external OSM Bright style', async ({ page }) => {
5-
await page.goto('/e2e/external-style.html');
4+
const EXTERNAL_STYLE_URL = 'https://tile.openstreetmap.jp/styles/osm-bright/style.json';
65

7-
// Wait for map to be loaded
8-
await page.waitForFunction(() => {
9-
const container = document.querySelector('#map');
10-
return container && (container as any).geoloniaMap;
11-
});
6+
test.describe('External Style Support', () => {
7+
test('data-style で外部スタイルを指定しても地図が表示されること', async ({ page }) => {
8+
await page.goto(`${TEST_URL}/external-style.html`);
9+
await waitForMapLoad(page, '#map');
1210

13-
// Check if map is rendered
14-
const mapCanvas = await page.locator('#map canvas.maplibregl-canvas');
11+
const mapCanvas = page.locator('#map canvas.maplibregl-canvas');
1512
await expect(mapCanvas).toBeVisible();
16-
17-
// Verify that the map has loaded
18-
const isMapLoaded = await page.evaluate(() => {
19-
const container = document.querySelector('#map') as any;
20-
const map = container.geoloniaMap;
21-
return map && map.loaded();
22-
});
23-
24-
expect(isMapLoaded).toBe(true);
2513
});
2614

27-
test('should warn about missing API key but still work with external style', async ({
28-
page,
29-
}) => {
30-
const consoleMessages: string[] = [];
31-
page.on('console', (msg) => {
32-
if (msg.type() === 'warning') {
33-
consoleMessages.push(msg.text());
34-
}
35-
});
36-
37-
await page.goto('/e2e/external-style.html');
38-
39-
// Wait for map to be loaded
40-
await page.waitForFunction(() => {
41-
const container = document.querySelector('#map');
42-
return container && (container as any).geoloniaMap;
43-
});
44-
45-
// Check if warning about API key was shown
46-
const hasApiKeyWarning = consoleMessages.some((msg) =>
47-
msg.includes('API key not found'),
15+
test('data-style で指定した外部スタイルURLにアクセスしていること', async ({ page }) => {
16+
const styleRequest = page.waitForRequest((req) =>
17+
req.url().includes(EXTERNAL_STYLE_URL),
4818
);
49-
expect(hasApiKeyWarning).toBe(true);
50-
});
51-
52-
test('should log external style loading info', async ({ page }) => {
53-
const consoleMessages: string[] = [];
54-
page.on('console', (msg) => {
55-
if (msg.type() === 'log') {
56-
consoleMessages.push(msg.text());
57-
}
58-
});
5919

60-
await page.goto('/e2e/external-style.html');
20+
await page.goto(`${TEST_URL}/external-style.html`);
6121

62-
// Wait for map to be loaded
63-
await page.waitForFunction(() => {
64-
const container = document.querySelector('#map');
65-
return container && (container as any).geoloniaMap;
66-
});
67-
68-
// Check if external style loading log was shown
69-
const hasExternalStyleLog = consoleMessages.some((msg) =>
70-
msg.includes('Loading external style from'),
71-
);
72-
expect(hasExternalStyleLog).toBe(true);
22+
const req = await styleRequest;
23+
expect(req.url()).toBe(EXTERNAL_STYLE_URL);
7324
});
7425
});

0 commit comments

Comments
 (0)