Skip to content
Snippets Groups Projects
Commit 7e0a62f8 authored by Andy Balaam's avatar Andy Balaam
Browse files

Make edits more realistic in receipt tests

parent c7b0850f
No related tags found
No related merge requests found
......@@ -103,6 +103,11 @@ describe("Read receipts", () => {
});
}
function backToThreadsList() {
cy.log("Back to threads list");
cy.get(".mx_RightPanel").findByTitle("Threads").click();
}
function openThread(rootMessage: string) {
cy.log("Open thread", rootMessage);
cy.get(".mx_RoomView_body", { log: false }).within(() => {
......@@ -191,6 +196,10 @@ describe("Read receipts", () => {
msgtype: content.msgtype,
body: newMessage,
},
"m.relates_to": {
rel_type: "m.replace",
event_id: ev.getId(),
},
};
}
})();
......@@ -666,21 +675,34 @@ describe("Read receipts", () => {
});
it.skip("Reading a thread root within the thread view marks it as read in the main timeline", () => {});
it("Creating a new thread based on a reply makes the room unread", () => {
// Given a message and reply exist and are read
goTo(room1);
receiveMessages(room2, ["Msg1", replyTo("Msg1", "Reply1"), threadedOff("Reply1", "Resp1")]);
assertUnread(room2, 3);
receiveMessages(room2, ["Msg1", replyTo("Msg1", "Reply1")]);
goTo(room2);
goTo(room1);
assertRead(room2);
// When I receive a thread message created on the reply
receiveMessages(room2, [threadedOff("Reply1", "Resp1")]);
// Then the room is unread
assertUnread(room2, 1);
});
it("Reading a thread whose root is a reply makes the room read", () => {
// Given an unread thread off a reply exists
goTo(room1);
receiveMessages(room2, ["Msg1", replyTo("Msg1", "Reply1"), threadedOff("Reply1", "Resp1")]);
assertUnread(room2, 3);
goTo(room2);
assertUnread(room2, 1);
assertUnreadThread("Reply1");
// When I read the thread
openThread("Reply1");
// Then the room and thread are read
assertRead(room2);
assertReadThread("Reply1");
});
});
});
......@@ -821,36 +843,48 @@ describe("Read receipts", () => {
describe("in threads", () => {
it("An edit of a threaded message makes the room unread", () => {
// Given we have read the thread
goTo(room1);
receiveMessages(room2, ["Msg1", threadedOff("Msg1", "Resp1")]);
assertUnread(room2, 2);
goTo(room2);
openThread("Msg1");
assertRead(room2);
backToThreadsList();
goTo(room1);
// When a message inside it is edited
receiveMessages(room2, [editOf("Resp1", "Edit1")]);
// Then the room and thread are unread
assertUnread(room2, 1);
goTo(room2);
assertUnreadThread("Msg1");
});
it("Reading an edit of a threaded message makes the room read", () => {
// Given an edited thread message is making the room unread
goTo(room1);
receiveMessages(room2, ["Msg1", threadedOff("Msg1", "Resp1")]);
assertUnread(room2, 2);
goTo(room2);
openThread("Msg1");
assertRead(room2);
backToThreadsList();
goTo(room1);
receiveMessages(room2, [editOf("Resp1", "Edit1")]);
assertUnread(room2, 1);
// When I read it
goTo(room2);
openThread("Msg1");
// Then the room and thread are read
assertRead(room2);
assertReadThread("Msg1");
});
it("Marking a room as read after an edit in a thread makes it read", () => {
// XXX: fails because the room is still bold/dot even after marking as read
it.skip("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")]);
assertUnread(room2, 3); // TODO: the edit counts as a message!
......@@ -876,39 +910,58 @@ describe("Read receipts", () => {
assertUnread(room2, 1); // TODO: should this edit make us unread?
});
it("A room with an edited threaded message is still unread after restart", () => {
// Given an edit in a thread is making a room unread
goTo(room1);
receiveMessages(room2, ["Msg1", threadedOff("Msg1", "Resp1"), editOf("Resp1", "Edit1")]);
assertUnread(room2, 3);
receiveMessages(room2, ["Msg1", threadedOff("Msg1", "Resp1")]);
markAsRead(room2);
receiveMessages(room2, [editOf("Resp1", "Edit1")]);
assertUnread(room2, 1);
// When I restart
saveAndReload();
assertUnread(room2, 3);
// Then is it still unread
assertUnread(room2, 1);
});
it("A room where all threaded edits are read is still read after restart", () => {
// XXX: fails for the same reason as "Marking a room as read after an edit in a thread makes it read"
it.skip("A room where all threaded edits are read is still read after restart", () => {
// Given I have marked an edit in a thread as read
goTo(room1);
receiveMessages(room2, ["Msg1", threadedOff("Msg1", "Resp1"), editOf("Resp1", "Edit1")]);
assertUnread(room2, 3);
markAsRead(room2);
assertRead(room2);
// When I restart
saveAndReload();
// It is still read
assertRead(room2);
});
});
describe("thread roots", () => {
it("An edit of a thread root makes the room unread", () => {
// Given I have read a thread
goTo(room1);
receiveMessages(room2, ["Msg1", threadedOff("Msg1", "Resp1")]);
assertUnread(room2, 2);
goTo(room2);
openThread("Msg1");
backToThreadsList();
assertRead(room2);
goTo(room1);
// When the thread root is edited
receiveMessages(room2, [editOf("Msg1", "Edit1")]);
// Then the room is unread
assertUnread(room2, 1);
// But the thread is read
goTo(room2);
assertRead(room2);
assertReadThread("Edit1");
});
it.skip("Reading an edit of a thread root makes the room read", () => {
// Given a fully-read thread exists
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment