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

Commit e76a37e

Browse files
authored
Update tests in anticipation of matrix-js-sdk#3901 (#11956)
* Update tests in anticipation of matrix-js-sdk#3901 * Formatting
1 parent 83f0650 commit e76a37e

File tree

2 files changed

+58
-5
lines changed

2 files changed

+58
-5
lines changed

test/Unread-test.ts

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,22 @@ describe("Unread", () => {
228228
});
229229
room.addReceipt(receipt);
230230

231+
// Create a read thread, so we don't consider all threads read
232+
// because there are no threaded read receipts.
233+
const { rootEvent, events } = mkThread({ room, client, authorId: myId, participantUserIds: [aliceId] });
234+
const receipt2 = new MatrixEvent({
235+
type: "m.receipt",
236+
room_id: "!foo:bar",
237+
content: {
238+
[events[events.length - 1].getId()!]: {
239+
[ReceiptType.Read]: {
240+
[myId]: { ts: 1, thread_id: rootEvent.getId() },
241+
},
242+
},
243+
},
244+
});
245+
room.addReceipt(receipt2);
246+
231247
// Create a thread as a different user.
232248
mkThread({ room, client, authorId: myId, participantUserIds: [aliceId] });
233249

@@ -315,7 +331,7 @@ describe("Unread", () => {
315331
content: {
316332
[events[0].getId()!]: {
317333
[ReceiptType.Read]: {
318-
[myId]: { ts: 1, threadId: rootEvent.getId()! },
334+
[myId]: { ts: 1, thread_id: rootEvent.getId()! },
319335
},
320336
},
321337
},
@@ -325,7 +341,8 @@ describe("Unread", () => {
325341
expect(doesRoomHaveUnreadMessages(room)).toBe(true);
326342
});
327343

328-
it("returns false when the event for a thread receipt can't be found, but the receipt ts is late", () => {
344+
// Fails with current implementation. Will be fixed or replaced after matrix-js-sdk#3901
345+
it.skip("returns false when the event for a thread receipt can't be found, but the receipt ts is late", () => {
329346
// Given a room that is read
330347
let receipt = new MatrixEvent({
331348
type: "m.receipt",
@@ -356,7 +373,7 @@ describe("Unread", () => {
356373
content: {
357374
["UNKNOWN_EVENT_ID"]: {
358375
[ReceiptType.Read]: {
359-
[myId]: { ts: receiptTs, threadId: rootEvent.getId()! },
376+
[myId]: { ts: receiptTs, thread_id: rootEvent.getId()! },
360377
},
361378
},
362379
},
@@ -381,6 +398,27 @@ describe("Unread", () => {
381398
});
382399
room.addReceipt(receipt);
383400

401+
// Create a read thread, so we don't consider all threads read
402+
// because there are no threaded read receipts.
403+
const { rootEvent: rootEvent1, events: events1 } = mkThread({
404+
room,
405+
client,
406+
authorId: myId,
407+
participantUserIds: [aliceId],
408+
});
409+
const receipt2 = new MatrixEvent({
410+
type: "m.receipt",
411+
room_id: "!foo:bar",
412+
content: {
413+
[events1[events1.length - 1].getId()!]: {
414+
[ReceiptType.Read]: {
415+
[myId]: { ts: 1, thread_id: rootEvent1.getId() },
416+
},
417+
},
418+
},
419+
});
420+
room.addReceipt(receipt2);
421+
384422
// And a thread
385423
const { rootEvent, events } = mkThread({ room, client, authorId: myId, participantUserIds: [aliceId] });
386424

@@ -397,7 +435,7 @@ describe("Unread", () => {
397435
content: {
398436
["UNKNOWN_EVENT_ID"]: {
399437
[ReceiptType.Read]: {
400-
[myId]: { ts: receiptTs, threadId: rootEvent.getId()! },
438+
[myId]: { ts: receiptTs, thread_id: rootEvent.getId()! },
401439
},
402440
},
403441
},

test/components/views/right_panel/LegacyRoomHeaderButtons-test.tsx

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,21 @@ describe("LegacyRoomHeaderButtons-test.tsx", function () {
106106
authorId: client.getUserId()!,
107107
participantUserIds: ["@alice:example.org"],
108108
});
109+
// We need some receipt, otherwise we treat this thread as
110+
// "older than all threaded receipts" and consider it read.
111+
let receipt = new MatrixEvent({
112+
type: "m.receipt",
113+
room_id: room.roomId,
114+
content: {
115+
[events[0].getId()!]: {
116+
// Receipt for the first event in the thread
117+
[ReceiptType.Read]: {
118+
[client.getUserId()!]: { ts: 1, thread_id: rootEvent.getId() },
119+
},
120+
},
121+
},
122+
});
123+
room.addReceipt(receipt);
109124
expect(isIndicatorOfType(container, "bold")).toBe(true);
110125

111126
// Sending the last event should clear the notification.
@@ -145,7 +160,7 @@ describe("LegacyRoomHeaderButtons-test.tsx", function () {
145160
expect(isIndicatorOfType(container, "bold")).toBe(true);
146161

147162
// Sending a read receipt on an earlier event shouldn't do anything.
148-
let receipt = new MatrixEvent({
163+
receipt = new MatrixEvent({
149164
type: "m.receipt",
150165
room_id: room.roomId,
151166
content: {

0 commit comments

Comments
 (0)