2016-03-31 07:48:46 +08:00
|
|
|
/*
|
|
|
|
Copyright 2016 OpenMarket Ltd
|
2019-11-27 03:06:02 +08:00
|
|
|
Copyright 2019 The Matrix.org Foundation C.I.C.
|
2016-03-31 07:48:46 +08:00
|
|
|
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
|
2017-10-29 15:43:52 +08:00
|
|
|
import SettingsStore from "../../../src/settings/SettingsStore";
|
|
|
|
|
2019-09-06 22:04:46 +08:00
|
|
|
import React from 'react';
|
|
|
|
import ReactDOM from "react-dom";
|
2019-08-24 18:47:07 +08:00
|
|
|
const TestUtils = require('react-dom/test-utils');
|
2017-10-12 00:56:17 +08:00
|
|
|
const expect = require('expect');
|
2019-03-15 16:57:26 +08:00
|
|
|
import { EventEmitter } from "events";
|
2016-03-31 07:48:46 +08:00
|
|
|
|
2019-12-16 19:12:48 +08:00
|
|
|
import sdk from '../../skinned-sdk';
|
2016-03-31 07:48:46 +08:00
|
|
|
|
2017-10-12 00:56:17 +08:00
|
|
|
const MessagePanel = sdk.getComponent('structures.MessagePanel');
|
2019-12-21 05:13:46 +08:00
|
|
|
import {MatrixClientPeg} from '../../../src/MatrixClientPeg';
|
2018-11-13 16:34:54 +08:00
|
|
|
import Matrix from 'matrix-js-sdk';
|
2016-03-31 07:48:46 +08:00
|
|
|
|
2019-12-17 19:24:37 +08:00
|
|
|
const test_utils = require('../../test-utils');
|
|
|
|
const mockclock = require('../../mock-clock');
|
2016-03-31 07:48:46 +08:00
|
|
|
|
2020-02-14 06:25:54 +08:00
|
|
|
import Adapter from "enzyme-adapter-react-16";
|
|
|
|
import { configure, mount } from "enzyme";
|
|
|
|
|
2019-03-21 01:43:19 +08:00
|
|
|
import Velocity from 'velocity-animate';
|
2019-12-18 01:26:12 +08:00
|
|
|
import MatrixClientContext from "../../../src/contexts/MatrixClientContext";
|
|
|
|
import RoomContext from "../../../src/contexts/RoomContext";
|
2020-11-06 00:27:41 +08:00
|
|
|
import DMRoomMap from "../../../src/utils/DMRoomMap";
|
2019-03-21 01:43:19 +08:00
|
|
|
|
2020-02-14 06:25:54 +08:00
|
|
|
configure({ adapter: new Adapter() });
|
|
|
|
|
2017-10-12 00:56:17 +08:00
|
|
|
let client;
|
2018-11-13 16:34:54 +08:00
|
|
|
const room = new Matrix.Room();
|
2016-11-15 02:20:15 +08:00
|
|
|
|
|
|
|
// wrap MessagePanel with a component which provides the MatrixClient in the context.
|
2020-08-29 19:14:16 +08:00
|
|
|
class WrappedMessagePanel extends React.Component {
|
|
|
|
state = {
|
|
|
|
resizeNotifier: new EventEmitter(),
|
|
|
|
};
|
|
|
|
|
|
|
|
render() {
|
2019-12-18 01:26:12 +08:00
|
|
|
return <MatrixClientContext.Provider value={client}>
|
2020-11-06 00:54:25 +08:00
|
|
|
<RoomContext.Provider value={{ canReact: true, canReply: true, room, roomId: room.roomId }}>
|
2019-12-18 01:26:12 +08:00
|
|
|
<MessagePanel room={room} {...this.props} resizeNotifier={this.state.resizeNotifier} />
|
|
|
|
</RoomContext.Provider>
|
|
|
|
</MatrixClientContext.Provider>;
|
2020-08-29 19:14:16 +08:00
|
|
|
}
|
|
|
|
}
|
2016-11-15 02:20:15 +08:00
|
|
|
|
2017-10-12 00:56:17 +08:00
|
|
|
describe('MessagePanel', function() {
|
|
|
|
const clock = mockclock.clock();
|
|
|
|
const realSetTimeout = window.setTimeout;
|
|
|
|
const events = mkEvents();
|
2016-03-31 07:48:46 +08:00
|
|
|
|
2016-04-07 23:47:17 +08:00
|
|
|
beforeEach(function() {
|
2019-12-16 19:12:48 +08:00
|
|
|
test_utils.stubClient();
|
2017-09-15 10:47:24 +08:00
|
|
|
client = MatrixClientPeg.get();
|
2016-04-20 04:10:23 +08:00
|
|
|
client.credentials = {userId: '@me:here'};
|
2017-10-29 15:43:52 +08:00
|
|
|
|
|
|
|
// HACK: We assume all settings want to be disabled
|
2019-12-16 19:55:01 +08:00
|
|
|
SettingsStore.getValue = jest.fn((arg) => {
|
|
|
|
return arg === "showDisplaynameChanges";
|
|
|
|
});
|
2019-03-21 01:43:19 +08:00
|
|
|
|
2019-03-21 02:11:42 +08:00
|
|
|
// This option clobbers the duration of all animations to be 1ms
|
2019-03-21 01:43:19 +08:00
|
|
|
// which makes unit testing a lot simpler (the animation doesn't
|
|
|
|
// complete without this even if we mock the clock and tick it
|
|
|
|
// what should be the correct amount of time).
|
|
|
|
Velocity.mock = true;
|
2020-11-06 00:27:41 +08:00
|
|
|
|
|
|
|
DMRoomMap.makeShared();
|
2016-04-07 23:47:17 +08:00
|
|
|
});
|
|
|
|
|
2017-07-07 22:26:55 +08:00
|
|
|
afterEach(function() {
|
2019-03-21 01:43:19 +08:00
|
|
|
delete Velocity.mock;
|
|
|
|
|
2016-03-31 07:48:46 +08:00
|
|
|
clock.uninstall();
|
|
|
|
});
|
|
|
|
|
|
|
|
function mkEvents() {
|
2017-10-12 00:56:17 +08:00
|
|
|
const events = [];
|
|
|
|
const ts0 = Date.now();
|
|
|
|
for (let i = 0; i < 10; i++) {
|
2016-03-31 07:48:46 +08:00
|
|
|
events.push(test_utils.mkMessage(
|
|
|
|
{
|
|
|
|
event: true, room: "!room:id", user: "@user:id",
|
|
|
|
ts: ts0 + i*1000,
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
return events;
|
|
|
|
}
|
|
|
|
|
2019-11-27 03:06:02 +08:00
|
|
|
|
|
|
|
// make a collection of events with some member events that should be collapsed
|
|
|
|
// with a MemberEventListSummary
|
|
|
|
function mkMelsEvents() {
|
|
|
|
const events = [];
|
|
|
|
const ts0 = Date.now();
|
|
|
|
|
|
|
|
let i = 0;
|
|
|
|
events.push(test_utils.mkMessage({
|
|
|
|
event: true, room: "!room:id", user: "@user:id",
|
|
|
|
ts: ts0 + ++i*1000,
|
|
|
|
}));
|
|
|
|
|
|
|
|
for (i = 0; i < 10; i++) {
|
|
|
|
events.push(test_utils.mkMembership({
|
|
|
|
event: true, room: "!room:id", user: "@user:id",
|
|
|
|
target: {
|
|
|
|
userId: "@user:id",
|
|
|
|
name: "Bob",
|
|
|
|
getAvatarUrl: () => {
|
|
|
|
return "avatar.jpeg";
|
|
|
|
},
|
|
|
|
},
|
|
|
|
ts: ts0 + i*1000,
|
|
|
|
mship: 'join',
|
|
|
|
prevMship: 'join',
|
|
|
|
name: 'A user',
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
|
|
|
|
events.push(test_utils.mkMessage({
|
|
|
|
event: true, room: "!room:id", user: "@user:id",
|
|
|
|
ts: ts0 + ++i*1000,
|
|
|
|
}));
|
|
|
|
|
|
|
|
return events;
|
|
|
|
}
|
|
|
|
|
2020-04-02 22:07:50 +08:00
|
|
|
// A list of membership events only with nothing else
|
|
|
|
function mkMelsEventsOnly() {
|
|
|
|
const events = [];
|
|
|
|
const ts0 = Date.now();
|
|
|
|
|
|
|
|
let i = 0;
|
|
|
|
|
|
|
|
for (i = 0; i < 10; i++) {
|
|
|
|
events.push(test_utils.mkMembership({
|
|
|
|
event: true, room: "!room:id", user: "@user:id",
|
|
|
|
target: {
|
|
|
|
userId: "@user:id",
|
|
|
|
name: "Bob",
|
|
|
|
getAvatarUrl: () => {
|
|
|
|
return "avatar.jpeg";
|
|
|
|
},
|
|
|
|
},
|
|
|
|
ts: ts0 + i*1000,
|
|
|
|
mship: 'join',
|
|
|
|
prevMship: 'join',
|
|
|
|
name: 'A user',
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
|
|
|
|
return events;
|
|
|
|
}
|
|
|
|
|
|
|
|
// A list of room creation, encryption, and invite events.
|
|
|
|
function mkCreationEvents() {
|
|
|
|
const mkEvent = test_utils.mkEvent;
|
|
|
|
const mkMembership = test_utils.mkMembership;
|
|
|
|
const roomId = "!someroom";
|
|
|
|
const alice = "@alice:example.org";
|
|
|
|
const ts0 = Date.now();
|
|
|
|
|
|
|
|
return [
|
|
|
|
mkEvent({
|
|
|
|
event: true,
|
|
|
|
type: "m.room.create",
|
|
|
|
room: roomId,
|
|
|
|
user: alice,
|
|
|
|
content: {
|
|
|
|
creator: alice,
|
|
|
|
room_version: "5",
|
|
|
|
predecessor: {
|
|
|
|
room_id: "!prevroom",
|
|
|
|
event_id: "$someevent",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
ts: ts0,
|
|
|
|
}),
|
|
|
|
mkMembership({
|
|
|
|
event: true,
|
|
|
|
room: roomId,
|
|
|
|
user: alice,
|
|
|
|
target: {
|
|
|
|
userId: alice,
|
|
|
|
name: "Alice",
|
|
|
|
getAvatarUrl: () => {
|
|
|
|
return "avatar.jpeg";
|
|
|
|
},
|
|
|
|
},
|
|
|
|
ts: ts0 + 1,
|
|
|
|
mship: 'join',
|
|
|
|
name: 'Alice',
|
|
|
|
}),
|
|
|
|
mkEvent({
|
|
|
|
event: true,
|
|
|
|
type: "m.room.join_rules",
|
|
|
|
room: roomId,
|
|
|
|
user: alice,
|
|
|
|
content: {
|
2020-08-29 19:14:16 +08:00
|
|
|
"join_rule": "invite",
|
2020-04-02 22:07:50 +08:00
|
|
|
},
|
|
|
|
ts: ts0 + 2,
|
|
|
|
}),
|
|
|
|
mkEvent({
|
|
|
|
event: true,
|
|
|
|
type: "m.room.history_visibility",
|
|
|
|
room: roomId,
|
|
|
|
user: alice,
|
|
|
|
content: {
|
|
|
|
"history_visibility": "invited",
|
|
|
|
},
|
|
|
|
ts: ts0 + 3,
|
|
|
|
}),
|
|
|
|
mkEvent({
|
|
|
|
event: true,
|
|
|
|
type: "m.room.encryption",
|
|
|
|
room: roomId,
|
|
|
|
user: alice,
|
|
|
|
content: {
|
|
|
|
"algorithm": "m.megolm.v1.aes-sha2",
|
|
|
|
},
|
|
|
|
ts: ts0 + 4,
|
|
|
|
}),
|
|
|
|
mkMembership({
|
|
|
|
event: true,
|
|
|
|
room: roomId,
|
|
|
|
user: alice,
|
|
|
|
skey: "@bob:example.org",
|
|
|
|
target: {
|
|
|
|
userId: "@bob:example.org",
|
|
|
|
name: "Bob",
|
|
|
|
getAvatarUrl: () => {
|
|
|
|
return "avatar.jpeg";
|
|
|
|
},
|
|
|
|
},
|
|
|
|
ts: ts0 + 5,
|
|
|
|
mship: 'invite',
|
|
|
|
name: 'Bob',
|
|
|
|
}),
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
function isReadMarkerVisible(rmContainer) {
|
|
|
|
return rmContainer && rmContainer.children.length > 0;
|
|
|
|
}
|
|
|
|
|
2016-03-31 07:48:46 +08:00
|
|
|
it('should show the events', function() {
|
2017-10-12 00:56:17 +08:00
|
|
|
const res = TestUtils.renderIntoDocument(
|
|
|
|
<WrappedMessagePanel className="cls" events={events} />,
|
2016-03-31 07:48:46 +08:00
|
|
|
);
|
|
|
|
|
|
|
|
// just check we have the right number of tiles for now
|
2017-10-12 00:56:17 +08:00
|
|
|
const tiles = TestUtils.scryRenderedComponentsWithType(
|
2016-03-31 07:48:46 +08:00
|
|
|
res, sdk.getComponent('rooms.EventTile'));
|
|
|
|
expect(tiles.length).toEqual(10);
|
|
|
|
});
|
|
|
|
|
2019-11-27 03:06:02 +08:00
|
|
|
it('should collapse adjacent member events', function() {
|
|
|
|
const res = TestUtils.renderIntoDocument(
|
|
|
|
<WrappedMessagePanel className="cls" events={mkMelsEvents()} />,
|
|
|
|
);
|
|
|
|
|
|
|
|
// just check we have the right number of tiles for now
|
|
|
|
const tiles = TestUtils.scryRenderedComponentsWithType(
|
|
|
|
res, sdk.getComponent('rooms.EventTile'),
|
|
|
|
);
|
|
|
|
expect(tiles.length).toEqual(2);
|
|
|
|
|
|
|
|
const summaryTiles = TestUtils.scryRenderedComponentsWithType(
|
|
|
|
res, sdk.getComponent('elements.MemberEventListSummary'),
|
|
|
|
);
|
|
|
|
expect(summaryTiles.length).toEqual(1);
|
|
|
|
});
|
|
|
|
|
2020-04-02 22:07:50 +08:00
|
|
|
it('should insert the read-marker in the right place', function() {
|
2017-10-12 00:56:17 +08:00
|
|
|
const res = TestUtils.renderIntoDocument(
|
2016-11-15 02:20:15 +08:00
|
|
|
<WrappedMessagePanel className="cls" events={events} readMarkerEventId={events[4].getId()}
|
2017-10-12 00:56:17 +08:00
|
|
|
readMarkerVisible={true} />,
|
2016-03-31 07:48:46 +08:00
|
|
|
);
|
|
|
|
|
2017-10-12 00:56:17 +08:00
|
|
|
const tiles = TestUtils.scryRenderedComponentsWithType(
|
2016-03-31 07:48:46 +08:00
|
|
|
res, sdk.getComponent('rooms.EventTile'));
|
|
|
|
|
|
|
|
// find the <li> which wraps the read marker
|
2017-10-12 00:56:17 +08:00
|
|
|
const rm = TestUtils.findRenderedDOMComponentWithClass(res, 'mx_RoomView_myReadMarker_container');
|
2016-03-31 07:48:46 +08:00
|
|
|
|
|
|
|
// it should follow the <li> which wraps the event tile for event 4
|
2017-10-12 00:56:17 +08:00
|
|
|
const eventContainer = ReactDOM.findDOMNode(tiles[4]).parentNode;
|
2016-03-31 07:48:46 +08:00
|
|
|
expect(rm.previousSibling).toEqual(eventContainer);
|
|
|
|
});
|
|
|
|
|
2019-11-27 03:06:02 +08:00
|
|
|
it('should show the read-marker that fall in summarised events after the summary', function() {
|
|
|
|
const melsEvents = mkMelsEvents();
|
|
|
|
const res = TestUtils.renderIntoDocument(
|
|
|
|
<WrappedMessagePanel className="cls" events={melsEvents} readMarkerEventId={melsEvents[4].getId()}
|
|
|
|
readMarkerVisible={true} />,
|
|
|
|
);
|
|
|
|
|
|
|
|
const summary = TestUtils.findRenderedDOMComponentWithClass(res, 'mx_EventListSummary');
|
|
|
|
|
|
|
|
// find the <li> which wraps the read marker
|
|
|
|
const rm = TestUtils.findRenderedDOMComponentWithClass(res, 'mx_RoomView_myReadMarker_container');
|
|
|
|
|
|
|
|
expect(rm.previousSibling).toEqual(summary);
|
2020-04-02 22:07:50 +08:00
|
|
|
|
|
|
|
// read marker should be visible given props and not at the last event
|
|
|
|
expect(isReadMarkerVisible(rm)).toBeTruthy();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should hide the read-marker at the end of summarised events', function() {
|
|
|
|
const melsEvents = mkMelsEventsOnly();
|
|
|
|
const res = TestUtils.renderIntoDocument(
|
|
|
|
<WrappedMessagePanel className="cls" events={melsEvents} readMarkerEventId={melsEvents[9].getId()}
|
|
|
|
readMarkerVisible={true} />,
|
|
|
|
);
|
|
|
|
|
|
|
|
const summary = TestUtils.findRenderedDOMComponentWithClass(res, 'mx_EventListSummary');
|
|
|
|
|
|
|
|
// find the <li> which wraps the read marker
|
|
|
|
const rm = TestUtils.findRenderedDOMComponentWithClass(res, 'mx_RoomView_myReadMarker_container');
|
|
|
|
|
|
|
|
expect(rm.previousSibling).toEqual(summary);
|
|
|
|
|
|
|
|
// read marker should be hidden given props and at the last event
|
|
|
|
expect(isReadMarkerVisible(rm)).toBeFalsy();
|
2019-11-27 03:06:02 +08:00
|
|
|
});
|
|
|
|
|
2016-03-31 07:48:46 +08:00
|
|
|
it('shows a ghost read-marker when the read-marker moves', function(done) {
|
|
|
|
// fake the clock so that we can test the velocity animation.
|
|
|
|
clock.install();
|
|
|
|
clock.mockDate();
|
|
|
|
|
2017-10-12 00:56:17 +08:00
|
|
|
const parentDiv = document.createElement('div');
|
2016-03-31 07:48:46 +08:00
|
|
|
|
|
|
|
// first render with the RM in one place
|
2017-10-12 00:56:17 +08:00
|
|
|
let mp = ReactDOM.render(
|
2016-11-15 02:20:15 +08:00
|
|
|
<WrappedMessagePanel className="cls" events={events} readMarkerEventId={events[4].getId()}
|
2016-04-20 04:10:23 +08:00
|
|
|
readMarkerVisible={true}
|
2016-03-31 07:48:46 +08:00
|
|
|
/>, parentDiv);
|
|
|
|
|
2017-10-12 00:56:17 +08:00
|
|
|
const tiles = TestUtils.scryRenderedComponentsWithType(
|
2016-03-31 07:48:46 +08:00
|
|
|
mp, sdk.getComponent('rooms.EventTile'));
|
2017-10-12 00:56:17 +08:00
|
|
|
const tileContainers = tiles.map(function(t) {
|
2016-04-01 00:01:11 +08:00
|
|
|
return ReactDOM.findDOMNode(t).parentNode;
|
|
|
|
});
|
2016-03-31 07:48:46 +08:00
|
|
|
|
|
|
|
// find the <li> which wraps the read marker
|
2017-10-12 00:56:17 +08:00
|
|
|
const rm = TestUtils.findRenderedDOMComponentWithClass(mp, 'mx_RoomView_myReadMarker_container');
|
2016-04-01 00:01:11 +08:00
|
|
|
expect(rm.previousSibling).toEqual(tileContainers[4]);
|
2016-03-31 07:48:46 +08:00
|
|
|
|
|
|
|
// now move the RM
|
|
|
|
mp = ReactDOM.render(
|
2016-11-15 02:20:15 +08:00
|
|
|
<WrappedMessagePanel className="cls" events={events} readMarkerEventId={events[6].getId()}
|
2016-04-20 04:10:23 +08:00
|
|
|
readMarkerVisible={true}
|
2016-03-31 07:48:46 +08:00
|
|
|
/>, parentDiv);
|
|
|
|
|
|
|
|
// now there should be two RM containers
|
2017-10-12 00:56:17 +08:00
|
|
|
const found = TestUtils.scryRenderedDOMComponentsWithClass(mp, 'mx_RoomView_myReadMarker_container');
|
2016-03-31 07:48:46 +08:00
|
|
|
expect(found.length).toEqual(2);
|
2016-04-20 04:10:23 +08:00
|
|
|
|
2016-03-31 07:48:46 +08:00
|
|
|
// the first should be the ghost
|
2016-04-01 00:01:11 +08:00
|
|
|
expect(found[0].previousSibling).toEqual(tileContainers[4]);
|
2017-10-12 00:56:17 +08:00
|
|
|
const hr = found[0].children[0];
|
2016-03-31 07:48:46 +08:00
|
|
|
|
|
|
|
// the second should be the real thing
|
2016-04-01 00:01:11 +08:00
|
|
|
expect(found[1].previousSibling).toEqual(tileContainers[6]);
|
2016-03-31 07:48:46 +08:00
|
|
|
|
|
|
|
// advance the clock, and then let the browser run an animation frame,
|
|
|
|
// to let the animation start
|
|
|
|
clock.tick(1500);
|
2016-04-20 04:10:23 +08:00
|
|
|
|
2016-03-31 07:48:46 +08:00
|
|
|
realSetTimeout(() => {
|
|
|
|
// then advance it again to let it complete
|
|
|
|
clock.tick(1000);
|
|
|
|
realSetTimeout(() => {
|
|
|
|
// the ghost should now have finished
|
2016-03-31 08:01:49 +08:00
|
|
|
expect(hr.style.opacity).toEqual('0');
|
2016-03-31 07:48:46 +08:00
|
|
|
done();
|
|
|
|
}, 100);
|
|
|
|
}, 100);
|
|
|
|
});
|
2020-02-14 06:25:54 +08:00
|
|
|
|
|
|
|
it('should collapse creation events', function() {
|
2020-04-02 22:07:50 +08:00
|
|
|
const events = mkCreationEvents();
|
2020-02-14 06:25:54 +08:00
|
|
|
const res = mount(
|
|
|
|
<WrappedMessagePanel className="cls" events={events} />,
|
|
|
|
);
|
|
|
|
|
|
|
|
// we expect that
|
|
|
|
// - the room creation event, the room encryption event, and Alice inviting Bob,
|
|
|
|
// should be outside of the room creation summary
|
|
|
|
// - all other events should be inside the room creation summary
|
|
|
|
|
|
|
|
const tiles = res.find(sdk.getComponent('views.rooms.EventTile'));
|
|
|
|
|
|
|
|
expect(tiles.at(0).props().mxEvent.getType()).toEqual("m.room.create");
|
|
|
|
expect(tiles.at(1).props().mxEvent.getType()).toEqual("m.room.encryption");
|
|
|
|
|
|
|
|
const summaryTiles = res.find(sdk.getComponent('views.elements.EventListSummary'));
|
|
|
|
const summaryTile = summaryTiles.at(0);
|
|
|
|
|
|
|
|
const summaryEventTiles = summaryTile.find(sdk.getComponent('views.rooms.EventTile'));
|
|
|
|
// every event except for the room creation, room encryption, and Bob's
|
|
|
|
// invite event should be in the event summary
|
|
|
|
expect(summaryEventTiles.length).toEqual(tiles.length - 3);
|
|
|
|
});
|
2020-04-02 22:07:50 +08:00
|
|
|
|
|
|
|
it('should hide read-marker at the end of creation event summary', function() {
|
|
|
|
const events = mkCreationEvents();
|
|
|
|
const res = mount(
|
|
|
|
<WrappedMessagePanel
|
|
|
|
className="cls"
|
|
|
|
events={events}
|
|
|
|
readMarkerEventId={events[5].getId()}
|
|
|
|
readMarkerVisible={true}
|
|
|
|
/>,
|
|
|
|
);
|
|
|
|
|
|
|
|
// find the <li> which wraps the read marker
|
|
|
|
const rm = res.find('.mx_RoomView_myReadMarker_container').getDOMNode();
|
|
|
|
|
|
|
|
const rows = res.find('.mx_RoomView_MessageList').children();
|
|
|
|
expect(rows.length).toEqual(6);
|
|
|
|
expect(rm.previousSibling).toEqual(rows.at(4).getDOMNode());
|
|
|
|
|
|
|
|
// read marker should be hidden given props and at the last event
|
|
|
|
expect(isReadMarkerVisible(rm)).toBeFalsy();
|
|
|
|
});
|
2016-03-31 07:48:46 +08:00
|
|
|
});
|