Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
remove dead code related to favourited messages
Browse files Browse the repository at this point in the history
  • Loading branch information
yaya-usman committed Aug 16, 2022
1 parent 7eaed1a commit 0e5545e
Show file tree
Hide file tree
Showing 159 changed files with 6,795 additions and 722 deletions.
12 changes: 6 additions & 6 deletions cypress/e2e/lazy-loading/lazy-loading.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,21 +115,21 @@ describe("Lazy Loading", () => {
});
}

function getMembersInMemberlist(): Chainable<JQuery> {
return cy.get(".mx_MemberList .mx_EntityTile_name");
function getMemberInMemberlist(name: string): Chainable<JQuery> {
return cy.contains(".mx_MemberList .mx_EntityTile_name", name);
}

function checkMemberList(charlies: Charly[]) {
getMembersInMemberlist().contains("Alice").should("exist");
getMembersInMemberlist().contains("Bob").should("exist");
getMemberInMemberlist("Alice").should("exist");
getMemberInMemberlist("Bob").should("exist");
charlies.forEach(charly => {
getMembersInMemberlist().contains(charly.displayName).should("exist");
getMemberInMemberlist(charly.displayName).should("exist");
});
}

function checkMemberListLacksCharlies(charlies: Charly[]) {
charlies.forEach(charly => {
getMembersInMemberlist().contains(charly.displayName).should("not.exist");
getMemberInMemberlist(charly.displayName).should("not.exist");
});
}

Expand Down
4 changes: 0 additions & 4 deletions cypress/e2e/location/location.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ limitations under the License.

import { SynapseInstance } from "../../plugins/synapsedocker";
import Chainable = Cypress.Chainable;
import { SettingLevel } from "../../../src/settings/SettingLevel";

describe("Location sharing", () => {
let synapse: SynapseInstance;
Expand All @@ -40,9 +39,6 @@ describe("Location sharing", () => {

cy.initTestUser(synapse, "Tom");
});

// enable pin drop location sharing feature
cy.setSettingValue("feature_location_share_pin_drop", null, SettingLevel.DEVICE, true);
});

afterEach(() => {
Expand Down
5 changes: 3 additions & 2 deletions cypress/e2e/regression-tests/pills-click-in-app.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,9 @@ describe("Pills", () => {
// find the pill in the timeline and click it
cy.get(".mx_EventTile_body .mx_Pill").click();

const localUrl = `/#/room/#${targetLocalpart}:`;
// verify we landed at a sane place
cy.url().should("contain", `/#/room/#${targetLocalpart}:`);
cy.url().should("contain", localUrl);

cy.wait(250); // let the room list settle

Expand All @@ -69,7 +70,7 @@ describe("Pills", () => {
cy.get(".mx_EventTile_body .mx_Pill .mx_Pill_linkText")
.should("have.css", "pointer-events", "none")
.click({ force: true }); // force is to ensure we bypass pointer-events
cy.url().should("contain", `https://matrix.to/#/#${targetLocalpart}:`);
cy.url().should("contain", localUrl);
});
});
});
90 changes: 90 additions & 0 deletions cypress/e2e/settings/hidden-rr-migration.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/*
Copyright 2022 The Matrix.org Foundation C.I.C.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

/// <reference types="cypress" />

import { SynapseInstance } from "../../plugins/synapsedocker";

function seedLabs(synapse: SynapseInstance, labsVal: boolean | null): void {
cy.initTestUser(synapse, "Sally", () => {
// seed labs flag
cy.window({ log: false }).then(win => {
if (typeof labsVal === "boolean") {
// stringify boolean
win.localStorage.setItem("mx_labs_feature_feature_hidden_read_receipts", `${labsVal}`);
}
});
});
}

function testForVal(settingVal: boolean | null): void {
const testRoomName = "READ RECEIPTS";
cy.createRoom({ name: testRoomName }).as("roomId");
cy.all([cy.get<string>("@roomId")]).then(() => {
cy.viewRoomByName(testRoomName).then(() => {
// if we can see the room, then sync is working for us. It's time to see if the
// migration even ran.

cy.getSettingValue("sendReadReceipts", null, true).should("satisfy", (val) => {
if (typeof settingVal === "boolean") {
return val === settingVal;
} else {
return !val; // falsy - we don't actually care if it's undefined, null, or a literal false
}
});
});
});
}

describe("Hidden Read Receipts Setting Migration", () => {
// We run this as a full-blown end-to-end test to ensure it works in an integration
// sense. If we unit tested it, we'd be testing that the code works but not that the
// migration actually runs.
//
// Here, we get to test that not only the code works but also that it gets run. Most
// of our interactions are with the JS console as we're honestly just checking that
// things got set correctly.
//
// For a security-sensitive feature like hidden read receipts, it's absolutely vital
// that we migrate the setting appropriately.

let synapse: SynapseInstance;

beforeEach(() => {
cy.startSynapse("default").then(data => {
synapse = data;
});
});

afterEach(() => {
cy.stopSynapse(synapse);
});

it('should not migrate the lack of a labs flag', () => {
seedLabs(synapse, null);
testForVal(null);
});

it('should migrate labsHiddenRR=false as sendRR=true', () => {
seedLabs(synapse, false);
testForVal(true);
});

it('should migrate labsHiddenRR=true as sendRR=false', () => {
seedLabs(synapse, true);
testForVal(false);
});
});
64 changes: 51 additions & 13 deletions cypress/e2e/spaces/spaces.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ describe("Spaces", () => {
cy.get(".mx_AccessibleButton").contains("Go to my first room").click();

// Assert rooms exist in the room list
cy.get(".mx_RoomTile").contains("General").should("exist");
cy.get(".mx_RoomTile").contains("Random").should("exist");
cy.get(".mx_RoomTile").contains("Jokes").should("exist");
cy.get(".mx_RoomList").contains(".mx_RoomTile", "General").should("exist");
cy.get(".mx_RoomList").contains(".mx_RoomTile", "Random").should("exist");
cy.get(".mx_RoomList").contains(".mx_RoomTile", "Jokes").should("exist");
});

it("should allow user to create private space", () => {
Expand All @@ -128,14 +128,14 @@ describe("Spaces", () => {
cy.get(".mx_AccessibleButton").contains("Skip for now").click();

// Assert rooms exist in the room list
cy.get(".mx_RoomTile").contains("General").should("exist");
cy.get(".mx_RoomTile").contains("Random").should("exist");
cy.get(".mx_RoomTile").contains("Projects").should("exist");
cy.get(".mx_RoomList").contains(".mx_RoomTile", "General").should("exist");
cy.get(".mx_RoomList").contains(".mx_RoomTile", "Random").should("exist");
cy.get(".mx_RoomList").contains(".mx_RoomTile", "Projects").should("exist");

// Assert rooms exist in the space explorer
cy.get(".mx_SpaceHierarchy_roomTile").contains("General").should("exist");
cy.get(".mx_SpaceHierarchy_roomTile").contains("Random").should("exist");
cy.get(".mx_SpaceHierarchy_roomTile").contains("Projects").should("exist");
cy.get(".mx_SpaceHierarchy_list").contains(".mx_SpaceHierarchy_roomTile", "General").should("exist");
cy.get(".mx_SpaceHierarchy_list").contains(".mx_SpaceHierarchy_roomTile", "Random").should("exist");
cy.get(".mx_SpaceHierarchy_list").contains(".mx_SpaceHierarchy_roomTile", "Projects").should("exist");
});

it("should allow user to create just-me space", () => {
Expand All @@ -157,8 +157,8 @@ describe("Spaces", () => {
cy.get(".mx_AddExistingToSpace_entry").click();
cy.get(".mx_AccessibleButton").contains("Add").click();

cy.get(".mx_RoomTile").contains("Sample Room").should("exist");
cy.get(".mx_SpaceHierarchy_roomTile").contains("Sample Room").should("exist");
cy.get(".mx_RoomList").contains(".mx_RoomTile", "Sample Room").should("exist");
cy.get(".mx_SpaceHierarchy_list").contains(".mx_SpaceHierarchy_roomTile", "Sample Room").should("exist");
});

it("should allow user to invite another to a space", () => {
Expand Down Expand Up @@ -233,8 +233,46 @@ describe("Spaces", () => {
cy.viewSpaceHomeByName(spaceName);
});
cy.get(".mx_SpaceRoomView .mx_SpaceHierarchy_list").within(() => {
cy.get(".mx_SpaceHierarchy_roomTile").contains("Music").should("exist");
cy.get(".mx_SpaceHierarchy_roomTile").contains("Gaming").should("exist");
cy.contains(".mx_SpaceHierarchy_roomTile", "Music").should("exist");
cy.contains(".mx_SpaceHierarchy_roomTile", "Gaming").should("exist");
});
});

it("should render subspaces in the space panel only when expanded", () => {
cy.injectAxe();

cy.createSpace({
name: "Child Space",
initial_state: [],
}).then(spaceId => {
cy.createSpace({
name: "Root Space",
initial_state: [
spaceChildInitialState(spaceId),
],
}).as("spaceId");
});
cy.get('.mx_SpacePanel .mx_SpaceButton[aria-label="Root Space"]').should("exist");
cy.get('.mx_SpacePanel .mx_SpaceButton[aria-label="Child Space"]').should("not.exist");

const axeOptions = {
rules: {
// Disable this check as it triggers on nested roving tab index elements which are in practice fine
'nested-interactive': {
enabled: false,
},
},
};
cy.checkA11y(undefined, axeOptions);
cy.get(".mx_SpacePanel").percySnapshotElement("Space panel collapsed", { widths: [68] });

cy.get(".mx_SpaceButton_toggleCollapse").click({ force: true });
cy.get(".mx_SpacePanel:not(.collapsed)").should("exist");

cy.contains(".mx_SpaceItem", "Root Space").should("exist")
.contains(".mx_SpaceItem", "Child Space").should("exist");

cy.checkA11y(undefined, axeOptions);
cy.get(".mx_SpacePanel").percySnapshotElement("Space panel expanded", { widths: [258] });
});
});
32 changes: 32 additions & 0 deletions cypress/e2e/spotlight/spotlight.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ Cypress.Commands.add("startDM", (name: string) => {
cy.openSpotlightDialog().within(() => {
cy.spotlightFilter(Filter.People);
cy.spotlightSearch().clear().type(name);
cy.wait(1000); // wait for the dialog code to settle
cy.get(".mx_Spinner").should("not.exist");
cy.spotlightResults().should("have.length", 1);
cy.spotlightResults().eq(0).should("contain", name);
Expand Down Expand Up @@ -216,6 +217,7 @@ describe("Spotlight", () => {
it("should find joined rooms", () => {
cy.openSpotlightDialog().within(() => {
cy.spotlightSearch().clear().type(room1Name);
cy.wait(1000); // wait for the dialog code to settle
cy.spotlightResults().should("have.length", 1);
cy.spotlightResults().eq(0).should("contain", room1Name);
cy.spotlightResults().eq(0).click();
Expand All @@ -229,6 +231,7 @@ describe("Spotlight", () => {
cy.openSpotlightDialog().within(() => {
cy.spotlightFilter(Filter.PublicRooms);
cy.spotlightSearch().clear().type(room1Name);
cy.wait(1000); // wait for the dialog code to settle
cy.spotlightResults().should("have.length", 1);
cy.spotlightResults().eq(0).should("contain", room1Name);
cy.spotlightResults().eq(0).should("contain", "View");
Expand All @@ -243,6 +246,7 @@ describe("Spotlight", () => {
cy.openSpotlightDialog().within(() => {
cy.spotlightFilter(Filter.PublicRooms);
cy.spotlightSearch().clear().type(room2Name);
cy.wait(1000); // wait for the dialog code to settle
cy.spotlightResults().should("have.length", 1);
cy.spotlightResults().eq(0).should("contain", room2Name);
cy.spotlightResults().eq(0).should("contain", "Join");
Expand All @@ -258,6 +262,7 @@ describe("Spotlight", () => {
cy.openSpotlightDialog().within(() => {
cy.spotlightFilter(Filter.PublicRooms);
cy.spotlightSearch().clear().type(room3Name);
cy.wait(1000); // wait for the dialog code to settle
cy.spotlightResults().should("have.length", 1);
cy.spotlightResults().eq(0).should("contain", room3Name);
cy.spotlightResults().eq(0).should("contain", "View");
Expand Down Expand Up @@ -296,6 +301,7 @@ describe("Spotlight", () => {
cy.openSpotlightDialog().within(() => {
cy.spotlightFilter(Filter.People);
cy.spotlightSearch().clear().type(bot1Name);
cy.wait(1000); // wait for the dialog code to settle
cy.spotlightResults().should("have.length", 1);
cy.spotlightResults().eq(0).should("contain", bot1Name);
cy.spotlightResults().eq(0).click();
Expand All @@ -308,6 +314,7 @@ describe("Spotlight", () => {
cy.openSpotlightDialog().within(() => {
cy.spotlightFilter(Filter.People);
cy.spotlightSearch().clear().type(bot2Name);
cy.wait(1000); // wait for the dialog code to settle
cy.spotlightResults().should("have.length", 1);
cy.spotlightResults().eq(0).should("contain", bot2Name);
cy.spotlightResults().eq(0).click();
Expand All @@ -324,6 +331,7 @@ describe("Spotlight", () => {
cy.openSpotlightDialog().within(() => {
cy.spotlightFilter(Filter.People);
cy.spotlightSearch().clear().type(bot2Name);
cy.wait(1000); // wait for the dialog code to settle
cy.spotlightResults().should("have.length", 1);
cy.spotlightResults().eq(0).should("contain", bot2Name);
cy.spotlightResults().eq(0).click();
Expand Down Expand Up @@ -352,6 +360,7 @@ describe("Spotlight", () => {
cy.openSpotlightDialog().within(() => {
cy.spotlightFilter(Filter.People);
cy.spotlightSearch().clear().type(bot1.getUserId());
cy.wait(1000); // wait for the dialog code to settle
cy.spotlightResults().should("have.length", 2);
cy.spotlightResults().eq(0).should("contain", `${bot1Name} and ${bot2Name}`);
});
Expand All @@ -360,15 +369,37 @@ describe("Spotlight", () => {
cy.openSpotlightDialog().within(() => {
cy.spotlightFilter(Filter.People);
cy.spotlightSearch().clear().type(bot2.getUserId());
cy.wait(1000); // wait for the dialog code to settle
cy.spotlightResults().should("have.length", 2);
cy.spotlightResults().eq(0).should("contain", `${bot1Name} and ${bot2Name}`);
});
});

// Test against https://github.com/vector-im/element-web/issues/22851
it("should show each person result only once", () => {
cy.openSpotlightDialog().within(() => {
cy.spotlightFilter(Filter.People);

// 2 rounds of search to simulate the bug conditions. Specifically, the first search
// should have 1 result (not 2) and the second search should also have 1 result (instead
// of the super buggy 3 described by https://github.com/vector-im/element-web/issues/22851)
//
// We search for user ID to trigger the profile lookup within the dialog.
for (let i = 0; i < 2; i++) {
cy.log("Iteration: " + i);
cy.spotlightSearch().clear().type(bot1.getUserId());
cy.wait(1000); // wait for the dialog code to settle
cy.spotlightResults().should("have.length", 1);
cy.spotlightResults().eq(0).should("contain", bot1.getUserId());
}
});
});

it("should allow opening group chat dialog", () => {
cy.openSpotlightDialog().within(() => {
cy.spotlightFilter(Filter.People);
cy.spotlightSearch().clear().type(bot2Name);
cy.wait(1000); // wait for the dialog code to settle
cy.spotlightResults().should("have.length", 1);
cy.spotlightResults().eq(0).should("contain", bot2Name);
cy.get(".mx_SpotlightDialog_startGroupChat").should("contain", "Start a group chat");
Expand All @@ -390,6 +421,7 @@ describe("Spotlight", () => {
cy.openSpotlightDialog().within(() => {
cy.spotlightFilter(Filter.People);
cy.spotlightSearch().clear().type(bot1Name);
cy.wait(1000); // wait for the dialog code to settle
cy.get(".mx_Spinner").should("not.exist");
cy.spotlightResults().should("have.length", 1);
});
Expand Down
Loading

0 comments on commit 0e5545e

Please sign in to comment.