@@ -29,6 +29,8 @@ import { flushPromisesWithFakeTimers, mkRoom, stubClient } from "../../../test-u
29
29
import { shouldShowFeedback } from "../../../../src/utils/Feedback" ;
30
30
import SettingsStore from "../../../../src/settings/SettingsStore" ;
31
31
import { SettingLevel } from "../../../../src/settings/SettingLevel" ;
32
+ import defaultDispatcher from "../../../../src/dispatcher/dispatcher" ;
33
+ import SdkConfig from "../../../../src/SdkConfig" ;
32
34
33
35
jest . useFakeTimers ( ) ;
34
36
@@ -40,6 +42,11 @@ jest.mock("../../../../src/utils/direct-messages", () => ({
40
42
startDmOnFirstMessage : jest . fn ( ) ,
41
43
} ) ) ;
42
44
45
+ jest . mock ( "../../../../src/dispatcher/dispatcher" , ( ) => ( {
46
+ register : jest . fn ( ) ,
47
+ dispatch : jest . fn ( ) ,
48
+ } ) ) ;
49
+
43
50
interface IUserChunkMember {
44
51
user_id : string ;
45
52
display_name ?: string ;
@@ -122,7 +129,7 @@ describe("Spotlight Dialog", () => {
122
129
} ;
123
130
124
131
const testPublicRoom : IPublicRoomsChunkRoom = {
125
- room_id : "@ room247:matrix.org" ,
132
+ room_id : "! room247:matrix.org" ,
126
133
name : "Room #247" ,
127
134
topic : "We hope you'll have a <b>shining</b> experience!" ,
128
135
world_readable : false ,
@@ -352,6 +359,34 @@ describe("Spotlight Dialog", () => {
352
359
expect ( startDmOnFirstMessage ) . toHaveBeenCalledWith ( mockedClient , [ new DirectoryMember ( testPerson ) ] ) ;
353
360
} ) ;
354
361
362
+ it ( "should pass via of the server being explored when joining room from directory" , async ( ) => {
363
+ SdkConfig . put ( {
364
+ room_directory : {
365
+ servers : [ "example.tld" ] ,
366
+ } ,
367
+ } ) ;
368
+ localStorage . setItem ( "mx_last_room_directory_server" , "example.tld" ) ;
369
+
370
+ render ( < SpotlightDialog initialFilter = { Filter . PublicRooms } onFinished = { ( ) => null } /> ) ;
371
+
372
+ jest . advanceTimersByTime ( 200 ) ;
373
+ await flushPromisesWithFakeTimers ( ) ;
374
+
375
+ const content = document . querySelector ( "#mx_SpotlightDialog_content" ) ! ;
376
+ const options = content . querySelectorAll ( "div.mx_SpotlightDialog_option" ) ;
377
+ expect ( options . length ) . toBe ( 1 ) ;
378
+ expect ( options [ 0 ] . innerHTML ) . toContain ( testPublicRoom . name ) ;
379
+
380
+ fireEvent . click ( options [ 0 ] ! ) ;
381
+ expect ( defaultDispatcher . dispatch ) . toHaveBeenCalledWith (
382
+ expect . objectContaining ( {
383
+ action : "view_room" ,
384
+ room_id : testPublicRoom . room_id ,
385
+ via_servers : [ "example.tld" ] ,
386
+ } ) ,
387
+ ) ;
388
+ } ) ;
389
+
355
390
describe ( "Feedback prompt" , ( ) => {
356
391
it ( "should show feedback prompt if feedback is enabled" , async ( ) => {
357
392
mocked ( shouldShowFeedback ) . mockReturnValue ( true ) ;
0 commit comments