11import { TestHomeServer , createHS , destroyHS } from "./homerunner" ;
22import {
3- Appservice ,
43 IAppserviceRegistration ,
54 MatrixClient ,
65 Membership ,
@@ -12,7 +11,6 @@ import { BridgeConfig, BridgeConfigRoot } from "../../src/config/Config";
1211import { start } from "../../src/App/BridgeApp" ;
1312import { RSAKeyPairOptions , generateKeyPair } from "node:crypto" ;
1413import path from "node:path" ;
15- import Redis from "ioredis" ;
1614import {
1715 BridgeConfigActorPermission ,
1816 BridgeConfigServicePermission ,
@@ -21,11 +19,15 @@ import { TestContainers } from "testcontainers";
2119
2220const WAIT_EVENT_TIMEOUT = 20000 ;
2321export const E2ESetupTestTimeout = 60000 ;
24- const REDIS_DATABASE_URI =
25- process . env . HOOKSHOT_E2E_REDIS_DB_URI ?? "redis://localhost:6379" ;
2622
2723interface Opts < ML extends string > {
2824 matrixLocalparts ?: ML [ ] ;
25+ staticConnectionRooms ?: Record <
26+ string ,
27+ {
28+ members : string [ ] ;
29+ }
30+ > ;
2931 permissionsRoom ?: {
3032 members : string [ ] ;
3133 permissions : Array < BridgeConfigServicePermission > ;
@@ -378,6 +380,7 @@ export class E2ETestEnv<ML extends string = string> {
378380
379381 const registration : IAppserviceRegistration = {
380382 id : "hookshot" ,
383+ url : null ,
381384 as_token : homeserver . asToken ,
382385 hs_token : homeserver . hsToken ,
383386 sender_localpart : "hookshot" ,
@@ -394,9 +397,22 @@ export class E2ETestEnv<ML extends string = string> {
394397 "de.sorunome.msc2409.push_ephemeral" : true ,
395398 } ;
396399
400+ const connectionRooms : Record < string , string > = { } ;
401+
402+ const botClient = new MatrixClient ( homeserver . url , homeserver . asToken ) ;
403+ for ( const [ roomIdMapper , roomOpts ] of Object . entries (
404+ opts . staticConnectionRooms ?? { } ,
405+ ) ) {
406+ connectionRooms [ roomIdMapper ] = await botClient . createRoom ( {
407+ name : `${ roomIdMapper } ` ,
408+ invite : roomOpts . members . map (
409+ ( localpart ) => `@${ localpart } :${ homeserver . domain } ` ,
410+ ) ,
411+ } ) ;
412+ }
413+
397414 let permissions : BridgeConfigActorPermission [ ] = [ ] ;
398415 if ( opts . permissionsRoom ) {
399- const botClient = new MatrixClient ( homeserver . url , homeserver . asToken ) ;
400416 const permsRoom = await botClient . createRoom ( {
401417 name : "Permissions room" ,
402418 invite : opts . permissionsRoom . members . map (
@@ -448,11 +464,15 @@ export class E2ETestEnv<ML extends string = string> {
448464 cache : cacheConfig ,
449465 permissions,
450466 ...providedConfig ,
467+ connections : opts . config ?. connections ?. map ( ( c ) => ( {
468+ ...c ,
469+ roomId : connectionRooms [ c . roomId ] ,
470+ } ) ) ,
451471 } ) ;
452472 const app = await start ( config , registration ) ;
453473 app . listener . finaliseListeners ( ) ;
454474
455- return new E2ETestEnv ( homeserver , app , opts , config , dir ) ;
475+ return new E2ETestEnv ( homeserver , app , opts , config , dir , connectionRooms ) ;
456476 }
457477
458478 private constructor (
@@ -461,6 +481,7 @@ export class E2ETestEnv<ML extends string = string> {
461481 public readonly opts : Opts < ML > ,
462482 private readonly config : BridgeConfig ,
463483 private readonly dir : string ,
484+ public readonly connectionRooms : Record < string , string > ,
464485 ) {
465486 const appService = app . appservice ;
466487
0 commit comments