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

Commit 4b3705d

Browse files
authored
Add a test for verifying without existing DM (#9619)
A regression test for element-hq/element-web#23819.
1 parent d258402 commit 4b3705d

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

cypress/e2e/crypto/crypto.spec.ts

+29
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,17 @@ const bobJoin = function(this: CryptoTestContext) {
9191
cy.contains(".mx_TextualEvent", "Bob joined the room").should("exist");
9292
};
9393

94+
/** configure the given MatrixClient to auto-accept any invites */
95+
function autoJoin(client: MatrixClient) {
96+
cy.window({ log: false }).then(async win => {
97+
client.on(win.matrixcs.RoomMemberEvent.Membership, (event, member) => {
98+
if (member.membership === "invite" && member.userId === client.getUserId()) {
99+
client.joinRoom(member.roomId);
100+
}
101+
});
102+
});
103+
}
104+
94105
const handleVerificationRequest = (request: VerificationRequest): Chainable<EmojiMapping[]> => {
95106
return cy.wrap(new Promise<EmojiMapping[]>((resolve) => {
96107
const onShowSas = (event: ISasEvent) => {
@@ -174,4 +185,22 @@ describe("Cryptography", function() {
174185
testMessages.call(this);
175186
verify.call(this);
176187
});
188+
189+
it("should allow verification when there is no existing DM", function(this: CryptoTestContext) {
190+
cy.bootstrapCrossSigning();
191+
autoJoin(this.bob);
192+
193+
/* we need to have a room with the other user present, so we can open the verification panel */
194+
let roomId: string;
195+
cy.createRoom({ name: "TestRoom", invite: [this.bob.getUserId()] }).then(_room1Id => {
196+
roomId = _room1Id;
197+
cy.log(`Created test room ${roomId}`);
198+
cy.visit(`/#/room/${roomId}`);
199+
// wait for Bob to join the room, otherwise our attempt to open his user details may race
200+
// with his join.
201+
cy.contains(".mx_TextualEvent", "Bob joined the room").should("exist");
202+
});
203+
204+
verify.call(this);
205+
});
177206
});

cypress/support/bot.ts

+1
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ Cypress.Commands.add("getBot", (synapse: SynapseInstance, opts: CreateBotOpts):
7878
const username = Cypress._.uniqueId("userId_");
7979
const password = Cypress._.uniqueId("password_");
8080
return cy.registerUser(synapse, username, password, opts.displayName).then(credentials => {
81+
cy.log(`Registered bot user ${username} with displayname ${opts.displayName}`);
8182
return cy.window({ log: false }).then(win => {
8283
const cli = new win.matrixcs.MatrixClient({
8384
baseUrl: synapse.baseUrl,

cypress/support/login.ts

+1
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ Cypress.Commands.add("initTestUser", (synapse: SynapseInstance, displayName: str
103103
return cy.registerUser(synapse, username, password, displayName).then(() => {
104104
return cy.loginUser(synapse, username, password);
105105
}).then(response => {
106+
cy.log(`Registered test user ${username} with displayname ${displayName}`);
106107
cy.window({ log: false }).then(win => {
107108
// Seed the localStorage with the required credentials
108109
win.localStorage.setItem("mx_hs_url", synapse.baseUrl);

0 commit comments

Comments
 (0)