From d73f510abe7dcc69309bbed351f725f56f94c390 Mon Sep 17 00:00:00 2001 From: Kerry Archibald Date: Thu, 14 Apr 2022 10:38:41 +0200 Subject: [PATCH] use unstable prefix for wk tile_Server Signed-off-by: Kerry Archibald --- src/utils/WellKnownUtils.ts | 2 +- .../views/location/LocationViewDialog-test.tsx | 3 ++- test/components/views/location/Map-test.tsx | 9 +++++---- test/components/views/messages/MBeaconBody-test.tsx | 3 ++- test/components/views/messages/MLocationBody-test.tsx | 7 ++++--- 5 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/utils/WellKnownUtils.ts b/src/utils/WellKnownUtils.ts index cb3e92a7bde..e41adabb903 100644 --- a/src/utils/WellKnownUtils.ts +++ b/src/utils/WellKnownUtils.ts @@ -22,7 +22,7 @@ import { MatrixClientPeg } from '../MatrixClientPeg'; const CALL_BEHAVIOUR_WK_KEY = "io.element.call_behaviour"; const E2EE_WK_KEY = "io.element.e2ee"; const E2EE_WK_KEY_DEPRECATED = "im.vector.riot.e2ee"; -const TILE_SERVER_WK_KEY = new UnstableValue( +export const TILE_SERVER_WK_KEY = new UnstableValue( "m.tile_server", "org.matrix.msc3488.tile_server"); /* eslint-disable camelcase */ diff --git a/test/components/views/location/LocationViewDialog-test.tsx b/test/components/views/location/LocationViewDialog-test.tsx index 432d7107fb2..fa23192bbfb 100644 --- a/test/components/views/location/LocationViewDialog-test.tsx +++ b/test/components/views/location/LocationViewDialog-test.tsx @@ -20,6 +20,7 @@ import { RoomMember } from 'matrix-js-sdk/src/matrix'; import { LocationAssetType } from 'matrix-js-sdk/src/@types/location'; import LocationViewDialog from '../../../../src/components/views/location/LocationViewDialog'; +import { TILE_SERVER_WK_KEY } from '../../../../src/utils/WellKnownUtils'; import { getMockClientWithEventEmitter, makeLocationEvent } from '../../../test-utils'; describe('', () => { @@ -27,7 +28,7 @@ describe('', () => { const userId = '@user:server'; const mockClient = getMockClientWithEventEmitter({ getClientWellKnown: jest.fn().mockReturnValue({ - "m.tile_server": { map_style_url: 'maps.com' }, + [TILE_SERVER_WK_KEY.name]: { map_style_url: 'maps.com' }, }), isGuest: jest.fn().mockReturnValue(false), }); diff --git a/test/components/views/location/Map-test.tsx b/test/components/views/location/Map-test.tsx index b5fce12a88d..40aaee01a07 100644 --- a/test/components/views/location/Map-test.tsx +++ b/test/components/views/location/Map-test.tsx @@ -24,6 +24,7 @@ import { logger } from 'matrix-js-sdk/src/logger'; import Map from '../../../../src/components/views/location/Map'; import { findByTestId, getMockClientWithEventEmitter } from '../../../test-utils'; import MatrixClientContext from '../../../../src/contexts/MatrixClientContext'; +import { TILE_SERVER_WK_KEY } from '../../../../src/utils/WellKnownUtils'; describe('', () => { const defaultProps = { @@ -34,7 +35,7 @@ describe('', () => { }; const matrixClient = getMockClientWithEventEmitter({ getClientWellKnown: jest.fn().mockReturnValue({ - "m.tile_server": { map_style_url: 'maps.com' }, + [TILE_SERVER_WK_KEY.name]: { map_style_url: 'maps.com' }, }), }); const getComponent = (props = {}) => @@ -46,7 +47,7 @@ describe('', () => { beforeEach(() => { jest.clearAllMocks(); matrixClient.getClientWellKnown.mockReturnValue({ - "m.tile_server": { map_style_url: 'maps.com' }, + [TILE_SERVER_WK_KEY.name]: { map_style_url: 'maps.com' }, }); jest.spyOn(logger, 'error').mockRestore(); @@ -65,7 +66,7 @@ describe('', () => { act(() => { matrixClient.emit(ClientEvent.ClientWellKnown, { - "m.tile_server": { map_style_url: 'new.maps.com' }, + [TILE_SERVER_WK_KEY.name]: { map_style_url: 'new.maps.com' }, }); }); @@ -77,7 +78,7 @@ describe('', () => { act(() => { matrixClient.emit(ClientEvent.ClientWellKnown, { - "m.tile_server": { map_style_url: undefined }, + [TILE_SERVER_WK_KEY.name]: { map_style_url: undefined }, }); }); diff --git a/test/components/views/messages/MBeaconBody-test.tsx b/test/components/views/messages/MBeaconBody-test.tsx index 772d83ae022..535e471a275 100644 --- a/test/components/views/messages/MBeaconBody-test.tsx +++ b/test/components/views/messages/MBeaconBody-test.tsx @@ -29,6 +29,7 @@ import { getMockClientWithEventEmitter, makeBeaconEvent, makeBeaconInfoEvent } f import { RoomPermalinkCreator } from '../../../../src/utils/permalinks/Permalinks'; import { MediaEventHelper } from '../../../../src/utils/MediaEventHelper'; import MatrixClientContext from '../../../../src/contexts/MatrixClientContext'; +import { TILE_SERVER_WK_KEY } from '../../../../src/utils/WellKnownUtils'; describe('', () => { // 14.03.2022 16:15 @@ -43,7 +44,7 @@ describe('', () => { const mockClient = getMockClientWithEventEmitter({ getClientWellKnown: jest.fn().mockReturnValue({ - "m.tile_server": { map_style_url: 'maps.com' }, + [TILE_SERVER_WK_KEY.name]: { map_style_url: 'maps.com' }, }), getUserId: jest.fn().mockReturnValue(aliceId), getRoom: jest.fn(), diff --git a/test/components/views/messages/MLocationBody-test.tsx b/test/components/views/messages/MLocationBody-test.tsx index c1133e81c0a..cc5a6105e50 100644 --- a/test/components/views/messages/MLocationBody-test.tsx +++ b/test/components/views/messages/MLocationBody-test.tsx @@ -28,6 +28,7 @@ import { RoomPermalinkCreator } from "../../../../src/utils/permalinks/Permalink import { MediaEventHelper } from "../../../../src/utils/MediaEventHelper"; import Modal from '../../../../src/Modal'; import SdkConfig from "../../../../src/SdkConfig"; +import { TILE_SERVER_WK_KEY } from '../../../../src/utils/WellKnownUtils'; import { makeLocationEvent } from "../../../test-utils/location"; import { getMockClientWithEventEmitter } from '../../../test-utils'; @@ -37,7 +38,7 @@ describe("MLocationBody", () => { const userId = '@user:server'; const mockClient = getMockClientWithEventEmitter({ getClientWellKnown: jest.fn().mockReturnValue({ - "m.tile_server": { map_style_url: 'maps.com' }, + [TILE_SERVER_WK_KEY.name]: { map_style_url: 'maps.com' }, }), isGuest: jest.fn().mockReturnValue(false), }); @@ -78,7 +79,7 @@ describe("MLocationBody", () => { it('displays correct fallback content when map_style_url is misconfigured', () => { const mockMap = new maplibregl.Map(); mockClient.getClientWellKnown.mockReturnValue({ - "m.tile_server": { map_style_url: 'bad-tile-server.com' }, + [TILE_SERVER_WK_KEY.name]: { map_style_url: 'bad-tile-server.com' }, }); const component = getComponent(); @@ -93,7 +94,7 @@ describe("MLocationBody", () => { describe('without error', () => { beforeEach(() => { mockClient.getClientWellKnown.mockReturnValue({ - "m.tile_server": { map_style_url: 'maps.com' }, + [TILE_SERVER_WK_KEY.name]: { map_style_url: 'maps.com' }, }); // MLocationBody uses random number for map id