mirror of https://github.com/vector-im/riot-web
Return the password from `getBot`
... so that we can use it to log in for a second timepull/28788/head^2
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 { VerificationRequest } from "matrix-js-sdk/src/crypto/verification/request/VerificationRequest";
|
||||||
import type { ISasEvent } from "matrix-js-sdk/src/crypto/verification/SAS";
|
import type { ISasEvent } from "matrix-js-sdk/src/crypto/verification/SAS";
|
||||||
|
import type { CypressBot } from "../../support/bot";
|
||||||
import { SynapseInstance } from "../../plugins/synapsedocker";
|
import { SynapseInstance } from "../../plugins/synapsedocker";
|
||||||
import Chainable = Cypress.Chainable;
|
import Chainable = Cypress.Chainable;
|
||||||
|
|
||||||
type EmojiMapping = [emoji: string, name: string];
|
type EmojiMapping = [emoji: string, name: string];
|
||||||
interface CryptoTestContext extends Mocha.Context {
|
interface CryptoTestContext extends Mocha.Context {
|
||||||
synapse: SynapseInstance;
|
synapse: SynapseInstance;
|
||||||
bob: MatrixClient;
|
bob: CypressBot;
|
||||||
}
|
}
|
||||||
|
|
||||||
const waitForVerificationRequest = (cli: MatrixClient): Promise<VerificationRequest> => {
|
const waitForVerificationRequest = (cli: MatrixClient): Promise<VerificationRequest> => {
|
||||||
|
|
|
@ -46,6 +46,10 @@ const defaultCreateBotOptions = {
|
||||||
bootstrapCrossSigning: true,
|
bootstrapCrossSigning: true,
|
||||||
} as CreateBotOpts;
|
} as CreateBotOpts;
|
||||||
|
|
||||||
|
export interface CypressBot extends MatrixClient {
|
||||||
|
__cypress_password: string;
|
||||||
|
}
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-namespace
|
// eslint-disable-next-line @typescript-eslint/no-namespace
|
||||||
namespace Cypress {
|
namespace Cypress {
|
||||||
|
@ -55,7 +59,7 @@ declare global {
|
||||||
* @param synapse the instance on which to register the bot user
|
* @param synapse the instance on which to register the bot user
|
||||||
* @param opts create bot options
|
* @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
|
* Returns a new Bot instance logged in as an existing user
|
||||||
* @param synapse the instance on which to register the bot user
|
* @param synapse the instance on which to register the bot user
|
||||||
|
@ -151,14 +155,20 @@ 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);
|
opts = Object.assign({}, defaultCreateBotOptions, opts);
|
||||||
const username = Cypress._.uniqueId("userId_");
|
const username = Cypress._.uniqueId("userId_");
|
||||||
const password = Cypress._.uniqueId("password_");
|
const password = Cypress._.uniqueId("password_");
|
||||||
return cy.registerUser(synapse, username, password, opts.displayName).then((credentials) => {
|
return cy
|
||||||
cy.log(`Registered bot user ${username} with displayname ${opts.displayName}`);
|
.registerUser(synapse, username, password, opts.displayName)
|
||||||
return setupBotClient(synapse, credentials, opts);
|
.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);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
Cypress.Commands.add(
|
Cypress.Commands.add(
|
||||||
|
|
Loading…
Reference in New Issue