Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
use unstable prefix for wk tile_Server
Browse files Browse the repository at this point in the history
Signed-off-by: Kerry Archibald <kerrya@element.io>
  • Loading branch information
Kerry Archibald committed Apr 14, 2022
1 parent c35fc16 commit d73f510
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/utils/WellKnownUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
3 changes: 2 additions & 1 deletion test/components/views/location/LocationViewDialog-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@ 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('<LocationViewDialog />', () => {
const roomId = '!room:server';
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),
});
Expand Down
9 changes: 5 additions & 4 deletions test/components/views/location/Map-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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('<Map />', () => {
const defaultProps = {
Expand All @@ -34,7 +35,7 @@ describe('<Map />', () => {
};
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 = {}) =>
Expand All @@ -46,7 +47,7 @@ describe('<Map />', () => {
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();
Expand All @@ -65,7 +66,7 @@ describe('<Map />', () => {

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' },
});
});

Expand All @@ -77,7 +78,7 @@ describe('<Map />', () => {

act(() => {
matrixClient.emit(ClientEvent.ClientWellKnown, {
"m.tile_server": { map_style_url: undefined },
[TILE_SERVER_WK_KEY.name]: { map_style_url: undefined },
});
});

Expand Down
3 changes: 2 additions & 1 deletion test/components/views/messages/MBeaconBody-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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('<MBeaconBody />', () => {
// 14.03.2022 16:15
Expand All @@ -43,7 +44,7 @@ describe('<MBeaconBody />', () => {

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(),
Expand Down
7 changes: 4 additions & 3 deletions test/components/views/messages/MLocationBody-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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),
});
Expand Down Expand Up @@ -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();

Expand All @@ -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
Expand Down

0 comments on commit d73f510

Please sign in to comment.