Add intercept of config.json
(#10908)
* Add intercept of `config.json` To help make sure that we run our tests against a known config, rather than accidentally making requests to `matrix.org`. * Remove now-redundant stubs of matrix.org files Now that we intercept config.json, all this stuff is redundant. * Reinstate fixture which is actually used Turns out this is used after all * Add a `map_style_url` * disable failing axe check
This commit is contained in:
parent
0d981326ac
commit
81df8a3d2b
9 changed files with 52 additions and 91 deletions
|
@ -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();
|
||||
|
|
|
@ -22,7 +22,6 @@ describe("Registration", () => {
|
|||
let homeserver: HomeserverInstance;
|
||||
|
||||
beforeEach(() => {
|
||||
cy.stubDefaultServer();
|
||||
cy.visit("/#/register");
|
||||
cy.startHomeserver("consent").then((data) => {
|
||||
homeserver = data;
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
{
|
||||
"m.homeserver": {
|
||||
"base_url": "https://matrix-client.matrix.org"
|
||||
},
|
||||
"m.identity_server": {
|
||||
"base_url": "https://vector.im"
|
||||
}
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
{}
|
|
@ -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,
|
||||
},
|
||||
},
|
||||
|
|
41
cypress/support/config.json.ts
Normal file
41
cypress/support/config.json.ts
Normal file
|
@ -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 });
|
||||
});
|
|
@ -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";
|
||||
|
|
|
@ -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 {};
|
||||
|
|
Loading…
Reference in a new issue