Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Add a test for verifying without existing DM
Browse files Browse the repository at this point in the history
A regression test for element-hq/element-web#23819.
  • Loading branch information
richvdh committed Nov 25, 2022
1 parent 13e9e14 commit 1acf995
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
23 changes: 22 additions & 1 deletion cypress/e2e/crypto/crypto.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import { MatrixClient, Room } from "matrix-js-sdk/src/matrix";
import { MatrixClient, Room, RoomMemberEvent } from "matrix-js-sdk/src/matrix";

import type { VerificationRequest } from "matrix-js-sdk/src/crypto/verification/request/VerificationRequest";
import type { ISasEvent } from "matrix-js-sdk/src/crypto/verification/SAS";
Expand Down Expand Up @@ -174,4 +174,25 @@ describe("Cryptography", function() {
testMessages.call(this);
verify.call(this);
});

it("should allow verification when there is no existing DM", function (this: CryptoTestContext) {
cy.bootstrapCrossSigning();

// configure bob to auto-accept the invite
this.bob.on(RoomMemberEvent.Membership, (event, member) => {
if (member.membership === "invite" && member.userId === this.bob.getUserId()) {
this.bob.joinRoom(member.roomId);
}
});

/* we need to have a room with the other user present, so we can open the verification panel */
let roomId: string;
cy.createRoom({ name: "TestRoom", invite: [this.bob.getUserId()]}).then(_room1Id => {
roomId = _room1Id;
cy.log(`Created test room ${roomId}`);
cy.visit(`/#/room/${roomId}`);
});

verify.call(this);
});
});
1 change: 1 addition & 0 deletions cypress/support/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ Cypress.Commands.add("getBot", (synapse: SynapseInstance, opts: CreateBotOpts):
const username = Cypress._.uniqueId("userId_");
const password = Cypress._.uniqueId("password_");
return cy.registerUser(synapse, username, password, opts.displayName).then(credentials => {
cy.log(`Registered bot user ${username} with displayname ${opts.displayName}`);
return cy.window({ log: false }).then(win => {
const cli = new win.matrixcs.MatrixClient({
baseUrl: synapse.baseUrl,
Expand Down
1 change: 1 addition & 0 deletions cypress/support/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ Cypress.Commands.add("initTestUser", (synapse: SynapseInstance, displayName: str
return cy.registerUser(synapse, username, password, displayName).then(() => {
return cy.loginUser(synapse, username, password);
}).then(response => {
cy.log(`Registered test user ${username} with displayname ${displayName}`);
cy.window({ log: false }).then(win => {
// Seed the localStorage with the required credentials
win.localStorage.setItem("mx_hs_url", synapse.baseUrl);
Expand Down

0 comments on commit 1acf995

Please sign in to comment.