@@ -20,6 +20,7 @@ import type { ISendEventResponse, MatrixClient, Room } from "matrix-js-sdk/src/m
2020import { HomeserverInstance } from "../plugins/utils/homeserver" ;
2121import { Credentials } from "./homeserver" ;
2222import Chainable = Cypress . Chainable ;
23+ import { collapseLastLogGroup } from "./log" ;
2324
2425interface CreateBotOpts {
2526 /**
@@ -65,6 +66,7 @@ declare global {
6566 * @param opts create bot options
6667 */
6768 getBot ( homeserver : HomeserverInstance , opts : CreateBotOpts ) : Chainable < CypressBot > ;
69+
6870 /**
6971 * Returns a new Bot instance logged in as an existing user
7072 * @param homeserver the instance on which to register the bot user
@@ -78,18 +80,21 @@ declare global {
7880 password : string ,
7981 opts : CreateBotOpts ,
8082 ) : Chainable < MatrixClient > ;
83+
8184 /**
8285 * Let a bot join a room
8386 * @param cli The bot's MatrixClient
8487 * @param roomId ID of the room to join
8588 */
8689 botJoinRoom ( cli : MatrixClient , roomId : string ) : Chainable < Room > ;
90+
8791 /**
8892 * Let a bot join a room by name
8993 * @param cli The bot's MatrixClient
9094 * @param roomName Name of the room to join
9195 */
9296 botJoinRoomByName ( cli : MatrixClient , roomName : string ) : Chainable < Room > ;
97+
9398 /**
9499 * Send a message as a bot into a room
95100 * @param cli The bot's MatrixClient
@@ -173,15 +178,21 @@ Cypress.Commands.add("getBot", (homeserver: HomeserverInstance, opts: CreateBotO
173178 opts = Object . assign ( { } , defaultCreateBotOptions , opts ) ;
174179 const username = Cypress . _ . uniqueId ( opts . userIdPrefix ) ;
175180 const password = Cypress . _ . uniqueId ( "password_" ) ;
181+ Cypress . log ( {
182+ name : "getBot" ,
183+ message : `Create bot user ${ username } with opts ${ JSON . stringify ( opts ) } ` ,
184+ groupStart : true ,
185+ } ) ;
176186 return cy
177187 . registerUser ( homeserver , username , password , opts . displayName )
178188 . then ( ( credentials ) => {
179- cy . log ( `Registered bot user ${ username } with displayname ${ opts . displayName } ` ) ;
180189 return setupBotClient ( homeserver , credentials , opts ) ;
181190 } )
182191 . then ( ( client ) : Chainable < CypressBot > => {
183192 Object . assign ( client , { __cypress_password : password } ) ;
184- return cy . wrap ( client as CypressBot ) ;
193+ Cypress . log ( { groupEnd : true , emitOnly : true } ) ;
194+ collapseLastLogGroup ( ) ;
195+ return cy . wrap ( client as CypressBot , { log : false } ) ;
185196 } ) ;
186197} ) ;
187198
@@ -194,9 +205,21 @@ Cypress.Commands.add(
194205 opts : CreateBotOpts ,
195206 ) : Chainable < MatrixClient > => {
196207 opts = Object . assign ( { } , defaultCreateBotOptions , { bootstrapCrossSigning : false } , opts ) ;
197- return cy . loginUser ( homeserver , username , password ) . then ( ( credentials ) => {
198- return setupBotClient ( homeserver , credentials , opts ) ;
208+ Cypress . log ( {
209+ name : "loginBot" ,
210+ message : `log in as ${ username } with opts ${ JSON . stringify ( opts ) } ` ,
211+ groupStart : true ,
199212 } ) ;
213+ return cy
214+ . loginUser ( homeserver , username , password )
215+ . then ( ( credentials ) => {
216+ return setupBotClient ( homeserver , credentials , opts ) ;
217+ } )
218+ . then ( ( res ) => {
219+ Cypress . log ( { groupEnd : true , emitOnly : true } ) ;
220+ collapseLastLogGroup ( ) ;
221+ cy . wrap ( res , { log : false } ) ;
222+ } ) ;
200223 } ,
201224) ;
202225
0 commit comments