diff --git a/test/app-tests/joining.js b/test/app-tests/joining.js index 1661e0e699..f348e8989f 100644 --- a/test/app-tests/joining.js +++ b/test/app-tests/joining.js @@ -37,6 +37,8 @@ const ReactDOM = require('react-dom'); const ReactTestUtils = require('react-addons-test-utils'); const expect = require('expect'); import Promise from 'bluebird'; +import {makeType} from "matrix-react-sdk/lib/utils/TypeUtils"; +import {ValidatedServerConfig} from "matrix-react-sdk/lib/utils/AutoDiscoveryUtils"; const test_utils = require('../test-utils'); const MockHttpBackend = require('matrix-mock-request'); @@ -97,17 +99,19 @@ describe('joining a room', function() { PlatformPeg.set(new WebPlatform()); const config = { - validated_server_config: { + validated_server_config: makeType(ValidatedServerConfig, { hsUrl: HS_URL, hsName: "TEST_ENVIRONMENT", hsNameIsDifferent: false, // yes, we lie isUrl: IS_URL, identityEnabled: true, - }, + }), }; const mc = ( - {throw new Error("unimplemented");}} initialScreenAfterLogin={{ screen: 'directory', diff --git a/test/app-tests/loading.js b/test/app-tests/loading.js index 4199495fe7..8e7a7807e8 100644 --- a/test/app-tests/loading.js +++ b/test/app-tests/loading.js @@ -39,6 +39,8 @@ import dis from 'matrix-react-sdk/lib/dispatcher'; import * as test_utils from '../test-utils'; import MockHttpBackend from 'matrix-mock-request'; import {parseQs, parseQsFromFragment} from '../../src/vector/url_utils'; +import {makeType} from "matrix-react-sdk/lib/utils/TypeUtils"; +import {ValidatedServerConfig} from "matrix-react-sdk/lib/utils/AutoDiscoveryUtils"; const DEFAULT_HS_URL='http://my_server'; const DEFAULT_IS_URL='http://my_is'; @@ -146,13 +148,13 @@ describe('loading:', function() { const config = Object.assign({ default_hs_url: DEFAULT_HS_URL, default_is_url: DEFAULT_IS_URL, - validated_server_config: { + validated_server_config: makeType(ValidatedServerConfig, { hsUrl: DEFAULT_HS_URL, hsName: "TEST_ENVIRONMENT", hsNameIsDifferent: false, // yes, we lie isUrl: DEFAULT_IS_URL, identityEnabled: true, - }, + }), embeddedPages: { homeUrl: 'data:text/html;charset=utf-8;base64,PGh0bWw+PC9odG1sPg==', }, @@ -167,6 +169,7 @@ describe('loading:', function() { component const login = ReactTestUtils.findRenderedComponentWithType( matrixChat, sdk.getComponent('structures.auth.Login')); + // When we switch to the login component, it'll hit the login endpoint + // for proof of life and to get flows. We'll only give it one option. + httpBackend.when('GET', '/login') + .respond(200, {"flows": [{"type": "m.login.password"}]}); + httpBackend.flush(); // We already would have tried the GET /login request + + // Give the component some time to finish processing the login flows before + // continuing. + await Promise.delay(100); + httpBackend.when('POST', '/login').check(function(req) { expect(req.data.type).toEqual('m.login.password'); expect(req.data.identifier.type).toEqual('m.id.user');