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

Update tests in anticipation of matrix-js-sdk#3901 #11956

Merged
merged 2 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 42 additions & 4 deletions test/Unread-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,22 @@ describe("Unread", () => {
});
room.addReceipt(receipt);

// Create a read thread, so we don't consider all threads read
// because there are no threaded read receipts.
const { rootEvent, events } = mkThread({ room, client, authorId: myId, participantUserIds: [aliceId] });
const receipt2 = new MatrixEvent({
type: "m.receipt",
room_id: "!foo:bar",
content: {
[events[events.length - 1].getId()!]: {
[ReceiptType.Read]: {
[myId]: { ts: 1, thread_id: rootEvent.getId() },
},
},
},
});
room.addReceipt(receipt2);

// Create a thread as a different user.
mkThread({ room, client, authorId: myId, participantUserIds: [aliceId] });

Expand Down Expand Up @@ -315,7 +331,7 @@ describe("Unread", () => {
content: {
[events[0].getId()!]: {
[ReceiptType.Read]: {
[myId]: { ts: 1, threadId: rootEvent.getId()! },
[myId]: { ts: 1, thread_id: rootEvent.getId()! },
},
},
},
Expand All @@ -325,7 +341,8 @@ describe("Unread", () => {
expect(doesRoomHaveUnreadMessages(room)).toBe(true);
});

it("returns false when the event for a thread receipt can't be found, but the receipt ts is late", () => {
// Fails with current implementation. Will be fixed or replaced after matrix-js-sdk#3901
it.skip("returns false when the event for a thread receipt can't be found, but the receipt ts is late", () => {
// Given a room that is read
let receipt = new MatrixEvent({
type: "m.receipt",
Expand Down Expand Up @@ -356,7 +373,7 @@ describe("Unread", () => {
content: {
["UNKNOWN_EVENT_ID"]: {
[ReceiptType.Read]: {
[myId]: { ts: receiptTs, threadId: rootEvent.getId()! },
[myId]: { ts: receiptTs, thread_id: rootEvent.getId()! },
},
},
},
Expand All @@ -381,6 +398,27 @@ describe("Unread", () => {
});
room.addReceipt(receipt);

// Create a read thread, so we don't consider all threads read
// because there are no threaded read receipts.
const { rootEvent: rootEvent1, events: events1 } = mkThread({
room,
client,
authorId: myId,
participantUserIds: [aliceId],
});
const receipt2 = new MatrixEvent({
type: "m.receipt",
room_id: "!foo:bar",
content: {
[events1[events1.length - 1].getId()!]: {
[ReceiptType.Read]: {
[myId]: { ts: 1, thread_id: rootEvent1.getId() },
},
},
},
});
room.addReceipt(receipt2);

// And a thread
const { rootEvent, events } = mkThread({ room, client, authorId: myId, participantUserIds: [aliceId] });

Expand All @@ -397,7 +435,7 @@ describe("Unread", () => {
content: {
["UNKNOWN_EVENT_ID"]: {
[ReceiptType.Read]: {
[myId]: { ts: receiptTs, threadId: rootEvent.getId()! },
[myId]: { ts: receiptTs, thread_id: rootEvent.getId()! },
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,20 @@ describe("LegacyRoomHeaderButtons-test.tsx", function () {
authorId: client.getUserId()!,
participantUserIds: ["@alice:example.org"],
});
// We need some receipt, otherwise we treat this thread as
// "older than all threaded receipts" and consider it read.
let receipt = new MatrixEvent({
type: "m.receipt",
room_id: room.roomId,
content: {
[events[0].getId()!]: { // Receipt for the first event in the thread
[ReceiptType.Read]: {
[client.getUserId()!]: { ts: 1, thread_id: rootEvent.getId() },
},
},
},
});
room.addReceipt(receipt);
expect(isIndicatorOfType(container, "bold")).toBe(true);

// Sending the last event should clear the notification.
Expand Down Expand Up @@ -145,7 +159,7 @@ describe("LegacyRoomHeaderButtons-test.tsx", function () {
expect(isIndicatorOfType(container, "bold")).toBe(true);

// Sending a read receipt on an earlier event shouldn't do anything.
let receipt = new MatrixEvent({
receipt = new MatrixEvent({
type: "m.receipt",
room_id: room.roomId,
content: {
Expand Down
Loading