2023-12-05 11:37:23 +01:00
|
|
|
/*
|
2024-09-09 15:57:16 +02:00
|
|
|
Copyright 2024 New Vector Ltd.
|
2023-12-05 11:37:23 +01:00
|
|
|
Copyright 2023 The Matrix.org Foundation C.I.C.
|
|
|
|
|
2024-09-09 15:57:16 +02:00
|
|
|
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only
|
|
|
|
Please see LICENSE files in the repository root for full details.
|
2023-12-05 11:37:23 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* See readme.md for tips on writing these tests. */
|
|
|
|
|
|
|
|
import { test } from ".";
|
|
|
|
|
2024-12-05 15:30:28 +01:00
|
|
|
test.describe("Read receipts", { tag: "@mergequeue" }, () => {
|
2023-12-05 11:37:23 +01:00
|
|
|
test.describe("redactions", () => {
|
|
|
|
test.describe("in threads", () => {
|
2023-12-12 13:38:13 +01:00
|
|
|
test("Redacting the threaded message pointed to by my receipt leaves the room read", async ({
|
2023-12-05 11:37:23 +01:00
|
|
|
roomAlpha: room1,
|
|
|
|
roomBeta: room2,
|
|
|
|
util,
|
|
|
|
msg,
|
|
|
|
}) => {
|
|
|
|
// Given I have some threads
|
|
|
|
await util.goTo(room1);
|
|
|
|
await util.receiveMessages(room2, [
|
2023-12-12 13:38:13 +01:00
|
|
|
"Root1",
|
|
|
|
msg.threadedOff("Root1", "ThreadMsg1"),
|
|
|
|
msg.threadedOff("Root1", "ThreadMsg2"),
|
2023-12-05 11:37:23 +01:00
|
|
|
"Root2",
|
|
|
|
msg.threadedOff("Root2", "Root2->A"),
|
|
|
|
]);
|
2024-04-29 17:30:19 +02:00
|
|
|
await util.assertUnread(room2, 2);
|
2023-12-05 11:37:23 +01:00
|
|
|
|
|
|
|
await util.goTo(room2);
|
2023-12-12 13:38:13 +01:00
|
|
|
await util.assertUnreadThread("Root1");
|
2024-04-29 17:30:19 +02:00
|
|
|
await util.assertUnreadThread("Root2");
|
|
|
|
|
|
|
|
// And I have read them
|
|
|
|
await util.assertUnreadThread("Root1");
|
2023-12-12 13:38:13 +01:00
|
|
|
await util.openThread("Root1");
|
2023-12-05 11:37:23 +01:00
|
|
|
await util.assertRead(room2);
|
2024-04-29 17:30:19 +02:00
|
|
|
await util.backToThreadsList();
|
|
|
|
await util.assertReadThread("Root1");
|
|
|
|
|
|
|
|
await util.openThread("Root2");
|
|
|
|
await util.assertReadThread("Root2");
|
2023-12-05 11:37:23 +01:00
|
|
|
await util.closeThreadsPanel();
|
|
|
|
await util.goTo(room1);
|
|
|
|
|
|
|
|
// When the latest message in a thread is redacted
|
|
|
|
await util.receiveMessages(room2, [msg.redactionOf("ThreadMsg2")]);
|
|
|
|
|
|
|
|
// Then the room and thread are still read
|
|
|
|
await util.assertStillRead(room2);
|
|
|
|
await util.goTo(room2);
|
2023-12-12 13:38:13 +01:00
|
|
|
await util.assertReadThread("Root1");
|
2023-12-05 11:37:23 +01:00
|
|
|
});
|
2024-04-29 17:30:19 +02:00
|
|
|
|
2023-12-11 15:53:00 +01:00
|
|
|
test("Reading an unread thread after a redaction of the latest message makes it read", async ({
|
2023-12-05 11:37:23 +01:00
|
|
|
roomAlpha: room1,
|
|
|
|
roomBeta: room2,
|
|
|
|
util,
|
|
|
|
msg,
|
|
|
|
}) => {
|
|
|
|
// Given an unread thread where the latest message was redacted
|
|
|
|
await util.goTo(room1);
|
|
|
|
await util.receiveMessages(room2, [
|
|
|
|
"Root",
|
|
|
|
msg.threadedOff("Root", "ThreadMsg1"),
|
|
|
|
msg.threadedOff("Root", "ThreadMsg2"),
|
|
|
|
]);
|
2024-04-29 17:30:19 +02:00
|
|
|
await util.assertUnread(room2, 1);
|
2023-12-05 11:37:23 +01:00
|
|
|
await util.receiveMessages(room2, [msg.redactionOf("ThreadMsg2")]);
|
2024-04-29 17:30:19 +02:00
|
|
|
await util.assertUnread(room2, 1);
|
2023-12-05 11:37:23 +01:00
|
|
|
await util.goTo(room2);
|
|
|
|
await util.assertUnreadThread("Root");
|
|
|
|
|
|
|
|
// When I read the thread
|
|
|
|
await util.openThread("Root");
|
|
|
|
await util.assertRead(room2);
|
|
|
|
await util.closeThreadsPanel();
|
|
|
|
await util.goTo(room1);
|
|
|
|
|
|
|
|
// Then the thread is read
|
|
|
|
await util.assertRead(room2);
|
|
|
|
await util.goTo(room2);
|
|
|
|
await util.assertReadThread("Root");
|
|
|
|
});
|
2024-04-29 17:30:19 +02:00
|
|
|
|
2023-12-11 15:53:00 +01:00
|
|
|
test("Reading an unread thread after a redaction of the latest message makes it read after restart", async ({
|
2023-12-05 11:37:23 +01:00
|
|
|
roomAlpha: room1,
|
|
|
|
roomBeta: room2,
|
|
|
|
util,
|
|
|
|
msg,
|
|
|
|
}) => {
|
|
|
|
// Given a redacted message is not counted in the unread count
|
|
|
|
await util.goTo(room1);
|
|
|
|
await util.receiveMessages(room2, [
|
|
|
|
"Root",
|
|
|
|
msg.threadedOff("Root", "ThreadMsg1"),
|
|
|
|
msg.threadedOff("Root", "ThreadMsg2"),
|
|
|
|
]);
|
2024-04-29 17:30:19 +02:00
|
|
|
await util.assertUnread(room2, 1);
|
2023-12-05 11:37:23 +01:00
|
|
|
await util.receiveMessages(room2, [msg.redactionOf("ThreadMsg2")]);
|
2024-04-29 17:30:19 +02:00
|
|
|
await util.assertUnread(room2, 1);
|
2023-12-05 11:37:23 +01:00
|
|
|
await util.goTo(room2);
|
|
|
|
await util.assertUnreadThread("Root");
|
|
|
|
await util.openThread("Root");
|
|
|
|
await util.assertRead(room2);
|
|
|
|
await util.closeThreadsPanel();
|
|
|
|
await util.goTo(room1);
|
|
|
|
await util.assertRead(room2);
|
|
|
|
await util.goTo(room2);
|
|
|
|
await util.assertReadThread("Root");
|
|
|
|
|
|
|
|
// When I restart
|
|
|
|
await util.saveAndReload();
|
|
|
|
|
2024-04-29 17:30:19 +02:00
|
|
|
// Then the room and thread are still read
|
2023-12-05 11:37:23 +01:00
|
|
|
await util.assertRead(room2);
|
2024-04-29 17:30:19 +02:00
|
|
|
await util.openThreadList();
|
|
|
|
await util.assertReadThread("Root");
|
2023-12-05 11:37:23 +01:00
|
|
|
});
|
2024-04-29 17:30:19 +02:00
|
|
|
|
2023-12-11 15:53:00 +01:00
|
|
|
test("Reading an unread thread after a redaction of an older message makes it read", async ({
|
2023-12-05 11:37:23 +01:00
|
|
|
roomAlpha: room1,
|
|
|
|
roomBeta: room2,
|
|
|
|
util,
|
|
|
|
msg,
|
|
|
|
}) => {
|
|
|
|
// Given an unread thread where an older message was redacted
|
|
|
|
await util.goTo(room1);
|
|
|
|
await util.receiveMessages(room2, [
|
|
|
|
"Root",
|
|
|
|
msg.threadedOff("Root", "ThreadMsg1"),
|
|
|
|
msg.threadedOff("Root", "ThreadMsg2"),
|
|
|
|
]);
|
2024-04-29 17:30:19 +02:00
|
|
|
await util.assertUnread(room2, 1);
|
2023-12-05 11:37:23 +01:00
|
|
|
await util.receiveMessages(room2, [msg.redactionOf("ThreadMsg1")]);
|
2024-04-29 17:30:19 +02:00
|
|
|
await util.assertUnread(room2, 1);
|
2023-12-05 11:37:23 +01:00
|
|
|
await util.goTo(room2);
|
|
|
|
await util.assertUnreadThread("Root");
|
|
|
|
|
|
|
|
// When I read the thread
|
|
|
|
await util.openThread("Root");
|
|
|
|
await util.assertRead(room2);
|
|
|
|
await util.closeThreadsPanel();
|
|
|
|
await util.goTo(room1);
|
|
|
|
|
|
|
|
// Then the thread is read
|
|
|
|
await util.assertRead(room2);
|
|
|
|
await util.goTo(room2);
|
|
|
|
await util.assertReadThread("Root");
|
|
|
|
});
|
2024-04-29 17:30:19 +02:00
|
|
|
|
2023-12-11 15:53:00 +01:00
|
|
|
test("Marking an unread thread as read after a redaction makes it read", async ({
|
2023-12-05 11:37:23 +01:00
|
|
|
roomAlpha: room1,
|
|
|
|
roomBeta: room2,
|
|
|
|
util,
|
|
|
|
msg,
|
|
|
|
}) => {
|
|
|
|
// Given an unread thread where an older message was redacted
|
|
|
|
await util.goTo(room1);
|
|
|
|
await util.receiveMessages(room2, [
|
|
|
|
"Root",
|
|
|
|
msg.threadedOff("Root", "ThreadMsg1"),
|
|
|
|
msg.threadedOff("Root", "ThreadMsg2"),
|
|
|
|
]);
|
2024-04-29 17:30:19 +02:00
|
|
|
await util.assertUnread(room2, 1);
|
2023-12-05 11:37:23 +01:00
|
|
|
await util.receiveMessages(room2, [msg.redactionOf("ThreadMsg1")]);
|
2024-04-29 17:30:19 +02:00
|
|
|
await util.assertUnread(room2, 1);
|
2023-12-05 11:37:23 +01:00
|
|
|
|
|
|
|
// When I mark the room as read
|
|
|
|
await util.markAsRead(room2);
|
|
|
|
await util.assertRead(room2);
|
|
|
|
|
|
|
|
// Then the thread is read
|
|
|
|
await util.assertRead(room2);
|
|
|
|
await util.goTo(room2);
|
|
|
|
await util.assertReadThread("Root");
|
|
|
|
});
|
2024-04-29 17:30:19 +02:00
|
|
|
|
2023-12-11 15:53:00 +01:00
|
|
|
test("Sending and redacting a message after marking the thread as read leaves it read", async ({
|
2023-12-05 11:37:23 +01:00
|
|
|
roomAlpha: room1,
|
|
|
|
roomBeta: room2,
|
|
|
|
util,
|
|
|
|
msg,
|
|
|
|
}) => {
|
|
|
|
// Given a thread exists and is marked as read
|
|
|
|
await util.goTo(room1);
|
|
|
|
await util.receiveMessages(room2, [
|
|
|
|
"Root",
|
|
|
|
msg.threadedOff("Root", "ThreadMsg1"),
|
|
|
|
msg.threadedOff("Root", "ThreadMsg2"),
|
|
|
|
]);
|
2024-04-29 17:30:19 +02:00
|
|
|
await util.assertUnread(room2, 1);
|
2023-12-05 11:37:23 +01:00
|
|
|
await util.markAsRead(room2);
|
|
|
|
await util.assertRead(room2);
|
|
|
|
|
|
|
|
// When I send and redact a message
|
|
|
|
await util.receiveMessages(room2, [msg.threadedOff("Root", "Msg3")]);
|
2024-04-29 17:30:19 +02:00
|
|
|
await util.goTo(room2);
|
|
|
|
await util.openThreadList();
|
|
|
|
await util.assertUnreadThread("Root");
|
2023-12-05 11:37:23 +01:00
|
|
|
await util.receiveMessages(room2, [msg.redactionOf("Msg3")]);
|
|
|
|
|
|
|
|
// Then the room and thread are read
|
|
|
|
await util.goTo(room2);
|
|
|
|
await util.assertReadThread("Root");
|
|
|
|
});
|
2024-04-29 17:30:19 +02:00
|
|
|
|
2023-12-11 15:53:00 +01:00
|
|
|
test("Redacting a message after marking the thread as read leaves it read", async ({
|
2023-12-05 11:37:23 +01:00
|
|
|
roomAlpha: room1,
|
|
|
|
roomBeta: room2,
|
|
|
|
util,
|
|
|
|
msg,
|
|
|
|
}) => {
|
|
|
|
// Given a thread exists and is marked as read
|
|
|
|
await util.goTo(room1);
|
|
|
|
await util.receiveMessages(room2, [
|
|
|
|
"Root",
|
|
|
|
msg.threadedOff("Root", "ThreadMsg1"),
|
|
|
|
msg.threadedOff("Root", "ThreadMsg2"),
|
|
|
|
]);
|
2024-04-29 17:30:19 +02:00
|
|
|
await util.assertUnread(room2, 1);
|
2023-12-05 11:37:23 +01:00
|
|
|
await util.markAsRead(room2);
|
|
|
|
await util.assertRead(room2);
|
|
|
|
|
|
|
|
// When I redact a message
|
|
|
|
await util.receiveMessages(room2, [msg.redactionOf("ThreadMsg1")]);
|
|
|
|
|
|
|
|
// Then the room and thread are read
|
|
|
|
await util.assertRead(room2);
|
|
|
|
await util.goTo(room2);
|
|
|
|
await util.assertReadThread("Root");
|
|
|
|
});
|
2024-04-29 17:30:19 +02:00
|
|
|
|
2023-12-12 13:38:13 +01:00
|
|
|
test("Reacting to a redacted message leaves the thread read", async ({
|
2023-12-05 11:37:23 +01:00
|
|
|
roomAlpha: room1,
|
|
|
|
roomBeta: room2,
|
|
|
|
util,
|
|
|
|
msg,
|
|
|
|
}) => {
|
|
|
|
// Given a message in a thread was redacted and everything is read
|
|
|
|
await util.goTo(room1);
|
|
|
|
await util.receiveMessages(room2, [
|
|
|
|
"Root",
|
|
|
|
msg.threadedOff("Root", "Msg2"),
|
|
|
|
msg.threadedOff("Root", "Msg3"),
|
|
|
|
]);
|
2024-04-29 17:30:19 +02:00
|
|
|
await util.assertUnread(room2, 1);
|
2023-12-05 11:37:23 +01:00
|
|
|
await util.receiveMessages(room2, [msg.redactionOf("Msg2")]);
|
|
|
|
await util.assertUnread(room2, 1);
|
2024-04-29 17:30:19 +02:00
|
|
|
await util.goTo(room2);
|
|
|
|
await util.assertRead(room2);
|
2023-12-05 11:37:23 +01:00
|
|
|
await util.openThread("Root");
|
|
|
|
await util.assertRead(room2);
|
2024-04-29 17:30:19 +02:00
|
|
|
await util.backToThreadsList();
|
|
|
|
await util.assertReadThread("Root");
|
2023-12-05 11:37:23 +01:00
|
|
|
await util.goTo(room1);
|
|
|
|
|
|
|
|
// When we receive a reaction to the redacted event
|
|
|
|
await util.receiveMessages(room2, [msg.reactionTo("Msg2", "z")]);
|
|
|
|
|
2024-04-29 17:30:19 +02:00
|
|
|
// Then the room is read
|
2023-12-05 11:37:23 +01:00
|
|
|
await util.assertStillRead(room2);
|
2024-04-29 17:30:19 +02:00
|
|
|
await util.goTo(room2);
|
|
|
|
await util.openThreadList();
|
|
|
|
await util.assertReadThread("Root");
|
2023-12-05 11:37:23 +01:00
|
|
|
});
|
2024-04-29 17:30:19 +02:00
|
|
|
|
2023-12-11 15:53:00 +01:00
|
|
|
test("Editing a redacted message leaves the thread read", async ({
|
2023-12-05 11:37:23 +01:00
|
|
|
roomAlpha: room1,
|
|
|
|
roomBeta: room2,
|
|
|
|
util,
|
|
|
|
msg,
|
|
|
|
}) => {
|
|
|
|
// Given a message in a thread was redacted and everything is read
|
|
|
|
await util.goTo(room1);
|
|
|
|
await util.receiveMessages(room2, [
|
|
|
|
"Root",
|
|
|
|
msg.threadedOff("Root", "Msg2"),
|
|
|
|
msg.threadedOff("Root", "Msg3"),
|
|
|
|
]);
|
2024-04-29 17:30:19 +02:00
|
|
|
await util.assertUnread(room2, 1);
|
2023-12-05 11:37:23 +01:00
|
|
|
await util.receiveMessages(room2, [msg.redactionOf("Msg2")]);
|
|
|
|
await util.assertUnread(room2, 1);
|
2024-04-29 17:30:19 +02:00
|
|
|
await util.goTo(room2);
|
2023-12-05 11:37:23 +01:00
|
|
|
await util.assertRead(room2);
|
2024-04-29 17:30:19 +02:00
|
|
|
await util.openThreadList();
|
|
|
|
await util.assertUnreadThread("Root");
|
|
|
|
await util.openThread("Root");
|
|
|
|
await util.assertReadThread("Root");
|
2023-12-05 11:37:23 +01:00
|
|
|
await util.goTo(room1);
|
|
|
|
|
|
|
|
// When we receive an edit of the redacted message
|
|
|
|
await util.receiveMessages(room2, [msg.editOf("Msg2", "New Msg2")]);
|
|
|
|
|
|
|
|
// Then the room is unread
|
|
|
|
await util.assertStillRead(room2);
|
2024-04-29 17:30:19 +02:00
|
|
|
// and so is the thread
|
|
|
|
await util.goTo(room2);
|
|
|
|
await util.openThreadList();
|
|
|
|
await util.assertReadThread("Root");
|
2023-12-05 11:37:23 +01:00
|
|
|
});
|
2024-04-29 17:30:19 +02:00
|
|
|
|
2023-12-11 15:53:00 +01:00
|
|
|
test("Reading a thread after a reaction to a redacted message marks the thread as read", async ({
|
2023-12-05 11:37:23 +01:00
|
|
|
roomAlpha: room1,
|
|
|
|
roomBeta: room2,
|
|
|
|
util,
|
|
|
|
msg,
|
|
|
|
}) => {
|
|
|
|
// Given a redacted message in a thread exists, but someone reacted to it before it was redacted
|
|
|
|
await util.goTo(room1);
|
|
|
|
await util.receiveMessages(room2, [
|
|
|
|
"Root",
|
|
|
|
msg.threadedOff("Root", "Msg2"),
|
|
|
|
msg.threadedOff("Root", "Msg3"),
|
|
|
|
msg.reactionTo("Msg3", "x"),
|
|
|
|
]);
|
2024-04-29 17:30:19 +02:00
|
|
|
await util.assertUnread(room2, 1);
|
2023-12-05 11:37:23 +01:00
|
|
|
await util.receiveMessages(room2, [msg.redactionOf("Msg3")]);
|
2024-04-29 17:30:19 +02:00
|
|
|
await util.assertUnread(room2, 1);
|
2023-12-05 11:37:23 +01:00
|
|
|
|
|
|
|
// When we read the thread
|
|
|
|
await util.goTo(room2);
|
|
|
|
await util.openThread("Root");
|
|
|
|
|
|
|
|
// Then the thread (and room) are read
|
|
|
|
await util.assertRead(room2);
|
|
|
|
await util.assertReadThread("Root");
|
|
|
|
});
|
2024-04-29 17:30:19 +02:00
|
|
|
|
2023-12-11 15:53:00 +01:00
|
|
|
test("Reading a thread containing a redacted, edited message marks the thread as read", async ({
|
2023-12-05 11:37:23 +01:00
|
|
|
roomAlpha: room1,
|
|
|
|
roomBeta: room2,
|
|
|
|
util,
|
|
|
|
msg,
|
|
|
|
}) => {
|
|
|
|
// Given a redacted message in a thread exists, but someone edited it before it was redacted
|
|
|
|
await util.goTo(room1);
|
|
|
|
await util.receiveMessages(room2, [
|
|
|
|
"Root",
|
|
|
|
msg.threadedOff("Root", "Msg2"),
|
|
|
|
msg.threadedOff("Root", "Msg3"),
|
|
|
|
msg.editOf("Msg3", "Msg3 Edited"),
|
|
|
|
]);
|
2024-04-29 17:30:19 +02:00
|
|
|
await util.assertUnread(room2, 1);
|
2023-12-05 11:37:23 +01:00
|
|
|
await util.receiveMessages(room2, [msg.redactionOf("Msg3")]);
|
|
|
|
|
|
|
|
// When we read the thread
|
|
|
|
await util.goTo(room2);
|
|
|
|
await util.openThread("Root");
|
|
|
|
|
|
|
|
// Then the thread (and room) are read
|
|
|
|
await util.assertRead(room2);
|
|
|
|
await util.assertReadThread("Root");
|
|
|
|
});
|
2024-04-29 17:30:19 +02:00
|
|
|
|
2023-12-18 22:05:06 +01:00
|
|
|
test("Reading a reply to a redacted message marks the thread as read", async ({
|
2023-12-05 11:37:23 +01:00
|
|
|
roomAlpha: room1,
|
|
|
|
roomBeta: room2,
|
|
|
|
util,
|
|
|
|
msg,
|
|
|
|
}) => {
|
|
|
|
// Given a redacted message in a thread exists, but someone replied before it was redacted
|
|
|
|
await util.goTo(room1);
|
|
|
|
await util.receiveMessages(room2, [
|
|
|
|
"Root",
|
|
|
|
msg.threadedOff("Root", "Msg2"),
|
|
|
|
msg.threadedOff("Root", "Msg3"),
|
|
|
|
msg.replyTo("Msg3", "Msg3Reply"),
|
|
|
|
]);
|
2024-04-29 17:30:19 +02:00
|
|
|
await util.assertUnread(room2, 1);
|
2023-12-05 11:37:23 +01:00
|
|
|
await util.receiveMessages(room2, [msg.redactionOf("Msg3")]);
|
|
|
|
|
|
|
|
// When we read the thread, creating a receipt that points at the edit
|
|
|
|
await util.goTo(room2);
|
|
|
|
await util.openThread("Root");
|
|
|
|
|
|
|
|
// Then the thread (and room) are read
|
|
|
|
await util.assertRead(room2);
|
|
|
|
await util.assertReadThread("Root");
|
|
|
|
});
|
2024-04-29 17:30:19 +02:00
|
|
|
|
2023-12-11 15:53:00 +01:00
|
|
|
test("Reading a thread root when its only message has been redacted leaves the room read", async ({
|
2023-12-05 11:37:23 +01:00
|
|
|
roomAlpha: room1,
|
|
|
|
roomBeta: room2,
|
|
|
|
util,
|
|
|
|
msg,
|
|
|
|
}) => {
|
|
|
|
// Given we had a thread
|
|
|
|
await util.goTo(room1);
|
|
|
|
await util.receiveMessages(room2, ["Root", msg.threadedOff("Root", "Msg2")]);
|
2024-04-29 17:30:19 +02:00
|
|
|
await util.assertUnread(room2, 1);
|
2023-12-05 11:37:23 +01:00
|
|
|
|
|
|
|
// And then redacted the message that makes it a thread
|
|
|
|
await util.receiveMessages(room2, [msg.redactionOf("Msg2")]);
|
|
|
|
await util.assertUnread(room2, 1);
|
|
|
|
|
|
|
|
// When we read the main timeline
|
|
|
|
await util.goTo(room2);
|
|
|
|
|
|
|
|
// Then the room is read
|
|
|
|
await util.assertRead(room2);
|
2024-04-29 17:30:19 +02:00
|
|
|
// and that thread is read
|
|
|
|
await util.openThreadList();
|
|
|
|
await util.assertReadThread("Root");
|
2023-12-05 11:37:23 +01:00
|
|
|
});
|
2024-04-29 17:30:19 +02:00
|
|
|
|
2023-12-21 17:57:22 +01:00
|
|
|
test("A thread with a redacted unread is still read after restart", async ({
|
2023-12-05 11:37:23 +01:00
|
|
|
roomAlpha: room1,
|
|
|
|
roomBeta: room2,
|
|
|
|
util,
|
|
|
|
msg,
|
|
|
|
}) => {
|
|
|
|
// Given I sent and redacted a message in an otherwise-read thread
|
|
|
|
await util.goTo(room1);
|
|
|
|
await util.receiveMessages(room2, [
|
|
|
|
"Root",
|
|
|
|
msg.threadedOff("Root", "ThreadMsg1"),
|
|
|
|
msg.threadedOff("Root", "ThreadMsg2"),
|
|
|
|
]);
|
2024-04-29 17:30:19 +02:00
|
|
|
await util.assertUnread(room2, 1);
|
2023-12-05 11:37:23 +01:00
|
|
|
await util.goTo(room2);
|
|
|
|
await util.openThread("Root");
|
|
|
|
await util.assertRead(room2);
|
|
|
|
await util.assertReadThread("Root");
|
|
|
|
await util.receiveMessages(room2, [msg.threadedOff("Root", "Msg3")]);
|
2024-04-29 17:30:19 +02:00
|
|
|
await util.assertRead(room2);
|
2023-12-05 11:37:23 +01:00
|
|
|
await util.receiveMessages(room2, [msg.redactionOf("Msg3")]);
|
|
|
|
await util.assertRead(room2);
|
|
|
|
await util.goTo(room2);
|
|
|
|
await util.assertReadThread("Root");
|
|
|
|
await util.goTo(room1);
|
|
|
|
|
|
|
|
// When I restart
|
|
|
|
await util.saveAndReload();
|
|
|
|
|
|
|
|
// Then the room and thread are still read
|
|
|
|
await util.assertRead(room2);
|
|
|
|
await util.goTo(room2);
|
|
|
|
await util.assertReadThread("Root");
|
|
|
|
});
|
2024-04-29 17:30:19 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Disabled: this doesn't seem to work as, at some point after syncing from cache, the redaction and redacted
|
|
|
|
* event get removed from the thread timeline such that we have no record of the events that the read receipt
|
|
|
|
* points to. I suspect this may have been passing by fluke before.
|
|
|
|
*/
|
|
|
|
test.skip("A thread with a read redaction is still read after restart", async ({
|
2023-12-05 11:37:23 +01:00
|
|
|
roomAlpha: room1,
|
|
|
|
roomBeta: room2,
|
|
|
|
util,
|
|
|
|
msg,
|
|
|
|
}) => {
|
|
|
|
// Given my receipt points at a redacted thread message
|
|
|
|
await util.goTo(room1);
|
|
|
|
await util.receiveMessages(room2, [
|
2023-12-12 13:38:13 +01:00
|
|
|
"Root1",
|
|
|
|
msg.threadedOff("Root1", "ThreadMsg1"),
|
|
|
|
msg.threadedOff("Root1", "ThreadMsg2"),
|
2023-12-05 11:37:23 +01:00
|
|
|
"Root2",
|
|
|
|
msg.threadedOff("Root2", "Root2->A"),
|
|
|
|
]);
|
2024-04-29 17:30:19 +02:00
|
|
|
await util.assertUnread(room2, 2);
|
2023-12-05 11:37:23 +01:00
|
|
|
await util.goTo(room2);
|
2023-12-12 13:38:13 +01:00
|
|
|
await util.assertUnreadThread("Root1");
|
|
|
|
await util.openThread("Root1");
|
2024-04-29 17:30:19 +02:00
|
|
|
await util.assertRead(room2);
|
2023-12-05 11:37:23 +01:00
|
|
|
await util.openThread("Root2");
|
|
|
|
await util.assertRead(room2);
|
|
|
|
await util.closeThreadsPanel();
|
|
|
|
await util.goTo(room1);
|
|
|
|
await util.assertRead(room2);
|
|
|
|
await util.receiveMessages(room2, [msg.redactionOf("ThreadMsg2")]);
|
|
|
|
await util.assertStillRead(room2);
|
|
|
|
await util.goTo(room2);
|
2023-12-12 13:38:13 +01:00
|
|
|
await util.assertReadThread("Root1");
|
2023-12-05 11:37:23 +01:00
|
|
|
|
|
|
|
// When I restart
|
|
|
|
await util.saveAndReload();
|
|
|
|
|
|
|
|
// Then the room is still read
|
|
|
|
await util.assertRead(room2);
|
2024-04-29 17:30:19 +02:00
|
|
|
// and so is the thread
|
|
|
|
await util.openThreadList();
|
|
|
|
await util.assertReadThread("Root1");
|
|
|
|
await util.assertReadThread("Root2");
|
2023-12-05 11:37:23 +01:00
|
|
|
});
|
2024-04-29 17:30:19 +02:00
|
|
|
|
2023-12-18 22:05:06 +01:00
|
|
|
test("A thread with an unread reply to a redacted message is still unread after restart", async ({
|
2023-12-05 11:37:23 +01:00
|
|
|
roomAlpha: room1,
|
|
|
|
roomBeta: room2,
|
|
|
|
util,
|
|
|
|
msg,
|
|
|
|
}) => {
|
|
|
|
// Given a redacted message in a thread exists, but someone replied before it was redacted
|
|
|
|
await util.goTo(room1);
|
|
|
|
await util.receiveMessages(room2, [
|
|
|
|
"Root",
|
|
|
|
msg.threadedOff("Root", "Msg2"),
|
|
|
|
msg.threadedOff("Root", "Msg3"),
|
|
|
|
msg.replyTo("Msg3", "Msg3Reply"),
|
|
|
|
]);
|
2024-04-29 17:30:19 +02:00
|
|
|
await util.assertUnread(room2, 1);
|
2023-12-05 11:37:23 +01:00
|
|
|
await util.receiveMessages(room2, [msg.redactionOf("Msg3")]);
|
|
|
|
|
|
|
|
// And we have read all this
|
|
|
|
await util.goTo(room2);
|
|
|
|
await util.openThread("Root");
|
|
|
|
await util.assertRead(room2);
|
|
|
|
await util.assertReadThread("Root");
|
|
|
|
|
|
|
|
// When I restart
|
|
|
|
await util.saveAndReload();
|
|
|
|
|
|
|
|
// Then the room is still read
|
|
|
|
await util.assertRead(room2);
|
|
|
|
await util.assertReadThread("Root");
|
|
|
|
});
|
2024-04-29 17:30:19 +02:00
|
|
|
|
2023-12-18 22:05:06 +01:00
|
|
|
test("A thread with a read reply to a redacted message is still read after restart", async ({
|
2023-12-05 11:37:23 +01:00
|
|
|
roomAlpha: room1,
|
|
|
|
roomBeta: room2,
|
|
|
|
util,
|
|
|
|
msg,
|
|
|
|
}) => {
|
|
|
|
// Given a redacted message in a thread exists, but someone replied before it was redacted
|
|
|
|
await util.goTo(room1);
|
|
|
|
await util.receiveMessages(room2, [
|
|
|
|
"Root",
|
|
|
|
msg.threadedOff("Root", "Msg2"),
|
|
|
|
msg.threadedOff("Root", "Msg3"),
|
|
|
|
msg.replyTo("Msg3", "Msg3Reply"),
|
|
|
|
]);
|
2024-04-29 17:30:19 +02:00
|
|
|
await util.assertUnread(room2, 1);
|
2023-12-05 11:37:23 +01:00
|
|
|
await util.receiveMessages(room2, [msg.redactionOf("Msg3")]);
|
|
|
|
|
|
|
|
// And I read it, so the room is read
|
|
|
|
await util.goTo(room2);
|
|
|
|
await util.openThread("Root");
|
|
|
|
await util.assertRead(room2);
|
|
|
|
await util.assertReadThread("Root");
|
|
|
|
|
|
|
|
// When I restart
|
|
|
|
await util.saveAndReload();
|
|
|
|
|
|
|
|
// Then the room is still read
|
|
|
|
await util.assertRead(room2);
|
|
|
|
await util.assertReadThread("Root");
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|