Cypress: skip tests known to fail when using Rust crypto (#10873)

* Cypress: skip tests known to fail when using Rust crypto

... which means we can then run the cypress test suite against Element Web R to
check we aren't introducing regressions.

* Update cypress/e2e/register/register.spec.ts

* Use env var to detect rust crypto

* Hoist `skipIfRustCrypto` call earlier
pull/28217/head
Richard van der Hoff 2023-05-24 10:50:05 +01:00 committed by GitHub
parent 0c30f0c838
commit 2571f54e8b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 30 additions and 3 deletions

View File

@ -18,6 +18,7 @@ import type { VerificationRequest } from "matrix-js-sdk/src/crypto/verification/
import { HomeserverInstance } from "../../plugins/utils/homeserver";
import { handleVerificationRequest, waitForVerificationRequest } from "./utils";
import { CypressBot } from "../../support/bot";
import { skipIfRustCrypto } from "../../support/util";
describe("Complete security", () => {
let homeserver: HomeserverInstance;
@ -46,6 +47,8 @@ describe("Complete security", () => {
});
it("should walk through device verification if we have a signed device", () => {
skipIfRustCrypto();
// create a new user, and have it bootstrap cross-signing
let botClient: CypressBot;
cy.getBot(homeserver, { displayName: "Jeff" })

View File

@ -20,6 +20,7 @@ import type { CypressBot } from "../../support/bot";
import { HomeserverInstance } from "../../plugins/utils/homeserver";
import { UserCredentials } from "../../support/login";
import { EmojiMapping, handleVerificationRequest, waitForVerificationRequest } from "./utils";
import { skipIfRustCrypto } from "../../support/util";
interface CryptoTestContext extends Mocha.Context {
homeserver: HomeserverInstance;
@ -152,6 +153,7 @@ describe("Cryptography", function () {
});
it("setting up secure key backup should work", () => {
skipIfRustCrypto();
cy.openUserSettings("Security & Privacy");
cy.findByRole("button", { name: "Set up Secure Backup" }).click();
cy.get(".mx_Dialog").within(() => {
@ -175,6 +177,7 @@ describe("Cryptography", function () {
});
it("creating a DM should work, being e2e-encrypted / user verification", function (this: CryptoTestContext) {
skipIfRustCrypto();
cy.bootstrapCrossSigning(aliceCredentials);
startDMWithBob.call(this);
// send first message
@ -196,6 +199,7 @@ describe("Cryptography", function () {
});
it("should allow verification when there is no existing DM", function (this: CryptoTestContext) {
skipIfRustCrypto();
cy.bootstrapCrossSigning(aliceCredentials);
autoJoin(this.bob);
@ -214,6 +218,7 @@ describe("Cryptography", function () {
});
it("should show the correct shield on edited e2e events", function (this: CryptoTestContext) {
skipIfRustCrypto();
cy.bootstrapCrossSigning(aliceCredentials);
// bob has a second, not cross-signed, device

View File

@ -19,6 +19,7 @@ import type { MatrixClient } from "matrix-js-sdk/src/matrix";
import { HomeserverInstance } from "../../plugins/utils/homeserver";
import { UserCredentials } from "../../support/login";
import { handleVerificationRequest } from "./utils";
import { skipIfRustCrypto } from "../../support/util";
const ROOM_NAME = "Test room";
const TEST_USER = "Alia";
@ -67,6 +68,7 @@ describe("Decryption Failure Bar", () => {
let roomId: string;
beforeEach(function () {
skipIfRustCrypto();
cy.startHomeserver("default").then((hs: HomeserverInstance) => {
homeserver = hs;
cy.initTestUser(homeserver, TEST_USER)

View File

@ -20,6 +20,8 @@ limitations under the License.
* we make requests to the live `matrix.org`, which makes our tests dependent on matrix.org being up and responsive.
*/
import { isRustCryptoEnabled } from "./util";
const CONFIG_JSON = {
// This is deliberately quite a minimal config.json, so that we can test that the default settings
// actually work.
@ -40,7 +42,7 @@ beforeEach(() => {
const configJson = CONFIG_JSON;
// configure element to use rust crypto if the env var tells us so
if (Cypress.env("RUST_CRYPTO")) {
if (isRustCryptoEnabled()) {
configJson["features"] = {
feature_rust_crypto: true,
};

View File

@ -56,5 +56,20 @@ cy.all = function all(commands): Cypress.Chainable {
return cy.wrap(resultArray, { log: false });
};
// Needed to make this file a module
export {};
/**
* Check if Cypress has been configured to enable rust crypto, and bail out if so.
*/
export function skipIfRustCrypto() {
if (isRustCryptoEnabled()) {
cy.log("Skipping due to rust crypto");
//@ts-ignore: 'state' is a secret internal command
cy.state("runnable").skip();
}
}
/**
* Determine if Cypress has been configured to enable rust crypto (by checking the environment variable)
*/
export function isRustCryptoEnabled(): boolean {
return !!Cypress.env("RUST_CRYPTO");
}