File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -330,6 +330,7 @@ export class StreamChat<StreamChatGenerics extends ExtendableGenerics = DefaultG
330330 warmUp : false ,
331331 recoverStateOnReconnect : true ,
332332 disableCache : false ,
333+ wsUrlSuffix : '' ,
333334 ...inputOptions ,
334335 } ;
335336
Original file line number Diff line number Diff line change @@ -191,7 +191,7 @@ export class StableWSConnection<StreamChatGenerics extends ExtendableGenerics =
191191 this . client . key
192192 } &authorization=${ token } &stream-auth-type=${ this . client . getAuthType ( ) } &X-Stream-Client=${ encodeURIComponent (
193193 this . client . getUserAgent ( ) ,
194- ) } `;
194+ ) } ${ this . client . options . wsUrlSuffix } `;
195195 } ;
196196
197197 /**
Original file line number Diff line number Diff line change @@ -1241,6 +1241,11 @@ export type StreamChatOptions = AxiosRequestConfig & {
12411241 * not be used in production apps.
12421242 */
12431243 wsConnection ?: StableWSConnection ;
1244+ /**
1245+ * Sets a suffix to the wsUrl when it is being built in `wsConnection`. Is meant to be
1246+ * used purely in testing suites and should not be used in production apps.
1247+ */
1248+ wsUrlSuffix ?: string ;
12441249} ;
12451250
12461251export type SyncOptions = {
Original file line number Diff line number Diff line change @@ -91,6 +91,20 @@ describe('connection', function () {
9191 const data = JSON . parse ( query . json ) ;
9292 expect ( data . device ) . to . deep . undefined ;
9393 } ) ;
94+
95+ it ( 'should include extra params when building url if provided' , function ( ) {
96+ const { query : prevQuery } = url . parse ( ws . _buildUrl ( ) , true ) ;
97+ ws . client . options . wsUrlSuffix = '&foo=1&bar=2' ;
98+ const { query } = url . parse ( ws . _buildUrl ( ) , true ) ;
99+
100+ // all of the previous query params should remain intact
101+ Object . keys ( prevQuery ) . forEach ( ( key ) => {
102+ expect ( prevQuery [ key ] ) . to . deep . equal ( query [ key ] ) ;
103+ } ) ;
104+ // only the updated query should contain the new ones
105+ expect ( query . foo ) . to . equal ( '1' ) ;
106+ expect ( query . bar ) . to . equal ( '2' ) ;
107+ } ) ;
94108 } ) ;
95109
96110 describe ( 'isResolved flag' , ( ) => {
You can’t perform that action at this time.
0 commit comments