it("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);
receiveMessages(room2,many("Msg",110));
assertUnread(room2,110);
goTo(room2);
assertRead(room2);
goTo(room1);
// When we restart, so only recent messages are loaded
saveAndReload();
goTo(room2);
assertMessageNotLoaded("Msg0010");
// And we page up, loading in old messages
pageUp();
cy.wait(200);
pageUp();
cy.wait(200);
pageUp();
assertMessageLoaded("Msg0010");
// Then the room remains read
assertStillRead(room2);
});
it("Paging up through old messages of an unread room leaves the room unread",()=>{
// Given lots of messages are in the room, and they are not read
goTo(room1);
receiveMessages(room2,many("x\ny\nz\nMsg",40));// newline to spread out messages
assertUnread(room2,40);
// When I jump to a message in the middle and page up
jumpTo(room2,"x\ny\nz\nMsg0020");
pageUp();
// Then the room is still unread
assertUnreadGreaterThan(room2,1);
});
it("Paging up to find old threads that were previously read leaves the room read",()=>{
// Given lots of messages in threads are all read
goTo(room1);
receiveMessages(room2,[
"Root1",
"Root2",
"Root3",
...manyThreadedOff("Root1",many("T",20)),
...manyThreadedOff("Root2",many("T",20)),
...manyThreadedOff("Root3",many("T",20)),
]);
goTo(room2);
assertUnread(room2,60);
openThread("Root1");
assertUnread(room2,40);
assertReadThread("Root1");
openThread("Root2");
assertUnread(room2,20);
assertReadThread("Root2");
openThread("Root3");
assertRead(room2);
assertReadThread("Root3");
// When I restart and page up to load old thread roots
goTo(room1);
saveAndReload();
goTo(room2);
pageUp();
// Then the room and threads remain read
assertRead(room2);
assertReadThread("Root1");
assertReadThread("Root2");
assertReadThread("Root3");
});
it("Paging up to find old threads that were never read keeps the room unread",()=>{
// Given lots of messages in threads that are unread
goTo(room1);
receiveMessages(room2,[
"Root1",
"Root2",
"Root3",
...manyThreadedOff("Root1",many("T",2)),
...manyThreadedOff("Root2",many("T",2)),
...manyThreadedOff("Root3",many("T",2)),
...many("Msg",100),
]);
goTo(room2);
assertUnread(room2,6);
assertUnreadThread("Root1");
assertUnreadThread("Root2");
assertUnreadThread("Root3");
// When I restart
closeThreadsPanel();
goTo(room1);
saveAndReload();
// Then the room remembers it's unread
// TODO: I (andyb) think this will fall in an encrypted room
assertUnread(room2,6);
// And when I page up to load old thread roots
goTo(room2);
pageUp();
// Then the room remains unread
assertUnread(room2,6);
assertUnreadThread("Root1");
assertUnreadThread("Root2");
assertUnreadThread("Root3");
});
it("Looking in thread view to find old threads that were never read makes the room unread",()=>{
// Given lots of messages in threads that are unread
goTo(room1);
receiveMessages(room2,[
"Root1",
"Root2",
"Root3",
...manyThreadedOff("Root1",many("T",2)),
...manyThreadedOff("Root2",many("T",2)),
...manyThreadedOff("Root3",many("T",2)),
...many("Msg",100),
]);
goTo(room2);
assertUnread(room2,6);
assertUnreadThread("Root1");
assertUnreadThread("Root2");
assertUnreadThread("Root3");
// When I restart
closeThreadsPanel();
goTo(room1);
saveAndReload();
// Then the room remembers it's unread
// TODO: I (andyb) think this will fall in an encrypted room
assertUnread(room2,6);
// And when I open the threads view
goTo(room2);
openThreadList();
// Then the room remains unread
assertUnread(room2,6);
assertUnreadThread("Root1");
assertUnreadThread("Root2");
assertUnreadThread("Root3");
});
it("After marking room as read, paging up to find old threads that were never read leaves the room read",()=>{
// Given lots of messages in threads that are unread but I marked as read on a main timeline message
goTo(room1);
receiveMessages(room2,[
"Root1",
"Root2",
"Root3",
...manyThreadedOff("Root1",many("T",2)),
...manyThreadedOff("Root2",many("T",2)),
...manyThreadedOff("Root3",many("T",2)),
...many("Msg",100),
]);
markAsRead(room2);
assertRead(room2);
// When I restart
saveAndReload();
// Then the room remembers it's read
assertRead(room2);
// And when I page up to load old thread roots
goTo(room2);
pageUp();
pageUp();
pageUp();
// Then the room remains read
assertStillRead(room2);
assertReadThread("Root1");
assertReadThread("Root2");
assertReadThread("Root3");
});
// XXX: fails because we see a dot instead of an unread number - probably the server and client disagree
it.skip("After marking room as read based on a thread message, opening threads view to find old threads that were never read leaves the room read",()=>{
// Given lots of messages in threads that are unread but I marked as read on a thread message