Fix TimelinePanel-test over-driving Thread model into compliance (#11198)

This commit is contained in:
Michael Telatynski 2023-07-07 09:48:06 +01:00 committed by GitHub
parent 706a42f390
commit 118ee89f9e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -851,22 +851,22 @@ describe("TimelinePanel", () => {
}); });
it("updates thread previews", async () => { it("updates thread previews", async () => {
root.setUnsigned({ mocked(client.supportsThreads).mockReturnValue(true);
"m.relations": { reply1.getContent()["m.relates_to"] = {
[THREAD_RELATION_TYPE.name]: { rel_type: RelationType.Thread,
latest_event: reply1.event, event_id: root.getId(),
count: 1, };
current_user_participated: true, reply2.getContent()["m.relates_to"] = {
}, rel_type: RelationType.Thread,
}, event_id: root.getId(),
}); };
const thread = room.createThread(root.getId()!, root, [], true); const thread = room.createThread(root.getId()!, root, [], true);
// So that we do not have to mock the thread loading // So that we do not have to mock the thread loading
thread.initialEventsFetched = true; thread.initialEventsFetched = true;
// @ts-ignore // @ts-ignore
thread.fetchEditsWhereNeeded = () => Promise.resolve(); thread.fetchEditsWhereNeeded = () => Promise.resolve();
await thread.addEvent(reply1, true); await thread.addEvent(reply1, false, true);
await allThreads.getLiveTimeline().addEvent(thread.rootEvent!, { toStartOfTimeline: true }); await allThreads.getLiveTimeline().addEvent(thread.rootEvent!, { toStartOfTimeline: true });
const replyToEvent = jest.spyOn(thread, "replyToEvent", "get"); const replyToEvent = jest.spyOn(thread, "replyToEvent", "get");
@ -879,16 +879,6 @@ describe("TimelinePanel", () => {
await dom.findByText("ReplyEvent1"); await dom.findByText("ReplyEvent1");
expect(replyToEvent).toHaveBeenCalled(); expect(replyToEvent).toHaveBeenCalled();
root.setUnsigned({
"m.relations": {
[THREAD_RELATION_TYPE.name]: {
latest_event: reply2.event,
count: 2,
current_user_participated: true,
},
},
});
replyToEvent.mockClear(); replyToEvent.mockClear();
await thread.addEvent(reply2, false, true); await thread.addEvent(reply2, false, true);
await dom.findByText("RootEvent"); await dom.findByText("RootEvent");