Return the password from `getBot`
... so that we can use it to log in for a second timepull/28217/head
parent
9901219194
commit
e3f591e7d2
|
@ -18,13 +18,14 @@ import { MatrixClient, Room } 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";
|
||||
import type { CypressBot } from "../../support/bot";
|
||||
import { SynapseInstance } from "../../plugins/synapsedocker";
|
||||
import Chainable = Cypress.Chainable;
|
||||
|
||||
type EmojiMapping = [emoji: string, name: string];
|
||||
interface CryptoTestContext extends Mocha.Context {
|
||||
synapse: SynapseInstance;
|
||||
bob: MatrixClient;
|
||||
bob: CypressBot;
|
||||
}
|
||||
|
||||
const waitForVerificationRequest = (cli: MatrixClient): Promise<VerificationRequest> => {
|
||||
|
|
|
@ -46,6 +46,10 @@ const defaultCreateBotOptions = {
|
|||
bootstrapCrossSigning: true,
|
||||
} as CreateBotOpts;
|
||||
|
||||
export interface CypressBot extends MatrixClient {
|
||||
__cypress_password: string;
|
||||
}
|
||||
|
||||
declare global {
|
||||
// eslint-disable-next-line @typescript-eslint/no-namespace
|
||||
namespace Cypress {
|
||||
|
@ -55,7 +59,7 @@ declare global {
|
|||
* @param synapse the instance on which to register the bot user
|
||||
* @param opts create bot options
|
||||
*/
|
||||
getBot(synapse: SynapseInstance, opts: CreateBotOpts): Chainable<MatrixClient>;
|
||||
getBot(synapse: SynapseInstance, opts: CreateBotOpts): Chainable<CypressBot>;
|
||||
/**
|
||||
* Returns a new Bot instance logged in as an existing user
|
||||
* @param synapse the instance on which to register the bot user
|
||||
|
@ -151,13 +155,19 @@ function setupBotClient(
|
|||
});
|
||||
}
|
||||
|
||||
Cypress.Commands.add("getBot", (synapse: SynapseInstance, opts: CreateBotOpts): Chainable<MatrixClient> => {
|
||||
Cypress.Commands.add("getBot", (synapse: SynapseInstance, opts: CreateBotOpts): Chainable<CypressBot> => {
|
||||
opts = Object.assign({}, defaultCreateBotOptions, opts);
|
||||
const username = Cypress._.uniqueId("userId_");
|
||||
const password = Cypress._.uniqueId("password_");
|
||||
return cy.registerUser(synapse, username, password, opts.displayName).then((credentials) => {
|
||||
return cy
|
||||
.registerUser(synapse, username, password, opts.displayName)
|
||||
.then((credentials) => {
|
||||
cy.log(`Registered bot user ${username} with displayname ${opts.displayName}`);
|
||||
return setupBotClient(synapse, credentials, opts);
|
||||
})
|
||||
.then((client): Chainable<CypressBot> => {
|
||||
Object.assign(client, { __cypress_password: password });
|
||||
return cy.wrap(client as CypressBot);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue