Rewrite doesRoomOrThreadHaveUnreadMessages to use the receipt rewrite from js-sdk (#11903)

* Rewrite doesRoomOrThreadHaveUnreadMessages to use the receipt rewrite from js-sdk

* Remove unit tests that rely on receipt timestamps

Previously, if we found a receipt for an unknown event, we would use the
receipt timestamp and declare all events before that time to be read.
Now, we ignore such "dangling" receipts until we find the event they
refer to.

This new behaviour is more correct, but does lead to more messages being
considered unread.

This commit deletes tests that checked for the old behaviour.

* Check for a missing thread in determineUnreadState

* Fix incorrect way to find room timeline

* More realistic test setup to support new receipt code

* Update snapshot to expect a room to be unread when there are no receipts

* Formatting fixes

* Update snapshot to show menu and notif button

* Disable some flaky tests

* Disable some flaky tests

* Fix test to make a threaded receipt for an event that is actually in the thread

---------

Co-authored-by: Florian Duros <florianduros@element.io>
Co-authored-by: Florian Duros <florian.duros@ormaz.fr>
This commit is contained in:
Andy Balaam 2023-11-29 13:36:52 +00:00 committed by GitHub
parent e207798a8f
commit 8b7f49e74e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 230 additions and 234 deletions

View file

@ -134,7 +134,7 @@ describe("Read receipts", () => {
goTo(room1);
assertStillRead(room2);
});
it("Editing a message after marking as read makes the room unread", () => {
it("Editing a message after marking as read leaves the room read", () => {
// Given the room is marked as read
goTo(room1);
receiveMessages(room2, ["Msg1"]);
@ -145,7 +145,7 @@ describe("Read receipts", () => {
// When a message is edited
receiveMessages(room2, [editOf("Msg1", "Msg1 Edit1")]);
// Then the room remains unread
// Then the room remains read
assertStillRead(room2);
});
it("Editing a reply after reading it makes the room unread", () => {
@ -264,8 +264,7 @@ describe("Read receipts", () => {
assertStillRead(room2);
assertReadThread("Msg1");
});
// XXX: fails because the unread dot remains after marking as read
it.skip("Marking a room as read after an edit in a thread makes it read", () => {
it("Marking a room as read after an edit in a thread makes it read", () => {
// Given an edit in a thread is making the room unread
goTo(room1);
receiveMessages(room2, ["Msg1", threadedOff("Msg1", "Resp1"), editOf("Resp1", "Edit1")]);
@ -277,7 +276,7 @@ describe("Read receipts", () => {
// Then it is read
assertRead(room2);
});
// XXX: fails because the unread dot remains after marking as read
// XXX: flaky
it.skip("Editing a thread message after marking as read leaves the room read", () => {
// Given a room is marked as read
goTo(room1);
@ -292,9 +291,9 @@ describe("Read receipts", () => {
// Then the room becomes unread
assertStillRead(room2);
});
// XXX: fails because we see a dot instead of an unread number - probably the server and client disagree
// XXX: flaky
it.skip("A room with an edited threaded message is still read after restart", () => {
// Given an edit in a thread is making a room unread
// Given an edit in a thread is leaving a room read
goTo(room1);
receiveMessages(room2, ["Msg1", threadedOff("Msg1", "Resp1")]);
markAsRead(room2);
@ -304,7 +303,7 @@ describe("Read receipts", () => {
// When I restart
saveAndReload();
// Then is it still unread
// Then is it still read
assertRead(room2);
});
it("A room where all threaded edits are read is still read after restart", () => {
@ -319,11 +318,11 @@ describe("Read receipts", () => {
saveAndReload();
assertRead(room2);
});
// XXX: fails because we see a dot instead of an unread number - probably the server and client disagree
// XXX: fails because the room becomes unread after restart
it.skip("A room where all threaded edits are marked as read is still read after restart", () => {
goTo(room1);
receiveMessages(room2, ["Msg1", threadedOff("Msg1", "Resp1"), editOf("Resp1", "Edit1")]);
assertUnread(room2, 3);
assertUnread(room2, 2);
markAsRead(room2);
assertRead(room2);
@ -336,7 +335,8 @@ describe("Read receipts", () => {
});
describe("thread roots", () => {
it("An edit of a thread root leaves the room read", () => {
// XXX: flaky
it.skip("An edit of a thread root leaves the room read", () => {
// Given I have read a thread
goTo(room1);
receiveMessages(room2, ["Msg1", threadedOff("Msg1", "Resp1")]);
@ -392,8 +392,7 @@ describe("Read receipts", () => {
// Then the room stays read
assertStillRead(room2);
});
// XXX: fails because the room has an unread dot after I marked it as read
it.skip("Marking a room as read after an edit of a thread root keeps it read", () => {
it("Marking a room as read after an edit of a thread root keeps it read", () => {
// Given a fully-read thread exists
goTo(room2);
receiveMessages(room2, ["Msg1", threadedOff("Msg1", "Resp1")]);
@ -402,10 +401,11 @@ describe("Read receipts", () => {
goTo(room1);
assertRead(room2);
// When the thread root is edited
receiveMessages(room2, [editOf("Msg1", "Msg1 Edit1")]);
// When the thread root is edited (and I receive another message
// to allow Mark as read)
receiveMessages(room2, [editOf("Msg1", "Msg1 Edit1"), "Msg2"]);
// And I mark the room as read
// And when I mark the room as read
markAsRead(room2);
// Then the room becomes read and stays read
@ -413,7 +413,7 @@ describe("Read receipts", () => {
goTo(room1);
assertStillRead(room2);
});
// XXX: fails because the room has an unread dot after I marked it as read
// XXX: flaky
it.skip("Editing a thread root that is a reply after marking as read leaves the room read", () => {
// Given a thread based on a reply exists and is read because it is marked as read
goTo(room1);
@ -423,14 +423,14 @@ describe("Read receipts", () => {
assertRead(room2);
// When I edit the thread root
receiveMessages(room1, [editOf("Reply", "Edited Reply")]);
receiveMessages(room2, [editOf("Reply", "Edited Reply")]);
// Then the room is read
assertStillRead(room2);
// And the thread is read
goTo(room2);
assertReadThread("EditedReply");
assertReadThread("Edited Reply");
});
it("Marking a room as read after an edit of a thread root that is a reply leaves it read", () => {
// Given a thread based on a reply exists and the reply has been edited

View file

@ -188,7 +188,7 @@ describe("Read receipts", () => {
});
describe("Paging up", () => {
// Flaky test https://github.com/vector-im/element-web/issues/26437
// XXX: Fails because flaky test https://github.com/vector-im/element-web/issues/26437
it.skip("Paging up through old messages after a room is read leaves the room read", () => {
// Given lots of messages are in the room, but we have read them
goTo(room1);

View file

@ -221,6 +221,8 @@ describe("Read receipts", () => {
assertRead(room2);
});
// XXX: fails because the room remains unread even though I sent a message
// Note: this test should not re-use the same MatrixClient - it
// should create a new one logged in as the same user.
it.skip("Me sending a message from a different client marks room as read", () => {
// Given I have unread messages
goTo(room1);
@ -345,8 +347,7 @@ describe("Read receipts", () => {
// Then thread does appear unread
assertUnreadThread("Msg1");
});
// XXX: fails because the room is still "bold" even though the notification counts all disappear
it.skip("Marking a room with unread threads as read makes it read", () => {
it("Marking a room with unread threads as read makes it read", () => {
// Given I have an unread thread
goTo(room1);
receiveMessages(room2, ["Msg1", threadedOff("Msg1", "Resp1"), threadedOff("Msg1", "Resp2")]);
@ -358,8 +359,7 @@ describe("Read receipts", () => {
// Then the room is read
assertRead(room2);
});
// XXX: fails for the same reason as "Marking a room with unread threads as read makes it read"
it.skip("Sending a new thread message after marking as read makes it unread", () => {
it("Sending a new thread message after marking as read makes it unread", () => {
// Given a thread exists
goTo(room1);
receiveMessages(room2, ["Msg1", threadedOff("Msg1", "Resp1"), threadedOff("Msg1", "Resp2")]);
@ -374,8 +374,7 @@ describe("Read receipts", () => {
// Then the room becomes unread
assertUnread(room2, 1);
});
// XXX: fails for the same reason as "Marking a room with unread threads as read makes it read"
it.skip("Sending a new different-thread message after marking as read makes it unread", () => {
it("Sending a new different-thread message after marking as read makes it unread", () => {
// Given 2 threads exist, and Thread2 has the latest message in it
goTo(room1);
receiveMessages(room2, ["Thread1", "Thread2", threadedOff("Thread1", "t1a")]);