From 14a622b1e8e2a608a3c32073e2b57e2835e4e393 Mon Sep 17 00:00:00 2001 From: Andy Balaam Date: Fri, 22 Sep 2023 11:21:41 +0100 Subject: [PATCH 1/4] Fix flaky test that assumes edits count as messages --- cypress/e2e/read-receipts/editing-messages.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cypress/e2e/read-receipts/editing-messages.spec.ts b/cypress/e2e/read-receipts/editing-messages.spec.ts index ef56f10cac..f8d8a081b0 100644 --- a/cypress/e2e/read-receipts/editing-messages.spec.ts +++ b/cypress/e2e/read-receipts/editing-messages.spec.ts @@ -371,7 +371,7 @@ describe("Read receipts", () => { it("A room where all threaded edits are read is still read after restart", () => { goTo(room2); receiveMessages(room2, ["Msg1", threadedOff("Msg1", "Resp1"), editOf("Resp1", "Edit1")]); - assertUnread(room2, 2); + assertUnread(room2, 1); openThread("Msg1"); assertRead(room2); goTo(room1); // Make sure we are looking at room1 after reload From 10eac43e24643fb502febe27f91bb6d78c39b2ed Mon Sep 17 00:00:00 2001 From: Andy Balaam Date: Fri, 22 Sep 2023 11:47:30 +0100 Subject: [PATCH 2/4] Fix flaky test that raced because we were in the room while the count changed --- .../read-receipts/editing-messages.spec.ts | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/cypress/e2e/read-receipts/editing-messages.spec.ts b/cypress/e2e/read-receipts/editing-messages.spec.ts index f8d8a081b0..97a90863da 100644 --- a/cypress/e2e/read-receipts/editing-messages.spec.ts +++ b/cypress/e2e/read-receipts/editing-messages.spec.ts @@ -23,6 +23,7 @@ import { HomeserverInstance } from "../../plugins/utils/homeserver"; import { assertRead, assertReadThread, + assertStillRead, assertUnread, assertUnreadThread, backToThreadsList, @@ -263,21 +264,17 @@ describe("Read receipts", () => { assertRead(room2); }); it("A room where all edits are read is still read after restart", () => { - // Given an edit made the room unread - goTo(room2); - receiveMessages(room2, ["Msg1"]); - assertRead(room2); - receiveMessages(room2, [editOf("Msg1", "Msg1 Edit1")]); + // Given a message was edited and read + goTo(room1); + receiveMessages(room2, ["Msg1", editOf("Msg1", "Msg1 Edit1")]); assertUnread(room2, 1); - - // When I mark it as read - markAsRead(room2); - - // Then the room becomes read + goTo(room2); assertRead(room2); - // And remains so after a reload + // When I reload saveAndReload(); + + // Then the room is still read assertRead(room2); }); }); From 25a462ad8e2c06314d20c578d310827d559eb3f5 Mon Sep 17 00:00:00 2001 From: Andy Balaam Date: Fri, 22 Sep 2023 12:06:33 +0100 Subject: [PATCH 3/4] Fix lint error --- cypress/e2e/read-receipts/editing-messages.spec.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/cypress/e2e/read-receipts/editing-messages.spec.ts b/cypress/e2e/read-receipts/editing-messages.spec.ts index 97a90863da..af0f758896 100644 --- a/cypress/e2e/read-receipts/editing-messages.spec.ts +++ b/cypress/e2e/read-receipts/editing-messages.spec.ts @@ -23,7 +23,6 @@ import { HomeserverInstance } from "../../plugins/utils/homeserver"; import { assertRead, assertReadThread, - assertStillRead, assertUnread, assertUnreadThread, backToThreadsList, From 4097844fed6de36f54cb19412e0d74287e82d268 Mon Sep 17 00:00:00 2001 From: Andy Balaam Date: Fri, 22 Sep 2023 11:51:26 +0100 Subject: [PATCH 4/4] Fix flake in high-level tests by not using markAsRead --- cypress/e2e/read-receipts/high-level.spec.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/cypress/e2e/read-receipts/high-level.spec.ts b/cypress/e2e/read-receipts/high-level.spec.ts index 39ea887fc2..76da807a4c 100644 --- a/cypress/e2e/read-receipts/high-level.spec.ts +++ b/cypress/e2e/read-receipts/high-level.spec.ts @@ -22,6 +22,7 @@ import type { MatrixClient, MatrixEvent } from "matrix-js-sdk/src/matrix"; import { HomeserverInstance } from "../../plugins/utils/homeserver"; import { assertRead, + assertStillRead, assertUnread, customEvent, goTo, @@ -157,18 +158,25 @@ describe("Read receipts", () => { assertRead(room2); }); it("Sending an important event after unimportant ones makes the room unread", () => { + // Given We have read the important messages goTo(room1); assertRead(room2); receiveMessages(room2, ["Msg1", "Msg2"]); assertUnread(room2, 2); - - markAsRead(room2); + goTo(room2); assertRead(room2); + goTo(room1); + // When we receive important messages receiveMessages(room2, [customEvent("org.custom.event", { body: "foobar" })]); - assertRead(room2); + // Then the room is still read + assertStillRead(room2); + + // And when we receive more important ones receiveMessages(room2, ["Hello"]); + + // The room is unread again assertUnread(room2, 1); }); it.skip("A receipt for the last unimportant event makes the room read, even if all are unimportant", () => {});