diff --git a/src/utils/location/map.ts b/src/utils/location/map.ts index b3b74d14495..331fce4aeea 100644 --- a/src/utils/location/map.ts +++ b/src/utils/location/map.ts @@ -36,7 +36,9 @@ export const createMap = ( style: styleUrl, zoom: 15, interactive, + attributionControl: false, }); + map.addControl(new maplibregl.AttributionControl(), 'top-right'); map.on('error', (e) => { logger.error( diff --git a/test/components/views/beacon/BeaconViewDialog-test.tsx b/test/components/views/beacon/BeaconViewDialog-test.tsx index 8d0fb30e307..12b40939392 100644 --- a/test/components/views/beacon/BeaconViewDialog-test.tsx +++ b/test/components/views/beacon/BeaconViewDialog-test.tsx @@ -89,6 +89,10 @@ describe('', () => { const getComponent = (props = {}) => mount(); + beforeAll(() => { + maplibregl.AttributionControl = jest.fn(); + }); + beforeEach(() => { jest.spyOn(OwnBeaconStore.instance, 'getLiveBeaconIds').mockRestore(); diff --git a/test/components/views/location/LocationViewDialog-test.tsx b/test/components/views/location/LocationViewDialog-test.tsx index fa23192bbfb..af270c5f974 100644 --- a/test/components/views/location/LocationViewDialog-test.tsx +++ b/test/components/views/location/LocationViewDialog-test.tsx @@ -18,6 +18,7 @@ import React from 'react'; import { mount } from 'enzyme'; import { RoomMember } from 'matrix-js-sdk/src/matrix'; import { LocationAssetType } from 'matrix-js-sdk/src/@types/location'; +import maplibregl from 'maplibre-gl'; import LocationViewDialog from '../../../../src/components/views/location/LocationViewDialog'; import { TILE_SERVER_WK_KEY } from '../../../../src/utils/WellKnownUtils'; @@ -41,6 +42,10 @@ describe('', () => { const getComponent = (props = {}) => mount(); + beforeAll(() => { + maplibregl.AttributionControl = jest.fn(); + }); + it('renders map correctly', () => { const component = getComponent(); expect(component.find('Map')).toMatchSnapshot(); diff --git a/test/components/views/location/Map-test.tsx b/test/components/views/location/Map-test.tsx index 12915c192ee..dc349793c6d 100644 --- a/test/components/views/location/Map-test.tsx +++ b/test/components/views/location/Map-test.tsx @@ -44,6 +44,10 @@ describe('', () => { wrappingComponentProps: { value: matrixClient }, }); + beforeAll(() => { + maplibregl.AttributionControl = jest.fn(); + }); + beforeEach(() => { jest.clearAllMocks(); matrixClient.getClientWellKnown.mockReturnValue({ diff --git a/test/components/views/location/__snapshots__/LocationViewDialog-test.tsx.snap b/test/components/views/location/__snapshots__/LocationViewDialog-test.tsx.snap index a9f7a03f07d..6104f0dad0b 100644 --- a/test/components/views/location/__snapshots__/LocationViewDialog-test.tsx.snap +++ b/test/components/views/location/__snapshots__/LocationViewDialog-test.tsx.snap @@ -23,7 +23,20 @@ exports[` renders map correctly 1`] = ` }, "_eventsCount": 1, "_maxListeners": undefined, - "addControl": [MockFunction], + "addControl": [MockFunction] { + "calls": Array [ + Array [ + mockConstructor {}, + "top-right", + ], + ], + "results": Array [ + Object { + "type": "return", + "value": undefined, + }, + ], + }, "fitBounds": [MockFunction], "removeControl": [MockFunction], "setCenter": [MockFunction] { @@ -78,7 +91,20 @@ exports[` renders map correctly 1`] = ` }, "_eventsCount": 1, "_maxListeners": undefined, - "addControl": [MockFunction], + "addControl": [MockFunction] { + "calls": Array [ + Array [ + mockConstructor {}, + "top-right", + ], + ], + "results": Array [ + Object { + "type": "return", + "value": undefined, + }, + ], + }, "fitBounds": [MockFunction], "removeControl": [MockFunction], "setCenter": [MockFunction] { diff --git a/test/components/views/messages/MBeaconBody-test.tsx b/test/components/views/messages/MBeaconBody-test.tsx index 8719df567da..e9cb719f7f2 100644 --- a/test/components/views/messages/MBeaconBody-test.tsx +++ b/test/components/views/messages/MBeaconBody-test.tsx @@ -79,6 +79,11 @@ describe('', () => { }); const modalSpy = jest.spyOn(Modal, 'createTrackedDialog').mockReturnValue(undefined); + + beforeAll(() => { + maplibregl.AttributionControl = jest.fn(); + }); + beforeEach(() => { jest.clearAllMocks(); }); diff --git a/test/components/views/messages/MLocationBody-test.tsx b/test/components/views/messages/MLocationBody-test.tsx index cc5a6105e50..ec2270f6358 100644 --- a/test/components/views/messages/MLocationBody-test.tsx +++ b/test/components/views/messages/MLocationBody-test.tsx @@ -56,6 +56,15 @@ describe("MLocationBody", () => { wrappingComponent: MatrixClientContext.Provider, wrappingComponentProps: { value: mockClient }, }); + + beforeAll(() => { + maplibregl.AttributionControl = jest.fn(); + }); + + beforeEach(() => { + jest.clearAllMocks(); + }); + describe('with error', () => { let sdkConfigSpy; diff --git a/test/components/views/messages/__snapshots__/MLocationBody-test.tsx.snap b/test/components/views/messages/__snapshots__/MLocationBody-test.tsx.snap index f4914b510d1..97ab9e0ac1c 100644 --- a/test/components/views/messages/__snapshots__/MLocationBody-test.tsx.snap +++ b/test/components/views/messages/__snapshots__/MLocationBody-test.tsx.snap @@ -124,7 +124,20 @@ exports[`MLocationBody without error renders map correctly 1`] = }, "_eventsCount": 1, "_maxListeners": undefined, - "addControl": [MockFunction], + "addControl": [MockFunction] { + "calls": Array [ + Array [ + mockConstructor {}, + "top-right", + ], + ], + "results": Array [ + Object { + "type": "return", + "value": undefined, + }, + ], + }, "fitBounds": [MockFunction], "removeControl": [MockFunction], "setCenter": [MockFunction] { @@ -135,22 +148,12 @@ exports[`MLocationBody without error renders map correctly 1`] = "lon": -0.1276, }, ], - Array [ - Object { - "lat": 51.5076, - "lon": -0.1276, - }, - ], ], "results": Array [ Object { "type": "return", "value": undefined, }, - Object { - "type": "return", - "value": undefined, - }, ], }, "setStyle": [MockFunction],