Apply prettier formatting
This commit is contained in:
parent
1cac306093
commit
526645c791
1576 changed files with 65385 additions and 62478 deletions
|
@ -26,18 +26,17 @@ import { ProxyInstance } from "../../plugins/sliding-sync";
|
|||
|
||||
describe("Sliding Sync", () => {
|
||||
beforeEach(() => {
|
||||
cy.startSynapse("default").as("synapse").then(synapse => {
|
||||
cy.startProxy(synapse).as("proxy");
|
||||
});
|
||||
cy.startSynapse("default")
|
||||
.as("synapse")
|
||||
.then((synapse) => {
|
||||
cy.startProxy(synapse).as("proxy");
|
||||
});
|
||||
|
||||
cy.all([
|
||||
cy.get<SynapseInstance>("@synapse"),
|
||||
cy.get<ProxyInstance>("@proxy"),
|
||||
]).then(([synapse, proxy]) => {
|
||||
cy.all([cy.get<SynapseInstance>("@synapse"), cy.get<ProxyInstance>("@proxy")]).then(([synapse, proxy]) => {
|
||||
cy.enableLabsFeature("feature_sliding_sync");
|
||||
|
||||
cy.intercept("/config.json?cachebuster=*", req => {
|
||||
return req.continue(res => {
|
||||
cy.intercept("/config.json?cachebuster=*", (req) => {
|
||||
return req.continue((res) => {
|
||||
res.send(200, {
|
||||
...res.body,
|
||||
setting_defaults: {
|
||||
|
@ -62,11 +61,16 @@ describe("Sliding Sync", () => {
|
|||
|
||||
// assert order
|
||||
const checkOrder = (wantOrder: string[]) => {
|
||||
cy.contains(".mx_RoomSublist", "Rooms").find(".mx_RoomTile_title").should((elements) => {
|
||||
expect(_.map(elements, (e) => {
|
||||
return e.textContent;
|
||||
}), "rooms are sorted").to.deep.equal(wantOrder);
|
||||
});
|
||||
cy.contains(".mx_RoomSublist", "Rooms")
|
||||
.find(".mx_RoomTile_title")
|
||||
.should((elements) => {
|
||||
expect(
|
||||
_.map(elements, (e) => {
|
||||
return e.textContent;
|
||||
}),
|
||||
"rooms are sorted",
|
||||
).to.deep.equal(wantOrder);
|
||||
});
|
||||
};
|
||||
const bumpRoom = (alias: string) => {
|
||||
// Send a message into the given room, this should bump the room to the top
|
||||
|
@ -80,9 +84,11 @@ describe("Sliding Sync", () => {
|
|||
const createAndJoinBob = () => {
|
||||
// create a Bob user
|
||||
cy.get<SynapseInstance>("@synapse").then((synapse) => {
|
||||
return cy.getBot(synapse, {
|
||||
displayName: "Bob",
|
||||
}).as("bob");
|
||||
return cy
|
||||
.getBot(synapse, {
|
||||
displayName: "Bob",
|
||||
})
|
||||
.as("bob");
|
||||
});
|
||||
|
||||
// invite Bob to Test Room and accept then send a message.
|
||||
|
@ -95,7 +101,7 @@ describe("Sliding Sync", () => {
|
|||
|
||||
// sanity check everything works
|
||||
it("should correctly render expected messages", () => {
|
||||
cy.get<string>("@roomId").then(roomId => cy.visit("/#/room/" + roomId));
|
||||
cy.get<string>("@roomId").then((roomId) => cy.visit("/#/room/" + roomId));
|
||||
cy.setSettingValue("layout", null, SettingLevel.DEVICE, Layout.IRC);
|
||||
|
||||
// Wait until configuration is finished
|
||||
|
@ -114,54 +120,52 @@ describe("Sliding Sync", () => {
|
|||
cy.createRoom({ name: "Pineapple" }).then(() => cy.contains(".mx_RoomSublist", "Pineapple"));
|
||||
cy.createRoom({ name: "Orange" }).then(() => cy.contains(".mx_RoomSublist", "Orange"));
|
||||
// check the rooms are in the right order
|
||||
cy.get(".mx_RoomTile").should('have.length', 4); // due to the Test Room in beforeEach
|
||||
checkOrder([
|
||||
"Orange", "Pineapple", "Apple", "Test Room",
|
||||
]);
|
||||
cy.get(".mx_RoomTile").should("have.length", 4); // due to the Test Room in beforeEach
|
||||
checkOrder(["Orange", "Pineapple", "Apple", "Test Room"]);
|
||||
|
||||
cy.contains(".mx_RoomSublist", "Rooms").find(".mx_RoomSublist_menuButton").click({ force: true });
|
||||
cy.contains("A-Z").click();
|
||||
cy.get('.mx_StyledRadioButton_checked').should("contain.text", "A-Z");
|
||||
checkOrder([
|
||||
"Apple", "Orange", "Pineapple", "Test Room",
|
||||
]);
|
||||
cy.get(".mx_StyledRadioButton_checked").should("contain.text", "A-Z");
|
||||
checkOrder(["Apple", "Orange", "Pineapple", "Test Room"]);
|
||||
});
|
||||
|
||||
it("should move rooms around as new events arrive", () => {
|
||||
// create rooms and check room names are correct
|
||||
cy.createRoom({ name: "Apple" }).as("roomA").then(() => cy.contains(".mx_RoomSublist", "Apple"));
|
||||
cy.createRoom({ name: "Pineapple" }).as("roomP").then(() => cy.contains(".mx_RoomSublist", "Pineapple"));
|
||||
cy.createRoom({ name: "Orange" }).as("roomO").then(() => cy.contains(".mx_RoomSublist", "Orange"));
|
||||
cy.createRoom({ name: "Apple" })
|
||||
.as("roomA")
|
||||
.then(() => cy.contains(".mx_RoomSublist", "Apple"));
|
||||
cy.createRoom({ name: "Pineapple" })
|
||||
.as("roomP")
|
||||
.then(() => cy.contains(".mx_RoomSublist", "Pineapple"));
|
||||
cy.createRoom({ name: "Orange" })
|
||||
.as("roomO")
|
||||
.then(() => cy.contains(".mx_RoomSublist", "Orange"));
|
||||
|
||||
// Select the Test Room
|
||||
cy.contains(".mx_RoomTile", "Test Room").click();
|
||||
|
||||
checkOrder([
|
||||
"Orange", "Pineapple", "Apple", "Test Room",
|
||||
]);
|
||||
checkOrder(["Orange", "Pineapple", "Apple", "Test Room"]);
|
||||
bumpRoom("@roomA");
|
||||
checkOrder([
|
||||
"Apple", "Orange", "Pineapple", "Test Room",
|
||||
]);
|
||||
checkOrder(["Apple", "Orange", "Pineapple", "Test Room"]);
|
||||
bumpRoom("@roomO");
|
||||
checkOrder([
|
||||
"Orange", "Apple", "Pineapple", "Test Room",
|
||||
]);
|
||||
checkOrder(["Orange", "Apple", "Pineapple", "Test Room"]);
|
||||
bumpRoom("@roomO");
|
||||
checkOrder([
|
||||
"Orange", "Apple", "Pineapple", "Test Room",
|
||||
]);
|
||||
checkOrder(["Orange", "Apple", "Pineapple", "Test Room"]);
|
||||
bumpRoom("@roomP");
|
||||
checkOrder([
|
||||
"Pineapple", "Orange", "Apple", "Test Room",
|
||||
]);
|
||||
checkOrder(["Pineapple", "Orange", "Apple", "Test Room"]);
|
||||
});
|
||||
|
||||
it("should not move the selected room: it should be sticky", () => {
|
||||
// create rooms and check room names are correct
|
||||
cy.createRoom({ name: "Apple" }).as("roomA").then(() => cy.contains(".mx_RoomSublist", "Apple"));
|
||||
cy.createRoom({ name: "Pineapple" }).as("roomP").then(() => cy.contains(".mx_RoomSublist", "Pineapple"));
|
||||
cy.createRoom({ name: "Orange" }).as("roomO").then(() => cy.contains(".mx_RoomSublist", "Orange"));
|
||||
cy.createRoom({ name: "Apple" })
|
||||
.as("roomA")
|
||||
.then(() => cy.contains(".mx_RoomSublist", "Apple"));
|
||||
cy.createRoom({ name: "Pineapple" })
|
||||
.as("roomP")
|
||||
.then(() => cy.contains(".mx_RoomSublist", "Pineapple"));
|
||||
cy.createRoom({ name: "Orange" })
|
||||
.as("roomO")
|
||||
.then(() => cy.contains(".mx_RoomSublist", "Orange"));
|
||||
|
||||
// Given a list of Orange, Pineapple, Apple - if Pineapple is active and a message is sent in Apple, the list should
|
||||
// turn into Apple, Pineapple, Orange - the index position of Pineapple never changes even though the list should technically
|
||||
|
@ -169,23 +173,17 @@ describe("Sliding Sync", () => {
|
|||
|
||||
// Select the Pineapple room
|
||||
cy.contains(".mx_RoomTile", "Pineapple").click();
|
||||
checkOrder([
|
||||
"Orange", "Pineapple", "Apple", "Test Room",
|
||||
]);
|
||||
checkOrder(["Orange", "Pineapple", "Apple", "Test Room"]);
|
||||
|
||||
// Move Apple
|
||||
bumpRoom("@roomA");
|
||||
checkOrder([
|
||||
"Apple", "Pineapple", "Orange", "Test Room",
|
||||
]);
|
||||
checkOrder(["Apple", "Pineapple", "Orange", "Test Room"]);
|
||||
|
||||
// Select the Test Room
|
||||
cy.contains(".mx_RoomTile", "Test Room").click();
|
||||
|
||||
// the rooms reshuffle to match reality
|
||||
checkOrder([
|
||||
"Apple", "Orange", "Pineapple", "Test Room",
|
||||
]);
|
||||
checkOrder(["Apple", "Orange", "Pineapple", "Test Room"]);
|
||||
});
|
||||
|
||||
it("should show the right unread notifications", () => {
|
||||
|
@ -212,7 +210,8 @@ describe("Sliding Sync", () => {
|
|||
cy.contains(".mx_RoomTile", "Test Room").should("not.have.class", "mx_NotificationBadge_count");
|
||||
});
|
||||
|
||||
it("should not show unread indicators", () => { // TODO: for now. Later we should.
|
||||
it("should not show unread indicators", () => {
|
||||
// TODO: for now. Later we should.
|
||||
createAndJoinBob();
|
||||
|
||||
// disable notifs in this room (TODO: CS API call?)
|
||||
|
@ -223,17 +222,13 @@ describe("Sliding Sync", () => {
|
|||
cy.createRoom({
|
||||
name: "Dummy",
|
||||
});
|
||||
checkOrder([
|
||||
"Dummy", "Test Room",
|
||||
]);
|
||||
checkOrder(["Dummy", "Test Room"]);
|
||||
|
||||
cy.all([cy.get<string>("@roomId"), cy.get<MatrixClient>("@bob")]).then(([roomId, bob]) => {
|
||||
return bob.sendTextMessage(roomId, "Do you read me?");
|
||||
});
|
||||
// wait for this message to arrive, tell by the room list resorting
|
||||
checkOrder([
|
||||
"Test Room", "Dummy",
|
||||
]);
|
||||
checkOrder(["Test Room", "Dummy"]);
|
||||
|
||||
cy.contains(".mx_RoomTile", "Test Room").get(".mx_NotificationBadge").should("not.exist");
|
||||
});
|
||||
|
@ -242,13 +237,18 @@ describe("Sliding Sync", () => {
|
|||
cy.get(".mx_UserMenu_userAvatar").click();
|
||||
cy.contains("All settings").click();
|
||||
cy.contains("Preferences").click();
|
||||
cy.contains(".mx_SettingsFlag", "Show timestamps in 12 hour format").should("exist").find(
|
||||
".mx_ToggleSwitch_on").should("not.exist");
|
||||
cy.contains(".mx_SettingsFlag", "Show timestamps in 12 hour format").should("exist").find(
|
||||
".mx_ToggleSwitch_ball").click();
|
||||
cy.contains(".mx_SettingsFlag", "Show timestamps in 12 hour format", { timeout: 2000 }).should("exist").find(
|
||||
".mx_ToggleSwitch_on", { timeout: 2000 },
|
||||
).should("exist");
|
||||
cy.contains(".mx_SettingsFlag", "Show timestamps in 12 hour format")
|
||||
.should("exist")
|
||||
.find(".mx_ToggleSwitch_on")
|
||||
.should("not.exist");
|
||||
cy.contains(".mx_SettingsFlag", "Show timestamps in 12 hour format")
|
||||
.should("exist")
|
||||
.find(".mx_ToggleSwitch_ball")
|
||||
.click();
|
||||
cy.contains(".mx_SettingsFlag", "Show timestamps in 12 hour format", { timeout: 2000 })
|
||||
.should("exist")
|
||||
.find(".mx_ToggleSwitch_on", { timeout: 2000 })
|
||||
.should("exist");
|
||||
});
|
||||
|
||||
it("should show and be able to accept/reject/rescind invites", () => {
|
||||
|
@ -263,50 +263,56 @@ describe("Sliding Sync", () => {
|
|||
// - roomJoin: will join this room
|
||||
// - roomReject: will reject the invite
|
||||
// - roomRescind: will make Bob rescind the invite
|
||||
let roomJoin; let roomReject; let roomRescind; let bobClient;
|
||||
cy.get<MatrixClient>("@bob").then((bob) => {
|
||||
bobClient = bob;
|
||||
return Promise.all([
|
||||
bob.createRoom({ name: "Join" }),
|
||||
bob.createRoom({ name: "Reject" }),
|
||||
bob.createRoom({ name: "Rescind" }),
|
||||
]);
|
||||
}).then(([join, reject, rescind]) => {
|
||||
roomJoin = join.room_id;
|
||||
roomReject = reject.room_id;
|
||||
roomRescind = rescind.room_id;
|
||||
return Promise.all([
|
||||
bobClient.invite(roomJoin, clientUserId),
|
||||
bobClient.invite(roomReject, clientUserId),
|
||||
bobClient.invite(roomRescind, clientUserId),
|
||||
]);
|
||||
});
|
||||
let roomJoin;
|
||||
let roomReject;
|
||||
let roomRescind;
|
||||
let bobClient;
|
||||
cy.get<MatrixClient>("@bob")
|
||||
.then((bob) => {
|
||||
bobClient = bob;
|
||||
return Promise.all([
|
||||
bob.createRoom({ name: "Join" }),
|
||||
bob.createRoom({ name: "Reject" }),
|
||||
bob.createRoom({ name: "Rescind" }),
|
||||
]);
|
||||
})
|
||||
.then(([join, reject, rescind]) => {
|
||||
roomJoin = join.room_id;
|
||||
roomReject = reject.room_id;
|
||||
roomRescind = rescind.room_id;
|
||||
return Promise.all([
|
||||
bobClient.invite(roomJoin, clientUserId),
|
||||
bobClient.invite(roomReject, clientUserId),
|
||||
bobClient.invite(roomRescind, clientUserId),
|
||||
]);
|
||||
});
|
||||
|
||||
// wait for them all to be on the UI
|
||||
cy.get(".mx_RoomTile").should('have.length', 4); // due to the Test Room in beforeEach
|
||||
cy.get(".mx_RoomTile").should("have.length", 4); // due to the Test Room in beforeEach
|
||||
|
||||
cy.contains(".mx_RoomTile", "Join").click();
|
||||
cy.contains(".mx_AccessibleButton", "Accept").click();
|
||||
|
||||
checkOrder([
|
||||
"Join", "Test Room",
|
||||
]);
|
||||
checkOrder(["Join", "Test Room"]);
|
||||
|
||||
cy.contains(".mx_RoomTile", "Reject").click();
|
||||
cy.contains(".mx_RoomView .mx_AccessibleButton", "Reject").click();
|
||||
|
||||
// wait for the rejected room to disappear
|
||||
cy.get(".mx_RoomTile").should('have.length', 3);
|
||||
cy.get(".mx_RoomTile").should("have.length", 3);
|
||||
|
||||
// check the lists are correct
|
||||
checkOrder([
|
||||
"Join", "Test Room",
|
||||
]);
|
||||
cy.contains(".mx_RoomSublist", "Invites").find(".mx_RoomTile_title").should((elements) => {
|
||||
expect(_.map(elements, (e) => {
|
||||
return e.textContent;
|
||||
}), "rooms are sorted").to.deep.equal(["Rescind"]);
|
||||
});
|
||||
checkOrder(["Join", "Test Room"]);
|
||||
cy.contains(".mx_RoomSublist", "Invites")
|
||||
.find(".mx_RoomTile_title")
|
||||
.should((elements) => {
|
||||
expect(
|
||||
_.map(elements, (e) => {
|
||||
return e.textContent;
|
||||
}),
|
||||
"rooms are sorted",
|
||||
).to.deep.equal(["Rescind"]);
|
||||
});
|
||||
|
||||
// now rescind the invite
|
||||
cy.get<MatrixClient>("@bob").then((bob) => {
|
||||
|
@ -314,19 +320,19 @@ describe("Sliding Sync", () => {
|
|||
});
|
||||
|
||||
// wait for the rescind to take effect and check the joined list once more
|
||||
cy.get(".mx_RoomTile").should('have.length', 2);
|
||||
checkOrder([
|
||||
"Join", "Test Room",
|
||||
]);
|
||||
cy.get(".mx_RoomTile").should("have.length", 2);
|
||||
checkOrder(["Join", "Test Room"]);
|
||||
});
|
||||
|
||||
it("should show a favourite DM only in the favourite sublist", () => {
|
||||
cy.createRoom({
|
||||
name: "Favourite DM",
|
||||
is_direct: true,
|
||||
}).as("room").then(roomId => {
|
||||
cy.getClient().then(cli => cli.setRoomTag(roomId, "m.favourite", { order: 0.5 }));
|
||||
});
|
||||
})
|
||||
.as("room")
|
||||
.then((roomId) => {
|
||||
cy.getClient().then((cli) => cli.setRoomTag(roomId, "m.favourite", { order: 0.5 }));
|
||||
});
|
||||
|
||||
cy.contains('.mx_RoomSublist[aria-label="Favourites"] .mx_RoomTile', "Favourite DM").should("exist");
|
||||
cy.contains('.mx_RoomSublist[aria-label="People"] .mx_RoomTile', "Favourite DM").should("not.exist");
|
||||
|
@ -335,7 +341,9 @@ describe("Sliding Sync", () => {
|
|||
// Regression test for a bug in SS mode, but would be useful to have in non-SS mode too.
|
||||
// This ensures we are setting RoomViewStore state correctly.
|
||||
it("should clear the reply to field when swapping rooms", () => {
|
||||
cy.createRoom({ name: "Other Room" }).as("roomA").then(() => cy.contains(".mx_RoomSublist", "Other Room"));
|
||||
cy.createRoom({ name: "Other Room" })
|
||||
.as("roomA")
|
||||
.then(() => cy.contains(".mx_RoomSublist", "Other Room"));
|
||||
cy.get<string>("@roomId").then((roomId) => {
|
||||
return cy.sendEvent(roomId, null, "m.room.message", {
|
||||
body: "Hello world",
|
||||
|
@ -346,9 +354,9 @@ describe("Sliding Sync", () => {
|
|||
cy.contains(".mx_RoomTile", "Test Room").click();
|
||||
cy.get(".mx_ReplyPreview").should("not.exist");
|
||||
// click reply-to on the Hello World message
|
||||
cy.contains(".mx_EventTile", "Hello world").find('.mx_AccessibleButton[aria-label="Reply"]').click(
|
||||
{ force: true },
|
||||
);
|
||||
cy.contains(".mx_EventTile", "Hello world")
|
||||
.find('.mx_AccessibleButton[aria-label="Reply"]')
|
||||
.click({ force: true });
|
||||
// check it's visible
|
||||
cy.get(".mx_ReplyPreview").should("exist");
|
||||
// now click Other Room
|
||||
|
@ -365,28 +373,31 @@ describe("Sliding Sync", () => {
|
|||
it("should not cancel replies when permalinks are clicked ", () => {
|
||||
cy.get<string>("@roomId").then((roomId) => {
|
||||
// we require a first message as you cannot click the permalink text with the avatar in the way
|
||||
return cy.sendEvent(roomId, null, "m.room.message", {
|
||||
body: "First message",
|
||||
msgtype: "m.text",
|
||||
}).then(() => {
|
||||
return cy.sendEvent(roomId, null, "m.room.message", {
|
||||
body: "Permalink me",
|
||||
return cy
|
||||
.sendEvent(roomId, null, "m.room.message", {
|
||||
body: "First message",
|
||||
msgtype: "m.text",
|
||||
})
|
||||
.then(() => {
|
||||
return cy.sendEvent(roomId, null, "m.room.message", {
|
||||
body: "Permalink me",
|
||||
msgtype: "m.text",
|
||||
});
|
||||
})
|
||||
.then(() => {
|
||||
cy.sendEvent(roomId, null, "m.room.message", {
|
||||
body: "Reply to me",
|
||||
msgtype: "m.text",
|
||||
});
|
||||
});
|
||||
}).then(() => {
|
||||
cy.sendEvent(roomId, null, "m.room.message", {
|
||||
body: "Reply to me",
|
||||
msgtype: "m.text",
|
||||
});
|
||||
});
|
||||
});
|
||||
// select the room
|
||||
cy.contains(".mx_RoomTile", "Test Room").click();
|
||||
cy.get(".mx_ReplyPreview").should("not.exist");
|
||||
// click reply-to on the Reply to me message
|
||||
cy.contains(".mx_EventTile", "Reply to me").find('.mx_AccessibleButton[aria-label="Reply"]').click(
|
||||
{ force: true },
|
||||
);
|
||||
cy.contains(".mx_EventTile", "Reply to me")
|
||||
.find('.mx_AccessibleButton[aria-label="Reply"]')
|
||||
.click({ force: true });
|
||||
// check it's visible
|
||||
cy.get(".mx_ReplyPreview").should("exist");
|
||||
// now click on the permalink for Permalink me
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue