@@ -237,6 +237,36 @@ describe('loading:', function () {
237237 expect ( localStorage . getItem ( 'mx_is_url' ) ) . toEqual ( DEFAULT_IS_URL ) ;
238238 } ) . done ( done , done ) ;
239239 } ) ;
240+
241+ it ( 'should not register as a guest when using a #/login link' , function ( ) {
242+ loadApp ( {
243+ uriFragment : "#/login" ,
244+ } ) ;
245+
246+ return q . delay ( 100 ) . then ( ( ) => {
247+ // we expect a single <Login> component
248+ ReactTestUtils . findRenderedComponentWithType (
249+ matrixChat , sdk . getComponent ( 'structures.login.Login' ) ) ;
250+
251+ // the only outstanding request should be a GET /login
252+ // (in particular there should be no /register request for
253+ // guest registration).
254+ for ( const req of httpBackend . requests ) {
255+ if ( req . method === 'GET' && req . path . endsWith ( '/_matrix/client/r0/login' ) ) {
256+ continue ;
257+ }
258+
259+ throw new Error ( `Unexpected HTTP request to ${ req } ` ) ;
260+ }
261+ return completeLogin ( matrixChat ) ;
262+ } ) . then ( ( ) => {
263+
264+ // once the sync completes, we should have a room view
265+ ReactTestUtils . findRenderedComponentWithType (
266+ matrixChat , sdk . getComponent ( 'structures.HomePage' ) ) ;
267+ expect ( windowLocation . hash ) . toEqual ( "#/home" ) ;
268+ } ) ;
269+ } ) ;
240270 } ) ;
241271
242272 describe ( "MatrixClient rehydrated from stored credentials:" , function ( ) {
@@ -308,28 +338,33 @@ describe('loading:', function () {
308338
309339 describe ( '/#/login link:' , function ( ) {
310340 beforeEach ( function ( ) {
311- httpBackend . when ( 'GET' , '/pushrules' ) . respond ( 200 , { } ) ;
312- httpBackend . when ( 'POST' , '/filter' ) . respond ( 200 , { filter_id : 'fid' } ) ;
313-
314341 loadApp ( {
315342 uriFragment : "#/login" ,
316343 } ) ;
317-
318- return expectAndAwaitSync ( ) . then ( ( ) => {
319- return q . delay ( 1 ) ;
320- } ) ;
321344 } ) ;
322345
323346 it ( 'shows a login view' , function ( ) {
324347 // we expect a single <Login> component
325- const login = ReactTestUtils . findRenderedComponentWithType (
348+ ReactTestUtils . findRenderedComponentWithType (
326349 matrixChat , sdk . getComponent ( 'structures.login.Login' )
327350 ) ;
351+
352+ // the only outstanding request should be a GET /login
353+ // (in particular there should be no /register request for
354+ // guest registration, nor /sync, etc).
355+ for ( const req of httpBackend . requests ) {
356+ if ( req . method === 'GET' && req . path . endsWith ( '/_matrix/client/r0/login' ) ) {
357+ continue ;
358+ }
359+
360+ throw new Error ( `Unexpected HTTP request to ${ req } ` ) ;
361+ }
328362 } ) ;
329363
330364 it ( 'shows the homepage after login' , function ( ) {
331365 return completeLogin ( matrixChat ) . then ( ( ) => {
332- // we should see a home page if we previously had no room
366+ // we should see a home page, even though we previously had
367+ // a stored mx_last_room_id
333368 ReactTestUtils . findRenderedComponentWithType (
334369 matrixChat , sdk . getComponent ( 'structures.HomePage' ) ) ;
335370 expect ( windowLocation . hash ) . toEqual ( "#/home" ) ;
0 commit comments