Skip to content

Commit e04da30

Browse files
committed
(refs geolonia#463) removed duplicated changes regarding geolonia#466
1 parent 57d67e6 commit e04da30

2 files changed

Lines changed: 39 additions & 77 deletions

File tree

docs/e2e/external-style.html

Lines changed: 0 additions & 29 deletions
This file was deleted.

e2e/external-style.spec.ts

Lines changed: 39 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,74 @@
11
import { test, expect } from '@playwright/test';
2-
import { TEST_URL, LOAD_TIMEOUT } from './helper';
32

43
test.describe('External Style Support', () => {
54
test('should render map with external OSM Bright style', async ({ page }) => {
6-
await page.goto(`${TEST_URL}/external-style.html`);
5+
await page.goto('/e2e/external-style.html');
76

8-
// Wait for map object to be created
7+
// Wait for map to be loaded
98
await page.waitForFunction(() => {
109
const container = document.querySelector('#map');
1110
return container && (container as any).geoloniaMap;
12-
}, { timeout: LOAD_TIMEOUT });
11+
});
1312

14-
// Check that the map container and canvas are visible
15-
const mapContainer = page.locator('#map');
16-
await expect(mapContainer).toBeVisible();
17-
const mapCanvas = page.locator('#map canvas.maplibregl-canvas');
13+
// Check if map is rendered
14+
const mapCanvas = await page.locator('#map canvas.maplibregl-canvas');
1815
await expect(mapCanvas).toBeVisible();
1916

20-
// Verify that the map instance has the correct center from data attributes
21-
const center = await page.evaluate(() => {
17+
// Verify that the map has loaded
18+
const isMapLoaded = await page.evaluate(() => {
2219
const container = document.querySelector('#map') as any;
23-
return container.geoloniaMap.getCenter();
20+
const map = container.geoloniaMap;
21+
return map && map.loaded();
2422
});
25-
expect(center.lat).toBeCloseTo(35.6812, 1);
26-
expect(center.lng).toBeCloseTo(139.7671, 1);
23+
24+
expect(isMapLoaded).toBe(true);
2725
});
2826

29-
test('should not throw errors when using external style without API key', async ({ page }) => {
30-
const consoleErrors: string[] = [];
27+
test('should warn about missing API key but still work with external style', async ({
28+
page,
29+
}) => {
30+
const consoleMessages: string[] = [];
3131
page.on('console', (msg) => {
32-
if (msg.type() === 'error') {
33-
consoleErrors.push(msg.text());
32+
if (msg.type() === 'warning') {
33+
consoleMessages.push(msg.text());
3434
}
3535
});
3636

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

39+
// Wait for map to be loaded
3940
await page.waitForFunction(() => {
4041
const container = document.querySelector('#map');
4142
return container && (container as any).geoloniaMap;
42-
}, { timeout: LOAD_TIMEOUT });
43+
});
4344

44-
// External style should work without API key errors
45-
const hasApiKeyError = consoleErrors.some((msg) =>
46-
msg.includes('API key'),
45+
// Check if warning about API key was shown
46+
const hasApiKeyWarning = consoleMessages.some((msg) =>
47+
msg.includes('API key not found'),
4748
);
48-
expect(hasApiKeyError).toBe(false);
49+
expect(hasApiKeyWarning).toBe(true);
4950
});
5051

51-
test('should display map tiles from external source', async ({ page }) => {
52-
await page.goto(`${TEST_URL}/external-style.html`);
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+
});
59+
60+
await page.goto('/e2e/external-style.html');
5361

62+
// Wait for map to be loaded
5463
await page.waitForFunction(() => {
5564
const container = document.querySelector('#map');
5665
return container && (container as any).geoloniaMap;
57-
}, { timeout: LOAD_TIMEOUT });
58-
59-
// Verify canvas has rendered content (not blank)
60-
const isNotBlank = await page.evaluate(() => {
61-
const canvas = document.querySelector('#map canvas.maplibregl-canvas') as HTMLCanvasElement;
62-
const gl = canvas.getContext('webgl2') || canvas.getContext('webgl');
63-
if (!gl) return false;
64-
65-
const width = canvas.width;
66-
const height = Math.floor(canvas.height / 2);
67-
const pixels = new Uint8Array(width * height * 4);
68-
gl.readPixels(0, Math.floor(canvas.height / 2), width, height, gl.RGBA, gl.UNSIGNED_BYTE, pixels);
69-
70-
let nonWhiteCount = 0;
71-
const totalPixels = pixels.length / 4;
72-
for (let i = 0; i < pixels.length; i += 4) {
73-
if (pixels[i] < 250 || pixels[i + 1] < 250 || pixels[i + 2] < 250) {
74-
nonWhiteCount++;
75-
if (nonWhiteCount > totalPixels * 0.01) return true;
76-
}
77-
}
78-
return nonWhiteCount > 0;
7966
});
8067

81-
expect(isNotBlank).toBe(true);
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);
8273
});
8374
});

0 commit comments

Comments
 (0)