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

Commit 8ad7a4f

Browse files
committed
playwright: factor out createSecondBotDevice utility
1 parent 76b8950 commit 8ad7a4f

File tree

2 files changed

+20
-15
lines changed

2 files changed

+20
-15
lines changed

playwright/e2e/crypto/event-shields.spec.ts

+9-15
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,16 @@ SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only
66
Please see LICENSE files in the repository root for full details.
77
*/
88

9-
import { Page } from "@playwright/test";
10-
119
import { expect, test } from "../../element-web-test";
12-
import { autoJoin, createSharedRoomWithUser, enableKeyBackup, logIntoElement, logOutOfElement, verify } from "./utils";
13-
import { Bot } from "../../pages/bot";
14-
import { HomeserverInstance } from "../../plugins/homeserver";
10+
import {
11+
autoJoin,
12+
createSecondBotDevice,
13+
createSharedRoomWithUser,
14+
enableKeyBackup,
15+
logIntoElement,
16+
logOutOfElement,
17+
verify,
18+
} from "./utils";
1519

1620
test.describe("Cryptography", function () {
1721
test.use({
@@ -296,13 +300,3 @@ test.describe("Cryptography", function () {
296300
});
297301
});
298302
});
299-
300-
async function createSecondBotDevice(page: Page, homeserver: HomeserverInstance, bob: Bot) {
301-
const bobSecondDevice = new Bot(page, homeserver, {
302-
bootstrapSecretStorage: false,
303-
bootstrapCrossSigning: false,
304-
});
305-
bobSecondDevice.setCredentials(await homeserver.loginUser(bob.credentials.userId, bob.credentials.password));
306-
await bobSecondDevice.prepareClient();
307-
return bobSecondDevice;
308-
}

playwright/e2e/crypto/utils.ts

+11
Original file line numberDiff line numberDiff line change
@@ -377,3 +377,14 @@ export async function awaitVerifier(
377377
return verificationRequest.verifier;
378378
});
379379
}
380+
381+
/** Log in a second device for the given bot user */
382+
export async function createSecondBotDevice(page: Page, homeserver: HomeserverInstance, bob: Bot) {
383+
const bobSecondDevice = new Bot(page, homeserver, {
384+
bootstrapSecretStorage: false,
385+
bootstrapCrossSigning: false,
386+
});
387+
bobSecondDevice.setCredentials(await homeserver.loginUser(bob.credentials.userId, bob.credentials.password));
388+
await bobSecondDevice.prepareClient();
389+
return bobSecondDevice;
390+
}

0 commit comments

Comments
 (0)