mirror of
https://github.com/vector-im/element-web.git
synced 2024-11-27 02:48:39 +08:00
c05c429803
Co-authored-by: github-merge-queue <118344674+github-merge-queue@users.noreply.github.com> Co-authored-by: github-merge-queue <github-merge-queue@users.noreply.github.com> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Florian Duros <florian.duros@ormaz.fr> Co-authored-by: Kim Brose <kim.brose@nordeck.net> Co-authored-by: Florian Duros <florianduros@element.io> Co-authored-by: R Midhun Suresh <hi@midhun.dev> Co-authored-by: dbkr <986903+dbkr@users.noreply.github.com> Co-authored-by: ElementRobot <releases@riot.im> Co-authored-by: dbkr <dbkr@users.noreply.github.com> Co-authored-by: David Baker <dbkr@users.noreply.github.com> Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> Co-authored-by: David Langley <davidl@element.io> Co-authored-by: Michael Weimann <michaelw@matrix.org> Co-authored-by: Timshel <Timshel@users.noreply.github.com> Co-authored-by: Sahil Silare <32628578+sahil9001@users.noreply.github.com> Co-authored-by: Will Hunt <will@half-shot.uk> Co-authored-by: Hubert Chathi <hubert@uhoreg.ca> Co-authored-by: Andrew Ferrazzutti <andrewf@element.io> Co-authored-by: Robin <robin@robin.town> Co-authored-by: Tulir Asokan <tulir@maunium.net>
225 lines
8.7 KiB
TypeScript
225 lines
8.7 KiB
TypeScript
/*
|
|
Copyright 2024 New Vector Ltd.
|
|
Copyright 2023 The Matrix.org Foundation C.I.C.
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only
|
|
Please see LICENSE files in the repository root for full details.
|
|
*/
|
|
|
|
/* See readme.md for tips on writing these tests. */
|
|
|
|
import { test } from ".";
|
|
|
|
test.describe("Read receipts", () => {
|
|
test.describe("redactions", () => {
|
|
test.describe("thread roots", () => {
|
|
test("Redacting a thread root after it was read leaves the room read", async ({
|
|
roomAlpha: room1,
|
|
roomBeta: room2,
|
|
util,
|
|
msg,
|
|
}) => {
|
|
test.slow();
|
|
|
|
// Given a thread exists and is read
|
|
await util.goTo(room1);
|
|
await util.receiveMessages(room2, [
|
|
"Root",
|
|
msg.threadedOff("Root", "Msg2"),
|
|
msg.threadedOff("Root", "Msg3"),
|
|
]);
|
|
await util.assertUnread(room2, 1);
|
|
await util.goTo(room2);
|
|
await util.openThread("Root");
|
|
await util.assertRead(room2);
|
|
await util.assertReadThread("Root");
|
|
|
|
// When someone redacts the thread root
|
|
await util.receiveMessages(room2, [msg.redactionOf("Root")]);
|
|
|
|
// Then the room is still read
|
|
await util.assertStillRead(room2);
|
|
});
|
|
|
|
/*
|
|
* Disabled for the same reason as "A thread with a read redaction is still read after restart"
|
|
* above
|
|
*/
|
|
test.skip("Redacting a thread root still allows us to read the thread", async ({
|
|
roomAlpha: room1,
|
|
roomBeta: room2,
|
|
util,
|
|
msg,
|
|
}) => {
|
|
// Given an unread thread exists
|
|
await util.goTo(room1);
|
|
await util.receiveMessages(room2, [
|
|
"Root",
|
|
msg.threadedOff("Root", "Msg2"),
|
|
msg.threadedOff("Root", "Msg3"),
|
|
]);
|
|
await util.assertUnread(room2, 1);
|
|
|
|
// When someone redacts the thread root
|
|
await util.receiveMessages(room2, [msg.redactionOf("Root")]);
|
|
|
|
// Then the room is still unread
|
|
await util.assertUnread(room2, 1);
|
|
|
|
// And I can open the thread and read it
|
|
await util.goTo(room2);
|
|
await util.assertRead(room2);
|
|
// The redacted message gets collapsed into, "foo was invited, joined and removed a message"
|
|
await util.openCollapsedMessage(1);
|
|
await util.openThread("Message deleted");
|
|
await util.assertRead(room2);
|
|
await util.assertReadThread("Root");
|
|
});
|
|
|
|
test("Sending a threaded message onto a redacted thread root leaves the room unread", async ({
|
|
roomAlpha: room1,
|
|
roomBeta: room2,
|
|
util,
|
|
msg,
|
|
}) => {
|
|
// Given a thread exists, is read and its root is redacted
|
|
await util.goTo(room1);
|
|
await util.receiveMessages(room2, [
|
|
"Root",
|
|
msg.threadedOff("Root", "Msg2"),
|
|
msg.threadedOff("Root", "Msg3"),
|
|
]);
|
|
await util.assertUnread(room2, 1);
|
|
await util.goTo(room2);
|
|
await util.openThread("Root");
|
|
await util.assertRead(room2);
|
|
await util.assertReadThread("Root");
|
|
await util.receiveMessages(room2, [msg.redactionOf("Root")]);
|
|
|
|
// When we receive a new message on it
|
|
await util.receiveMessages(room2, [msg.threadedOff("Root", "Msg4")]);
|
|
|
|
// Then the room is read but the thread is unread
|
|
await util.assertRead(room2);
|
|
await util.goTo(room2);
|
|
await util.assertUnreadThread("Message deleted");
|
|
});
|
|
|
|
test("Reacting to a redacted thread root leaves the room read", async ({
|
|
roomAlpha: room1,
|
|
roomBeta: room2,
|
|
util,
|
|
msg,
|
|
}) => {
|
|
// Given a thread exists, is read and the root was redacted
|
|
await util.goTo(room1);
|
|
await util.receiveMessages(room2, [
|
|
"Root",
|
|
msg.threadedOff("Root", "Msg2"),
|
|
msg.threadedOff("Root", "Msg3"),
|
|
]);
|
|
await util.assertUnread(room2, 1);
|
|
await util.goTo(room2);
|
|
await util.openThread("Root");
|
|
await util.assertRead(room2);
|
|
await util.assertReadThread("Root");
|
|
await util.receiveMessages(room2, [msg.redactionOf("Root")]);
|
|
|
|
// When I react to the old root
|
|
await util.receiveMessages(room2, [msg.reactionTo("Root", "y")]);
|
|
|
|
// Then the room is still read
|
|
await util.assertRead(room2);
|
|
await util.assertReadThread("Root");
|
|
});
|
|
|
|
test("Editing a redacted thread root leaves the room read", async ({
|
|
roomAlpha: room1,
|
|
roomBeta: room2,
|
|
util,
|
|
msg,
|
|
}) => {
|
|
// Given a thread exists, is read and the root was redacted
|
|
await util.goTo(room1);
|
|
await util.receiveMessages(room2, [
|
|
"Root",
|
|
msg.threadedOff("Root", "Msg2"),
|
|
msg.threadedOff("Root", "Msg3"),
|
|
]);
|
|
await util.assertUnread(room2, 1);
|
|
await util.goTo(room2);
|
|
await util.openThread("Root");
|
|
await util.assertRead(room2);
|
|
await util.assertReadThread("Root");
|
|
await util.receiveMessages(room2, [msg.redactionOf("Root")]);
|
|
|
|
// When I edit the old root
|
|
await util.receiveMessages(room2, [msg.editOf("Root", "New Root")]);
|
|
|
|
// Then the room is still read
|
|
await util.assertRead(room2);
|
|
// as is the thread
|
|
await util.assertReadThread("Root");
|
|
});
|
|
|
|
test("Replying to a redacted thread root makes the room unread", async ({
|
|
roomAlpha: room1,
|
|
roomBeta: room2,
|
|
util,
|
|
msg,
|
|
}) => {
|
|
// Given a thread exists, is read and the root was redacted
|
|
await util.goTo(room1);
|
|
await util.receiveMessages(room2, [
|
|
"Root",
|
|
msg.threadedOff("Root", "Msg2"),
|
|
msg.threadedOff("Root", "Msg3"),
|
|
]);
|
|
await util.assertUnread(room2, 1);
|
|
await util.goTo(room2);
|
|
await util.openThread("Root");
|
|
await util.assertRead(room2);
|
|
await util.assertReadThread("Root");
|
|
await util.receiveMessages(room2, [msg.redactionOf("Root")]);
|
|
|
|
// When I reply to the old root
|
|
await util.receiveMessages(room2, [msg.replyTo("Root", "Reply!")]);
|
|
|
|
// Then the room is unread
|
|
await util.assertUnread(room2, 1);
|
|
});
|
|
|
|
test("Reading a reply to a redacted thread root makes the room read", async ({
|
|
roomAlpha: room1,
|
|
roomBeta: room2,
|
|
util,
|
|
msg,
|
|
}) => {
|
|
// Given a thread exists, is read and the root was redacted, and
|
|
// someone replied to it
|
|
await util.goTo(room1);
|
|
await util.receiveMessages(room2, [
|
|
"Root",
|
|
msg.threadedOff("Root", "Msg2"),
|
|
msg.threadedOff("Root", "Msg3"),
|
|
]);
|
|
await util.assertUnread(room2, 1);
|
|
await util.goTo(room2);
|
|
await util.openThread("Root");
|
|
await util.assertRead(room2);
|
|
await util.assertReadThread("Root");
|
|
await util.receiveMessages(room2, [msg.redactionOf("Root")]);
|
|
await util.assertStillRead(room2);
|
|
await util.receiveMessages(room2, [msg.replyTo("Root", "Reply!")]);
|
|
await util.assertUnread(room2, 1);
|
|
|
|
// When I read the room
|
|
await util.goTo(room2);
|
|
|
|
// Then it becomes read
|
|
await util.assertRead(room2);
|
|
});
|
|
});
|
|
});
|
|
});
|