@@ -39,6 +39,8 @@ import dis from 'matrix-react-sdk/lib/dispatcher';
3939import * as test_utils from '../test-utils' ;
4040import MockHttpBackend from 'matrix-mock-request' ;
4141import { parseQs , parseQsFromFragment } from '../../src/vector/url_utils' ;
42+ import { makeType } from "matrix-react-sdk/lib/utils/TypeUtils" ;
43+ import { ValidatedServerConfig } from "matrix-react-sdk/lib/utils/AutoDiscoveryUtils" ;
4244
4345const DEFAULT_HS_URL = 'http://my_server' ;
4446const DEFAULT_IS_URL = 'http://my_is' ;
@@ -146,13 +148,13 @@ describe('loading:', function() {
146148 const config = Object . assign ( {
147149 default_hs_url : DEFAULT_HS_URL ,
148150 default_is_url : DEFAULT_IS_URL ,
149- validated_server_config : {
151+ validated_server_config : makeType ( ValidatedServerConfig , {
150152 hsUrl : DEFAULT_HS_URL ,
151153 hsName : "TEST_ENVIRONMENT" ,
152154 hsNameIsDifferent : false , // yes, we lie
153155 isUrl : DEFAULT_IS_URL ,
154156 identityEnabled : true ,
155- } ,
157+ } ) ,
156158 embeddedPages : {
157159 homeUrl : 'data:text/html;charset=utf-8;base64,PGh0bWw+PC9odG1sPg==' ,
158160 } ,
@@ -167,6 +169,7 @@ describe('loading:', function() {
167169 < MatrixChat
168170 onNewScreen = { onNewScreen }
169171 config = { config }
172+ serverConfig = { config . validated_server_config }
170173 realQueryParams = { params }
171174 startingFragmentQueryParams = { fragParts . params }
172175 enableGuest = { true }
@@ -623,11 +626,21 @@ describe('loading:', function() {
623626
624627 // check that we have a Login component, send a 'user:pass' login,
625628 // and await the HTTP requests.
626- function completeLogin ( matrixChat ) {
629+ async function completeLogin ( matrixChat ) {
627630 // we expect a single <Login> component
628631 const login = ReactTestUtils . findRenderedComponentWithType (
629632 matrixChat , sdk . getComponent ( 'structures.auth.Login' ) ) ;
630633
634+ // When we switch to the login component, it'll hit the login endpoint
635+ // for proof of life and to get flows. We'll only give it one option.
636+ httpBackend . when ( 'GET' , '/login' )
637+ . respond ( 200 , { "flows" : [ { "type" : "m.login.password" } ] } ) ;
638+ httpBackend . flush ( ) ; // We already would have tried the GET /login request
639+
640+ // Give the component some time to finish processing the login flows before
641+ // continuing.
642+ await Promise . delay ( 100 ) ;
643+
631644 httpBackend . when ( 'POST' , '/login' ) . check ( function ( req ) {
632645 expect ( req . data . type ) . toEqual ( 'm.login.password' ) ;
633646 expect ( req . data . identifier . type ) . toEqual ( 'm.id.user' ) ;
0 commit comments