You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by ms...@apache.org on 2026/06/11 15:31:56 UTC
(superset) branch master updated: test(core): cover invalid raster tile URL fallback in mapStyles (#40974)
This is an automated email from the ASF dual-hosted git repository.
msyavuz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git
The following commit(s) were added to refs/heads/master by this push:
new 058be4b904b test(core): cover invalid raster tile URL fallback in mapStyles (#40974)
058be4b904b is described below
commit 058be4b904b1fb1f70cc5175e432e219d29681a7
Author: Mehmet Salih Yavuz <sa...@proton.me>
AuthorDate: Thu Jun 11 18:31:50 2026 +0300
test(core): cover invalid raster tile URL fallback in mapStyles (#40974)
---
.../superset-ui-core/src/utils/mapStyles.test.ts | 35 ++++++++++++++++++++++
1 file changed, 35 insertions(+)
diff --git a/superset-frontend/packages/superset-ui-core/src/utils/mapStyles.test.ts b/superset-frontend/packages/superset-ui-core/src/utils/mapStyles.test.ts
index 318a81ef567..5313a9c1c2e 100644
--- a/superset-frontend/packages/superset-ui-core/src/utils/mapStyles.test.ts
+++ b/superset-frontend/packages/superset-ui-core/src/utils/mapStyles.test.ts
@@ -74,6 +74,30 @@ test('bootstrap data helper parses document data safely', () => {
expect(getBootstrapDataFromDocument()).toBeUndefined();
});
+test('bootstrap data helper returns undefined without a document', () => {
+ // jsdom defines `document` as a non-configurable global, so the SSR guard
+ // cannot be exercised by deleting it. Instead, re-evaluate the function's
+ // own source in a scope where `document` is shadowed with undefined. When
+ // running under coverage, the source is istanbul-instrumented and references
+ // its module-scoped counter, so the counter is injected to keep the guard's
+ // execution attributed to mapStyles.ts.
+ const source = getBootstrapDataFromDocument.toString();
+ const counterName = source.match(/cov_\w+/)?.[0] ?? 'unusedCoverageCounter';
+ const coverage = (globalThis as { __coverage__?: Record<string, unknown> })
+ .__coverage__;
+ const coverageEntry =
+ coverage?.[
+ Object.keys(coverage).find(file => file.endsWith('mapStyles.ts')) ?? ''
+ ];
+ // eslint-disable-next-line no-new-func
+ const callWithoutDocument = new Function(
+ counterName,
+ 'document',
+ `return (${source})();`,
+ );
+ expect(callWithoutDocument(() => coverageEntry, undefined)).toBeUndefined();
+});
+
test('renderer options enable Mapbox only when a key is available', () => {
expect(getMapRendererOptions({ hasMapboxKey: true })).toEqual([
{ value: 'maplibre' },
@@ -233,6 +257,17 @@ test('custom raster tile templates do not receive OSM attribution', () => {
}
});
+test('relative raster tile templates do not receive OSM attribution', () => {
+ const relativeTileUrl = '/tiles/{z}/{x}/{y}.png';
+ const style = resolveMapStyle(relativeTileUrl, 'default-style.json');
+
+ expect(typeof style).toBe('object');
+ if (typeof style !== 'string') {
+ expect(style.sources['osm-raster-tiles'].tiles).toEqual([relativeTileUrl]);
+ expect(style.sources['osm-raster-tiles']).not.toHaveProperty('attribution');
+ }
+});
+
test('lookalike OpenStreetMap hostnames do not receive OSM attribution', () => {
const lookalikeTileUrl =
'https://openstreetmap.org.example.com/{z}/{x}/{y}.png';