Fix threaded reply playwright tests (#12070)

It appears the bug with these tests was just that the MessageBuilder
wasn't setting the thread relation on the reply messages as this didn't
happen trying to repro it manually, so fix the builder and re-enable
the tests.

The flip side of this is that it implies buggy clients that don't
set thread relations properly will cause stuck notifs in Element Web.
I've filed this as https://github.com/element-hq/element-web/issues/26787
pull/28217/head
David Baker 2023-12-18 21:05:06 +00:00 committed by GitHub
parent ffb4239103
commit 24cda5fc59
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 6 deletions

View File

@ -155,10 +155,19 @@ export class MessageBuilder {
public async getContent(room: JSHandle<Room>): Promise<Record<string, unknown>> { public async getContent(room: JSHandle<Room>): Promise<Record<string, unknown>> {
const ev = await this.messageFinder.getMessage(room, targetMessage, true); const ev = await this.messageFinder.getMessage(room, targetMessage, true);
return ev.evaluate((ev, newMessage) => { return ev.evaluate((ev, newMessage) => {
const threadRel =
ev.getRelation()?.rel_type === "m.thread"
? {
rel_type: "m.thread",
event_id: ev.getRelation().event_id,
}
: {};
return { return {
"msgtype": "m.text", "msgtype": "m.text",
"body": newMessage, "body": newMessage,
"m.relates_to": { "m.relates_to": {
...threadRel,
"m.in_reply_to": { "m.in_reply_to": {
event_id: ev.getId(), event_id: ev.getId(),
}, },

View File

@ -642,8 +642,7 @@ test.describe("Read receipts", () => {
await util.assertRead(room2); await util.assertRead(room2);
await util.assertReadThread("Root"); await util.assertReadThread("Root");
}); });
// XXX: fails because the read count drops to 1 but not to zero (this is a genuine stuck unread case) test("Reading a reply to a redacted message marks the thread as read", async ({
test.skip("Reading a reply to a redacted message marks the thread as read", async ({
roomAlpha: room1, roomAlpha: room1,
roomBeta: room2, roomBeta: room2,
util, util,
@ -760,8 +759,7 @@ test.describe("Read receipts", () => {
// Then the room is still read // Then the room is still read
await util.assertRead(room2); await util.assertRead(room2);
}); });
// XXX: fails for the same reason as "Reading a reply to a redacted message marks the thread as read" test("A thread with an unread reply to a redacted message is still unread after restart", async ({
test.skip("A thread with an unread reply to a redacted message is still unread after restart", async ({
roomAlpha: room1, roomAlpha: room1,
roomBeta: room2, roomBeta: room2,
util, util,
@ -791,8 +789,7 @@ test.describe("Read receipts", () => {
await util.assertRead(room2); await util.assertRead(room2);
await util.assertReadThread("Root"); await util.assertReadThread("Root");
}); });
// XXX: fails for the same reason as "Reading a reply to a redacted message marks the thread as read test("A thread with a read reply to a redacted message is still read after restart", async ({
test.skip("A thread with a read reply to a redacted message is still read after restart", async ({
roomAlpha: room1, roomAlpha: room1,
roomBeta: room2, roomBeta: room2,
util, util,