From c0a0ca107003a7545d454599f6b32e31fa45d526 Mon Sep 17 00:00:00 2001 From: Estelle Comment Date: Fri, 3 Nov 2023 12:46:11 +0100 Subject: [PATCH] Delete even more stuff --- cypress/e2e/create-room/create-room.spec.ts | 6 -- cypress/e2e/login/login.spec.ts | 1 - cypress/e2e/register/register.spec.ts | 78 --------------------- cypress/support/clipboard.ts | 57 --------------- cypress/support/composer.ts | 48 ------------- cypress/support/e2e.ts | 8 --- cypress/support/iframes.ts | 49 ------------- cypress/support/labs.ts | 45 ------------ cypress/support/network.ts | 70 ------------------ cypress/support/percy.ts | 54 -------------- cypress/support/performance.ts | 74 ------------------- 11 files changed, 490 deletions(-) delete mode 100644 cypress/e2e/register/register.spec.ts delete mode 100644 cypress/support/clipboard.ts delete mode 100644 cypress/support/composer.ts delete mode 100644 cypress/support/iframes.ts delete mode 100644 cypress/support/labs.ts delete mode 100644 cypress/support/network.ts delete mode 100644 cypress/support/percy.ts delete mode 100644 cypress/support/performance.ts diff --git a/cypress/e2e/create-room/create-room.spec.ts b/cypress/e2e/create-room/create-room.spec.ts index aee2a60874..8a26c05e9b 100644 --- a/cypress/e2e/create-room/create-room.spec.ts +++ b/cypress/e2e/create-room/create-room.spec.ts @@ -62,7 +62,6 @@ describe("Create Room", () => { const nameLabel = "Nom"; cy.get(`[label="${nameLabel}"]`).type(name); // Submit - cy.startMeasuring("from-submit-to-room"); cy.get(".mx_Dialog_primary").click(); }); @@ -70,7 +69,6 @@ describe("Create Room", () => { // http://localhost:8080/#/room/!kshfkshfkKSHJ:agent1.tchap.incubateur.net const roomUrlRegex = new RegExp("/#/room/![A-z0-9]+:" + homeserverShortname); cy.url().should("match", roomUrlRegex); - cy.stopMeasuring("from-submit-to-room"); cy.get(".mx_LegacyRoomHeader_nametext").contains(name); cy.get(".tc_RoomHeader_external").should("not.exist"); }); @@ -86,7 +84,6 @@ describe("Create Room", () => { // Change room to external cy.get(".tc_TchapRoomTypeSelector_external").click(); // Submit - cy.startMeasuring("from-submit-to-room"); cy.get(".mx_Dialog_primary").click(); }); @@ -94,7 +91,6 @@ describe("Create Room", () => { // http://localhost:8080/#/room/!kshfkshfkKSHJ:agent1.tchap.incubateur.net const roomUrlRegex = new RegExp("/#/room/![A-z0-9]+:" + homeserverShortname); cy.url().should("match", roomUrlRegex); - cy.stopMeasuring("from-submit-to-room"); cy.get(".mx_LegacyRoomHeader_nametext").contains(name); cy.get(".tc_RoomHeader_external").should("exist"); }); @@ -109,7 +105,6 @@ describe("Create Room", () => { // Change room to public cy.get(".tc_TchapRoomTypeSelector_forum").click(); // Submit - cy.startMeasuring("from-submit-to-room"); cy.get(".mx_Dialog_primary").click(); }); @@ -117,7 +112,6 @@ describe("Create Room", () => { // http://localhost:8080/#/room/!kshfkshfkKSHJ:agent1.tchap.incubateur.net const roomUrlRegex = new RegExp("/#/room/![A-z0-9]+:" + homeserverShortname); cy.url().should("match", roomUrlRegex); - cy.stopMeasuring("from-submit-to-room"); cy.get(".mx_LegacyRoomHeader_nametext").contains(name); }); diff --git a/cypress/e2e/login/login.spec.ts b/cypress/e2e/login/login.spec.ts index 69f1c446c0..3403576af4 100644 --- a/cypress/e2e/login/login.spec.ts +++ b/cypress/e2e/login/login.spec.ts @@ -51,7 +51,6 @@ describe("Login", () => { // For now, the login is run against the default_server_config.m.homeserver.base_url present in config.json. it("logs in with an existing account and lands on the home screen", () => { cy.get("#mx_LoginForm_email", { timeout: 15000 }).should("be.visible"); - cy.percySnapshot("Login"); cy.get("#mx_LoginForm_email").type(username); cy.get("#mx_LoginForm_password").type(password); diff --git a/cypress/e2e/register/register.spec.ts b/cypress/e2e/register/register.spec.ts deleted file mode 100644 index 6544c77abb..0000000000 --- a/cypress/e2e/register/register.spec.ts +++ /dev/null @@ -1,78 +0,0 @@ -/* -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. -*/ - -/// - -describe("Registration", () => { - const homeserverUrl = Cypress.env("E2E_TEST_USER_HOMESERVER_URL"); - beforeEach(() => { - cy.visit("/#/register"); - }); - - afterEach(() => { - // todo delete user - }); - - it.skip("registers an account and lands on the home screen", () => { - cy.get(".mx_ServerPicker_change", { timeout: 15000 }).click(); - cy.get(".mx_ServerPickerDialog_continue").should("be.visible"); - cy.percySnapshot("Server Picker"); - - cy.get(".mx_ServerPickerDialog_otherHomeserver").type(homeserverUrl); - cy.get(".mx_ServerPickerDialog_continue").click(); - // wait for the dialog to go away - cy.get(".mx_ServerPickerDialog").should("not.exist"); - - cy.get("#mx_RegistrationForm_username").should("be.visible"); - // Hide the server text as it contains the randomly allocated Synapse port - const percyCSS = ".mx_ServerPicker_server { visibility: hidden !important; }"; - cy.percySnapshot("Registration", { percyCSS }); - - cy.get("#mx_RegistrationForm_username").type("alice"); - cy.get("#mx_RegistrationForm_password").type("totally a great password"); - cy.get("#mx_RegistrationForm_passwordConfirm").type("totally a great password"); - cy.startMeasuring("create-account"); - cy.get(".mx_Login_submit").click(); - - cy.get(".mx_RegistrationEmailPromptDialog").should("be.visible"); - cy.percySnapshot("Registration email prompt", { percyCSS }); - cy.get(".mx_RegistrationEmailPromptDialog button.mx_Dialog_primary").click(); - - cy.stopMeasuring("create-account"); - cy.get(".mx_InteractiveAuthEntryComponents_termsPolicy").should("be.visible"); - cy.percySnapshot("Registration terms prompt", { percyCSS }); - - cy.get(".mx_InteractiveAuthEntryComponents_termsPolicy input").click(); - cy.startMeasuring("from-submit-to-home"); - cy.get(".mx_InteractiveAuthEntryComponents_termsSubmit").click(); - - cy.get(".mx_UseCaseSelection_skip").should("exist"); - cy.percySnapshot("Use-case selection screen"); - cy.get(".mx_UseCaseSelection_skip .mx_AccessibleButton").click(); - - cy.url().should("contain", "/#/home"); - cy.stopMeasuring("from-submit-to-home"); - - const userMenuLabel = "Menu utilisateur"; - cy.get(`[aria-label="${userMenuLabel}"]`).click(); - const securityLabel = "Sécurité et vie privée"; - cy.get(`[aria-label="${securityLabel}"]`).click(); - cy.get(".mx_DevicesPanel_myDevice .mx_DevicesPanel_deviceTrust .mx_E2EIcon").should( - "have.class", - "mx_E2EIcon_verified", - ); - }); -}); diff --git a/cypress/support/clipboard.ts b/cypress/support/clipboard.ts deleted file mode 100644 index 795caee595..0000000000 --- a/cypress/support/clipboard.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* -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. -*/ - -/// - -import Chainable = Cypress.Chainable; - -// Mock the clipboard, as only Electron gives the app permission to the clipboard API by default -// Virtual clipboard -let copyText: string; - -declare global { - // eslint-disable-next-line @typescript-eslint/no-namespace - namespace Cypress { - interface Chainable { - /** - * Mock the clipboard on the current window, ready for calling `getClipboardText`. - * Irreversible, refresh the window to restore mock. - */ - mockClipboard(): Chainable; - /** - * Read text from the mocked clipboard. - * @return {string} the clipboard text - */ - getClipboardText(): Chainable; - } - } -} - -Cypress.Commands.add("mockClipboard", () => { - cy.window({ log: false }).then((win) => { - win.navigator.clipboard.writeText = (text) => { - copyText = text; - return Promise.resolve(); - }; - }); -}); - -Cypress.Commands.add("getClipboardText", (): Chainable => { - return cy.wrap(copyText); -}); - -// Needed to make this file a module -export {}; diff --git a/cypress/support/composer.ts b/cypress/support/composer.ts deleted file mode 100644 index 347c581a47..0000000000 --- a/cypress/support/composer.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* -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. -*/ - -/// - -import Chainable = Cypress.Chainable; - -declare global { - // eslint-disable-next-line @typescript-eslint/no-namespace - namespace Cypress { - interface Chainable { - // Get the composer element - // selects main timeline composer by default - // set `isRightPanel` true to select right panel composer - getComposer(isRightPanel?: boolean): Chainable; - // Open the message composer kebab menu - openMessageComposerOptions(isRightPanel?: boolean): Chainable; - } - } -} - -Cypress.Commands.add("getComposer", (isRightPanel?: boolean): Chainable => { - const panelClass = isRightPanel ? ".mx_RightPanel" : ".mx_RoomView_body"; - return cy.get(`${panelClass} .mx_MessageComposer`); -}); - -Cypress.Commands.add("openMessageComposerOptions", (isRightPanel?: boolean): Chainable => { - cy.getComposer(isRightPanel).within(() => { - cy.get('[aria-label="More options"]').click(); - }); - return cy.get(".mx_MessageComposer_Menu"); -}); - -// Needed to make this file a module -export {}; diff --git a/cypress/support/e2e.ts b/cypress/support/e2e.ts index e046df9315..e4eadf170c 100644 --- a/cypress/support/e2e.ts +++ b/cypress/support/e2e.ts @@ -16,20 +16,12 @@ limitations under the License. /// -import "@percy/cypress"; import "cypress-real-events"; -import "./performance"; import "./loginToRemoteHomeserver"; -import "./labs"; import "./client"; import "./settings"; -import "./clipboard"; import "./util"; import "./app"; -import "./percy"; import "./views"; -import "./iframes"; import "./timeline"; -import "./network"; -import "./composer"; diff --git a/cypress/support/iframes.ts b/cypress/support/iframes.ts deleted file mode 100644 index 03bd653e3b..0000000000 --- a/cypress/support/iframes.ts +++ /dev/null @@ -1,49 +0,0 @@ -/* -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. -*/ - -/// - -import Chainable = Cypress.Chainable; - -declare global { - // eslint-disable-next-line @typescript-eslint/no-namespace - namespace Cypress { - interface Chainable { - /** - * Gets you into the `body` of the selectable iframe. Best to call - * `within({}, () => { ... })` on the returned Chainable to access - * further elements. - * @param selector The jquery selector to find the frame with. - */ - accessIframe(selector: string): Chainable>; - } - } -} - -// Inspired by https://www.cypress.io/blog/2020/02/12/working-with-iframes-in-cypress/ -Cypress.Commands.add("accessIframe", (selector: string): Chainable> => { - return ( - cy - .get(selector) - .its("0.contentDocument.body") - .should("not.be.empty") - // Cypress loses types in the mess of wrapping, so force cast - .then(cy.wrap) as Chainable> - ); -}); - -// Needed to make this file a module -export {}; diff --git a/cypress/support/labs.ts b/cypress/support/labs.ts deleted file mode 100644 index f069589173..0000000000 --- a/cypress/support/labs.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* -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. -*/ - -import Chainable = Cypress.Chainable; - -/// - -declare global { - // eslint-disable-next-line @typescript-eslint/no-namespace - namespace Cypress { - interface Chainable { - /** - * Enables a labs feature for an element session. - * Has to be called before the session is initialized - * @param feature labsFeature to enable (e.g. "feature_spotlight") - */ - enableLabsFeature(feature: string): Chainable; - } - } -} - -Cypress.Commands.add("enableLabsFeature", (feature: string): Chainable => { - return cy - .window({ log: false }) - .then((win) => { - win.localStorage.setItem(`mx_labs_feature_${feature}`, "true"); - }) - .then(() => null); -}); - -// Needed to make this file a module -export {}; diff --git a/cypress/support/network.ts b/cypress/support/network.ts deleted file mode 100644 index fc2a35029d..0000000000 --- a/cypress/support/network.ts +++ /dev/null @@ -1,70 +0,0 @@ -/* -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. -*/ - -/// - -declare global { - // eslint-disable-next-line @typescript-eslint/no-namespace - namespace Cypress { - interface Chainable { - // Intercept all /_matrix/ networking requests for the logged in user and fail them - goOffline(): void; - // Remove intercept on all /_matrix/ networking requests - goOnline(): void; - } - } -} - -// We manage intercepting Matrix APIs here, as fully disabling networking will disconnect -// the browser under test from the Cypress runner, so can cause issues. - -Cypress.Commands.add("goOffline", (): void => { - cy.log("Going offline"); - cy.window({ log: false }).then((win) => { - cy.intercept( - "**/_matrix/**", - { - headers: { - Authorization: "Bearer " + win.mxMatrixClientPeg.matrixClient.getAccessToken(), - }, - }, - (req) => { - req.destroy(); - }, - ); - }); -}); - -Cypress.Commands.add("goOnline", (): void => { - cy.log("Going online"); - cy.window({ log: false }).then((win) => { - cy.intercept( - "**/_matrix/**", - { - headers: { - Authorization: "Bearer " + win.mxMatrixClientPeg.matrixClient.getAccessToken(), - }, - }, - (req) => { - req.continue(); - }, - ); - win.dispatchEvent(new Event("online")); - }); -}); - -// Needed to make this file a module -export {}; diff --git a/cypress/support/percy.ts b/cypress/support/percy.ts deleted file mode 100644 index f5e30a58fc..0000000000 --- a/cypress/support/percy.ts +++ /dev/null @@ -1,54 +0,0 @@ -/* -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. -*/ - -/// -import { SnapshotOptions as PercySnapshotOptions } from "@percy/core"; - -declare global { - // eslint-disable-next-line @typescript-eslint/no-namespace - namespace Cypress { - interface SnapshotOptions extends PercySnapshotOptions { - domTransformation?: (documentClone: Document) => void; - } - - interface Chainable { - percySnapshotElement(name?: string, options?: SnapshotOptions); - } - - interface Chainable { - /** - * Takes a Percy snapshot of a given element - */ - percySnapshotElement(name: string, options: SnapshotOptions): Chainable; - } - } -} - -Cypress.Commands.add("percySnapshotElement", { prevSubject: "element" }, (subject, name, options) => { - cy.percySnapshot(name, { - domTransformation: (documentClone) => scope(documentClone, subject.selector), - ...options, - }); -}); - -function scope(documentClone: Document, selector: string): Document { - const element = documentClone.querySelector(selector); - documentClone.querySelector("body").innerHTML = element.outerHTML; - - return documentClone; -} - -export {}; diff --git a/cypress/support/performance.ts b/cypress/support/performance.ts deleted file mode 100644 index 5ae1e17ba0..0000000000 --- a/cypress/support/performance.ts +++ /dev/null @@ -1,74 +0,0 @@ -/* -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. -*/ - -/// - -import Chainable = Cypress.Chainable; -import AUTWindow = Cypress.AUTWindow; - -declare global { - // eslint-disable-next-line @typescript-eslint/no-namespace - namespace Cypress { - interface Chainable { - /** - * Start measuring the duration of some task. - * @param task The task name. - */ - startMeasuring(task: string): Chainable; - /** - * Stop measuring the duration of some task. - * The duration is reported in the Cypress log. - * @param task The task name. - */ - stopMeasuring(task: string): Chainable; - } - } -} - -function getPrefix(task: string): string { - return `cy:${Cypress.spec.name.split(".")[0]}:${task}`; -} - -function startMeasuring(task: string): Chainable { - return cy.window({ log: false }).then((win) => { - win.mxPerformanceMonitor.start(getPrefix(task)); - }); -} - -function stopMeasuring(task: string): Chainable { - return cy.window({ log: false }).then((win) => { - const measure = win.mxPerformanceMonitor.stop(getPrefix(task)); - cy.log(`**${task}** ${measure.duration} ms`); - }); -} - -Cypress.Commands.add("startMeasuring", startMeasuring); -Cypress.Commands.add("stopMeasuring", stopMeasuring); - -Cypress.on("window:before:unload", (event: BeforeUnloadEvent) => { - const doc = event.target as Document; - if (doc.location.href === "about:blank") return; - const win = doc.defaultView as AUTWindow; - if (!win.mxPerformanceMonitor) return; - const entries = win.mxPerformanceMonitor.getEntries().filter((entry) => { - return entry.name.startsWith("cy:"); - }); - if (!entries || entries.length === 0) return; - cy.task("addMeasurements", entries); -}); - -// Needed to make this file a module -export {};