Merge branch 'develop' into 19245-improve-styling-of-search-initialization-errors
This commit is contained in:
commit
401e124df6
90 changed files with 562 additions and 398 deletions
|
@ -168,7 +168,7 @@ describe('<LeftPanelLiveShareWarning />', () => {
|
|||
const component = getComponent();
|
||||
// error mode
|
||||
expect(component.find('.mx_LeftPanelLiveShareWarning').at(0).text()).toEqual(
|
||||
'An error occured whilst sharing your live location',
|
||||
'An error occurred whilst sharing your live location',
|
||||
);
|
||||
|
||||
act(() => {
|
||||
|
|
|
@ -359,7 +359,7 @@ describe('<RoomLiveShareWarning />', () => {
|
|||
|
||||
// renders wire error ui
|
||||
expect(component.find('.mx_RoomLiveShareWarning_label').text()).toEqual(
|
||||
'An error occured whilst sharing your live location, please try again',
|
||||
'An error occurred whilst sharing your live location, please try again',
|
||||
);
|
||||
expect(findByTestId(component, 'room-live-share-wire-error-close-button').length).toBeTruthy();
|
||||
});
|
||||
|
|
|
@ -69,7 +69,7 @@ exports[`<LeftPanelLiveShareWarning /> when user has live location monitor rende
|
|||
role="button"
|
||||
tabIndex={0}
|
||||
>
|
||||
An error occured whilst sharing your live location
|
||||
An error occurred whilst sharing your live location
|
||||
</div>
|
||||
</AccessibleButton>
|
||||
</LeftPanelLiveShareWarning>
|
||||
|
|
|
@ -32,7 +32,7 @@ exports[`<RoomLiveShareWarning /> when user has live beacons and geolocation is
|
|||
<span
|
||||
className="mx_RoomLiveShareWarning_label"
|
||||
>
|
||||
An error occured whilst sharing your live location, please try again
|
||||
An error occurred whilst sharing your live location, please try again
|
||||
</span>
|
||||
<AccessibleButton
|
||||
className="mx_RoomLiveShareWarning_stopButton"
|
||||
|
|
65
test/components/views/rooms/BasicMessageComposer-test.tsx
Normal file
65
test/components/views/rooms/BasicMessageComposer-test.tsx
Normal file
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
Copyright 2022 The Matrix.org Foundation C.I.C.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { mount, ReactWrapper } from 'enzyme';
|
||||
import { MatrixClient, Room } from 'matrix-js-sdk/src/matrix';
|
||||
|
||||
import BasicMessageComposer from '../../../../src/components/views/rooms/BasicMessageComposer';
|
||||
import * as TestUtils from "../../../test-utils";
|
||||
import { MatrixClientPeg } from "../../../../src/MatrixClientPeg";
|
||||
import EditorModel from "../../../../src/editor/model";
|
||||
import { createPartCreator, createRenderer } from "../../../editor/mock";
|
||||
|
||||
describe("BasicMessageComposer", () => {
|
||||
const renderer = createRenderer();
|
||||
const pc = createPartCreator();
|
||||
|
||||
beforeEach(() => {
|
||||
TestUtils.stubClient();
|
||||
});
|
||||
|
||||
it("should allow a user to paste a URL without it being mangled", () => {
|
||||
const model = new EditorModel([], pc, renderer);
|
||||
|
||||
const wrapper = render(model);
|
||||
|
||||
wrapper.find(".mx_BasicMessageComposer_input").simulate("paste", {
|
||||
clipboardData: {
|
||||
getData: type => {
|
||||
if (type === "text/plain") {
|
||||
return "https://element.io";
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
expect(model.parts).toHaveLength(1);
|
||||
expect(model.parts[0].text).toBe("https://element.io");
|
||||
});
|
||||
});
|
||||
|
||||
function render(model: EditorModel): ReactWrapper {
|
||||
const client: MatrixClient = MatrixClientPeg.get();
|
||||
|
||||
const roomId = '!1234567890:domain';
|
||||
const userId = client.getUserId();
|
||||
const room = new Room(roomId, client, userId);
|
||||
|
||||
return mount((
|
||||
<BasicMessageComposer model={model} room={room} />
|
||||
));
|
||||
}
|
|
@ -17,7 +17,11 @@ limitations under the License.
|
|||
import React from 'react';
|
||||
import ReactTestUtils from 'react-dom/test-utils';
|
||||
import ReactDOM from 'react-dom';
|
||||
import { MatrixClient, Room, RoomMember } from 'matrix-js-sdk/src/matrix';
|
||||
import {
|
||||
PendingEventOrdering,
|
||||
Room,
|
||||
RoomMember,
|
||||
} from 'matrix-js-sdk/src/matrix';
|
||||
|
||||
import * as TestUtils from '../../../test-utils';
|
||||
import { MatrixClientPeg } from '../../../../src/MatrixClientPeg';
|
||||
|
@ -29,6 +33,8 @@ import RoomListLayoutStore from "../../../../src/stores/room-list/RoomListLayout
|
|||
import RoomList from "../../../../src/components/views/rooms/RoomList";
|
||||
import RoomSublist from "../../../../src/components/views/rooms/RoomSublist";
|
||||
import RoomTile from "../../../../src/components/views/rooms/RoomTile";
|
||||
import { getMockClientWithEventEmitter, mockClientMethodsUser } from '../../../test-utils';
|
||||
import ResizeNotifier from '../../../../src/utils/ResizeNotifier';
|
||||
|
||||
function generateRoomId() {
|
||||
return '!' + Math.random().toString().slice(2, 10) + ':domain';
|
||||
|
@ -38,7 +44,7 @@ describe('RoomList', () => {
|
|||
function createRoom(opts) {
|
||||
const room = new Room(generateRoomId(), MatrixClientPeg.get(), client.getUserId(), {
|
||||
// The room list now uses getPendingEvents(), so we need a detached ordering.
|
||||
pendingEventOrdering: "detached",
|
||||
pendingEventOrdering: PendingEventOrdering.Detached,
|
||||
});
|
||||
if (opts) {
|
||||
Object.assign(room, opts);
|
||||
|
@ -47,25 +53,38 @@ describe('RoomList', () => {
|
|||
}
|
||||
|
||||
let parentDiv = null;
|
||||
let client = null;
|
||||
let root = null;
|
||||
const myUserId = '@me:domain';
|
||||
|
||||
const movingRoomId = '!someroomid';
|
||||
let movingRoom;
|
||||
let otherRoom;
|
||||
let movingRoom: Room | undefined;
|
||||
let otherRoom: Room | undefined;
|
||||
|
||||
let myMember;
|
||||
let myOtherMember;
|
||||
let myMember: RoomMember | undefined;
|
||||
let myOtherMember: RoomMember | undefined;
|
||||
|
||||
const client = getMockClientWithEventEmitter({
|
||||
...mockClientMethodsUser(myUserId),
|
||||
getRooms: jest.fn(),
|
||||
getVisibleRooms: jest.fn(),
|
||||
getRoom: jest.fn(),
|
||||
});
|
||||
|
||||
const defaultProps = {
|
||||
onKeyDown: jest.fn(),
|
||||
onFocus: jest.fn(),
|
||||
onBlur: jest.fn(),
|
||||
onResize: jest.fn(),
|
||||
resizeNotifier: {} as unknown as ResizeNotifier,
|
||||
isMinimized: false,
|
||||
activeSpace: '',
|
||||
};
|
||||
|
||||
beforeEach(async function(done) {
|
||||
RoomListStoreClass.TEST_MODE = true;
|
||||
jest.clearAllMocks();
|
||||
|
||||
TestUtils.stubClient();
|
||||
client = MatrixClientPeg.get();
|
||||
client.credentials = { userId: myUserId };
|
||||
//revert this to prototype method as the test-utils monkey-patches this to return a hardcoded value
|
||||
client.getUserId = MatrixClient.prototype.getUserId;
|
||||
|
||||
DMRoomMap.makeShared();
|
||||
|
||||
|
@ -74,7 +93,7 @@ describe('RoomList', () => {
|
|||
|
||||
const WrappedRoomList = TestUtils.wrapInMatrixClientContext(RoomList);
|
||||
root = ReactDOM.render(
|
||||
<WrappedRoomList searchFilter="" onResize={() => {}} />,
|
||||
<WrappedRoomList {...defaultProps} />,
|
||||
parentDiv,
|
||||
);
|
||||
ReactTestUtils.findRenderedComponentWithType(root, RoomList);
|
||||
|
@ -99,7 +118,7 @@ describe('RoomList', () => {
|
|||
}[userId]);
|
||||
|
||||
// Mock the matrix client
|
||||
client.getRooms = () => [
|
||||
const mockRooms = [
|
||||
movingRoom,
|
||||
otherRoom,
|
||||
createRoom({ tags: { 'm.favourite': { order: 0.1 } }, name: 'Some other room' }),
|
||||
|
@ -107,14 +126,15 @@ describe('RoomList', () => {
|
|||
createRoom({ tags: { 'm.lowpriority': {} }, name: 'Some unimportant room' }),
|
||||
createRoom({ tags: { 'custom.tag': {} }, name: 'Some room customly tagged' }),
|
||||
];
|
||||
client.getVisibleRooms = client.getRooms;
|
||||
client.getRooms.mockReturnValue(mockRooms);
|
||||
client.getVisibleRooms.mockReturnValue(mockRooms);
|
||||
|
||||
const roomMap = {};
|
||||
client.getRooms().forEach((r) => {
|
||||
roomMap[r.roomId] = r;
|
||||
});
|
||||
|
||||
client.getRoom = (roomId) => roomMap[roomId];
|
||||
client.getRoom.mockImplementation((roomId) => roomMap[roomId]);
|
||||
|
||||
// Now that everything has been set up, prepare and update the store
|
||||
await RoomListStore.instance.makeReady(client);
|
||||
|
@ -171,6 +191,7 @@ describe('RoomList', () => {
|
|||
movingRoom.tags = { [oldTagId]: {} };
|
||||
} else if (oldTagId === DefaultTagID.DM) {
|
||||
// Mock inverse m.direct
|
||||
// @ts-ignore forcing private property
|
||||
DMRoomMap.shared().roomToUser = {
|
||||
[movingRoom.roomId]: '@someotheruser:domain',
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue