diff --git a/cypress/e2e/login/login.spec.ts b/cypress/e2e/login/login.spec.ts index 7098a4ce9d..9bc6dd3f1b 100644 --- a/cypress/e2e/login/login.spec.ts +++ b/cypress/e2e/login/login.spec.ts @@ -21,10 +21,6 @@ import { HomeserverInstance } from "../../plugins/utils/homeserver"; describe("Login", () => { let homeserver: HomeserverInstance; - beforeEach(() => { - cy.stubDefaultServer(); - }); - afterEach(() => { cy.stopHomeserver(homeserver); }); @@ -44,17 +40,18 @@ describe("Login", () => { it("logs in with an existing account and lands on the home screen", () => { cy.injectAxe(); - cy.findByRole("textbox", { name: "Username", timeout: 15000 }).should("be.visible"); - // Disabled because flaky - see https://github.com/vector-im/element-web/issues/24688 - //cy.percySnapshot("Login"); - cy.checkA11y(); - + // first pick the homeserver, as otherwise the user picker won't be visible cy.findByRole("button", { name: "Edit" }).click(); cy.findByRole("textbox", { name: "Other homeserver" }).type(homeserver.baseUrl); cy.findByRole("button", { name: "Continue" }).click(); // wait for the dialog to go away cy.get(".mx_ServerPickerDialog").should("not.exist"); + cy.findByRole("textbox", { name: "Username", timeout: 15000 }).should("be.visible"); + // Disabled because flaky - see https://github.com/vector-im/element-web/issues/24688 + //cy.percySnapshot("Login"); + cy.checkA11y(); + cy.findByRole("textbox", { name: "Username" }).type(username); cy.findByPlaceholderText("Password").type(password); cy.findByRole("button", { name: "Sign in" }).click(); diff --git a/cypress/e2e/register/register.spec.ts b/cypress/e2e/register/register.spec.ts index 152915cc1c..79f4987353 100644 --- a/cypress/e2e/register/register.spec.ts +++ b/cypress/e2e/register/register.spec.ts @@ -22,7 +22,6 @@ describe("Registration", () => { let homeserver: HomeserverInstance; beforeEach(() => { - cy.stubDefaultServer(); cy.visit("/#/register"); cy.startHomeserver("consent").then((data) => { homeserver = data; diff --git a/cypress/fixtures/matrix-org-client-login.json b/cypress/fixtures/matrix-org-client-login.json deleted file mode 100644 index d7c4fde1e5..0000000000 --- a/cypress/fixtures/matrix-org-client-login.json +++ /dev/null @@ -1,48 +0,0 @@ -{ - "flows": [ - { - "type": "m.login.sso", - "identity_providers": [ - { - "id": "oidc-github", - "name": "GitHub", - "icon": "mxc://matrix.org/sVesTtrFDTpXRbYfpahuJsKP", - "brand": "github" - }, - { - "id": "oidc-google", - "name": "Google", - "icon": "mxc://matrix.org/ZlnaaZNPxtUuQemvgQzlOlkz", - "brand": "google" - }, - { - "id": "oidc-gitlab", - "name": "GitLab", - "icon": "mxc://matrix.org/MCVOEmFgVieKFshPxmnejWOq", - "brand": "gitlab" - }, - { - "id": "oidc-facebook", - "name": "Facebook", - "icon": "mxc://matrix.org/nsyeLIgzxazZmJadflMAsAWG", - "brand": "facebook" - }, - { - "id": "oidc-apple", - "name": "Apple", - "icon": "mxc://matrix.org/QQKNSOdLiMHtJhzeAObmkFiU", - "brand": "apple" - } - ] - }, - { - "type": "m.login.token" - }, - { - "type": "m.login.password" - }, - { - "type": "m.login.application_service" - } - ] -} diff --git a/cypress/fixtures/matrix-org-client-well-known.json b/cypress/fixtures/matrix-org-client-well-known.json deleted file mode 100644 index ed726e2421..0000000000 --- a/cypress/fixtures/matrix-org-client-well-known.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "m.homeserver": { - "base_url": "https://matrix-client.matrix.org" - }, - "m.identity_server": { - "base_url": "https://vector.im" - } -} diff --git a/cypress/fixtures/vector-im-identity-v2.json b/cypress/fixtures/vector-im-identity-v2.json deleted file mode 100644 index 0967ef424b..0000000000 --- a/cypress/fixtures/vector-im-identity-v2.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/cypress/support/axe.ts b/cypress/support/axe.ts index c0e7a6332a..38a297fe18 100644 --- a/cypress/support/axe.ts +++ b/cypress/support/axe.ts @@ -59,6 +59,10 @@ Cypress.Commands.overwrite( "color-contrast": { enabled: false, }, + // link-in-text-block also complains due to known contrast issues + "link-in-text-block": { + enabled: false, + }, ...options.rules, }, }, diff --git a/cypress/support/config.json.ts b/cypress/support/config.json.ts new file mode 100644 index 0000000000..ca91d9eeef --- /dev/null +++ b/cypress/support/config.json.ts @@ -0,0 +1,41 @@ +/* +Copyright 2023 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. +*/ + +/* Intercept requests to `config.json`, so that we can test against a known configuration. + * + * If we don't do this, we end up testing against the Element config for develop.element.io, which then means + * we make requests to the live `matrix.org`, which makes our tests dependent on matrix.org being up and responsive. + */ + +const CONFIG_JSON = { + // This is deliberately quite a minimal config.json, so that we can test that the default settings + // actually work. + // + // The only thing that we really *need* (otherwise Element refuses to load) is a default homeserver. + // We point that to a guaranteed-invalid domain. + default_server_config: { + "m.homeserver": { + base_url: "https://server.invalid", + }, + }, + + // the location tests want a map style url. + map_style_url: "https://api.maptiler.com/maps/streets/style.json?key=fU3vlMsMn4Jb6dnEIFsx", +}; + +beforeEach(() => { + cy.intercept({ method: "GET", pathname: "/config.json" }, { body: CONFIG_JSON }); +}); diff --git a/cypress/support/e2e.ts b/cypress/support/e2e.ts index 2349bf350a..4f268966a3 100644 --- a/cypress/support/e2e.ts +++ b/cypress/support/e2e.ts @@ -20,6 +20,7 @@ import "@percy/cypress"; import "cypress-real-events"; import "@testing-library/cypress/add-commands"; +import "./config.json"; import "./homeserver"; import "./login"; import "./labs"; diff --git a/cypress/support/network.ts b/cypress/support/network.ts index 0cd38d9119..3e031099fb 100644 --- a/cypress/support/network.ts +++ b/cypress/support/network.ts @@ -68,29 +68,5 @@ Cypress.Commands.add("goOnline", (): void => { }); }); -Cypress.Commands.add("stubDefaultServer", (): void => { - cy.log("Stubbing vector.im and matrix.org network calls"); - // We intercept vector.im & matrix.org calls so that tests don't fail when it has issues - cy.intercept("GET", "https://vector.im/_matrix/identity/v2", { - fixture: "vector-im-identity-v2.json", - }); - cy.intercept("GET", "https://matrix.org/.well-known/matrix/client", { - fixture: "matrix-org-client-well-known.json", - }); - cy.intercept("GET", "https://matrix-client.matrix.org/_matrix/client/versions", { - fixture: "matrix-org-client-versions.json", - }); - cy.intercept("GET", "https://matrix-client.matrix.org/_matrix/client/r0/login", { - fixture: "matrix-org-client-login.json", - }); - cy.intercept("POST", "https://matrix-client.matrix.org/_matrix/client/r0/register?kind=guest", { - statusCode: 403, - body: { - errcode: "M_FORBIDDEN", - error: "Registration is not enabled on this homeserver.", - }, - }); -}); - // Needed to make this file a module export {};