diff --git a/cypress/e2e/crypto/decryption-failure.spec.ts b/cypress/e2e/crypto/decryption-failure.spec.ts index a9ace36c22..64df3f5a2c 100644 --- a/cypress/e2e/crypto/decryption-failure.spec.ts +++ b/cypress/e2e/crypto/decryption-failure.spec.ts @@ -15,11 +15,10 @@ limitations under the License. */ import type { VerificationRequest } from "matrix-js-sdk/src/crypto/verification/request/VerificationRequest"; -import type { ISasEvent } from "matrix-js-sdk/src/crypto/verification/SAS"; import type { MatrixClient } from "matrix-js-sdk/src/matrix"; import { HomeserverInstance } from "../../plugins/utils/homeserver"; import { UserCredentials } from "../../support/login"; -import Chainable = Cypress.Chainable; +import { handleVerificationRequest } from "./utils"; const ROOM_NAME = "Test room"; const TEST_USER = "Alia"; @@ -39,24 +38,6 @@ const waitForVerificationRequest = (cli: MatrixClient): Promise => { - return cy.wrap( - new Promise((resolve) => { - const onShowSas = (event: ISasEvent) => { - verifier.off("show_sas", onShowSas); - event.confirm(); - resolve(event.sas.emoji); - }; - - const verifier = request.beginKeyVerification("m.sas.v1"); - verifier.on("show_sas", onShowSas); - verifier.verify(); - }), - // extra timeout, as this sometimes takes a while - { timeout: 30_000 }, - ); -}; - const checkTimelineNarrow = (button = true) => { cy.viewport(800, 600); // SVGA cy.get(".mx_LeftPanel_minimized").should("exist"); // Wait until the left panel is minimized @@ -161,7 +142,11 @@ describe("Decryption Failure Bar", () => { ); cy.wrap(verificationRequestPromise).then((verificationRequest: VerificationRequest) => { cy.wrap(verificationRequest.accept()); - handleVerificationRequest(verificationRequest).then((emojis) => { + cy.wrap( + handleVerificationRequest(verificationRequest), + // extra timeout, as this sometimes takes a while + { timeout: 30_000 }, + ).then((emojis: EmojiMapping[]) => { cy.get(".mx_VerificationShowSas_emojiSas_block").then((emojiBlocks) => { emojis.forEach((emoji: EmojiMapping, index: number) => { expect(emojiBlocks[index].textContent.toLowerCase()).to.eq(emoji[0] + emoji[1]); diff --git a/cypress/e2e/crypto/utils.ts b/cypress/e2e/crypto/utils.ts index 6f99a23d0f..aeb15eab11 100644 --- a/cypress/e2e/crypto/utils.ts +++ b/cypress/e2e/crypto/utils.ts @@ -38,21 +38,19 @@ export function waitForVerificationRequest(cli: MatrixClient): Promise { return new Promise((resolve) => { const onShowSas = (event: ISasEvent) => { verifier.off("show_sas", onShowSas); event.confirm(); - verifier.done(); resolve(event.sas.emoji); };