Fix broken Timeline panel jest test (#11827)

* Fix broken test

* Set localTimeStamp for each event
This commit is contained in:
R Midhun Suresh 2023-11-03 20:06:06 +05:30 committed by GitHub
parent f48cee238a
commit 9bb50119c7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -89,16 +89,16 @@ const getProps = (room: Room, events: MatrixEvent[]): TimelinePanel["props"] =>
const mockEvents = (room: Room, count = 2): MatrixEvent[] => { const mockEvents = (room: Room, count = 2): MatrixEvent[] => {
const events: MatrixEvent[] = []; const events: MatrixEvent[] = [];
for (let index = 0; index < count; index++) { for (let index = 0; index < count; index++) {
events.push( const event = new MatrixEvent({
new MatrixEvent({
room_id: room.roomId, room_id: room.roomId,
event_id: `${room.roomId}_event_${index}`, event_id: `${room.roomId}_event_${index}`,
type: EventType.RoomMessage, type: EventType.RoomMessage,
sender: "userId", sender: "userId",
content: createMessageEventContent("`Event${index}`"), content: createMessageEventContent("`Event${index}`"),
origin_server_ts: index, origin_server_ts: index,
}), });
); event.localTimestamp = index;
events.push(event);
} }
return events; return events;
@ -546,12 +546,14 @@ describe("TimelinePanel", () => {
event_id: `virtualCallEvent1`, event_id: `virtualCallEvent1`,
origin_server_ts: 0, origin_server_ts: 0,
}); });
virtualCallInvite.localTimestamp = 2;
const virtualCallMetaEvent = new MatrixEvent({ const virtualCallMetaEvent = new MatrixEvent({
type: "org.matrix.call.sdp_stream_metadata_changed", type: "org.matrix.call.sdp_stream_metadata_changed",
room_id: virtualRoom.roomId, room_id: virtualRoom.roomId,
event_id: `virtualCallEvent2`, event_id: `virtualCallEvent2`,
origin_server_ts: 0, origin_server_ts: 0,
}); });
virtualCallMetaEvent.localTimestamp = 2;
const virtualEvents = [virtualCallInvite, ...mockEvents(virtualRoom), virtualCallMetaEvent]; const virtualEvents = [virtualCallInvite, ...mockEvents(virtualRoom), virtualCallMetaEvent];
const { timelineSet: overlayTimelineSet } = getProps(virtualRoom, virtualEvents); const { timelineSet: overlayTimelineSet } = getProps(virtualRoom, virtualEvents);
@ -562,7 +564,6 @@ describe("TimelinePanel", () => {
overlayTimelineSetFilter={isCallEvent} overlayTimelineSetFilter={isCallEvent}
/>, />,
); );
await waitFor(() => await waitFor(() =>
expectEvents(container, [ expectEvents(container, [
// main timeline events are included // main timeline events are included