mirror of
https://github.com/vector-im/element-web.git
synced 2024-09-09 22:55:12 +00:00
Step 3.1: Stop using getComponent
in tests
This commit is contained in:
parent
303f06cc61
commit
1bbecdff6c
2 changed files with 20 additions and 24 deletions
|
@ -18,7 +18,6 @@ limitations under the License.
|
|||
|
||||
import PlatformPeg from 'matrix-react-sdk/src/PlatformPeg';
|
||||
import WebPlatform from '../../src/vector/platform/WebPlatform';
|
||||
import * as sdk from "matrix-react-sdk/src/index";
|
||||
import * as jssdk from "matrix-js-sdk/src/matrix";
|
||||
import "../skin-sdk";
|
||||
import "../jest-mocks";
|
||||
|
@ -28,15 +27,12 @@ import ReactTestUtils from "react-dom/test-utils";
|
|||
import {makeType} from "matrix-react-sdk/src/utils/TypeUtils";
|
||||
import {ValidatedServerConfig} from "matrix-react-sdk/src/utils/AutoDiscoveryUtils";
|
||||
import {sleep} from "../test-utils";
|
||||
import * as test_utils from "../test-utils";
|
||||
import MockHttpBackend from "matrix-mock-request";
|
||||
import "fake-indexeddb/auto";
|
||||
import { RoomView as RoomViewClass } from 'matrix-react-sdk/src/components/structures/RoomView';
|
||||
|
||||
|
||||
const MatrixChat = sdk.getComponent('structures.MatrixChat');
|
||||
const RoomDirectory = sdk.getComponent('structures.RoomDirectory');
|
||||
const RoomPreviewBar = sdk.getComponent('rooms.RoomPreviewBar');
|
||||
import MatrixChat from "matrix-react-sdk/src/components/structures/MatrixChat";
|
||||
import RoomDirectory from "matrix-react-sdk/src/components/structures/RoomDirectory";
|
||||
import RoomPreviewBar from "matrix-react-sdk/src/components/views/rooms/RoomPreviewBar";
|
||||
|
||||
const HS_URL='http://localhost';
|
||||
const IS_URL='http://localhost';
|
||||
|
|
|
@ -26,9 +26,8 @@ import ReactDOM from 'react-dom';
|
|||
import ReactTestUtils from 'react-dom/test-utils';
|
||||
import MatrixReactTestUtils from 'matrix-react-test-utils';
|
||||
import * as jssdk from 'matrix-js-sdk/src/matrix';
|
||||
import * as sdk from 'matrix-react-sdk/src/index';
|
||||
import {MatrixClientPeg} from 'matrix-react-sdk/src/MatrixClientPeg';
|
||||
import {Views} from 'matrix-react-sdk/src/components/structures/MatrixChat';
|
||||
import MatrixChat, {Views} from 'matrix-react-sdk/src/components/structures/MatrixChat';
|
||||
import dis from 'matrix-react-sdk/src/dispatcher/dispatcher';
|
||||
import * as test_utils from '../test-utils';
|
||||
import MockHttpBackend from 'matrix-mock-request';
|
||||
|
@ -41,6 +40,8 @@ import {cleanLocalstorage} from "../test-utils";
|
|||
import {IndexedDBCryptoStore} from "matrix-js-sdk/src/crypto/store/indexeddb-crypto-store";
|
||||
import { RoomView as RoomViewClass } from 'matrix-react-sdk/src/components/structures/RoomView';
|
||||
import LoginComponent from 'matrix-react-sdk/src/components/structures/auth/Login';
|
||||
import WelcomeComponent from "matrix-react-sdk/src/components/views/auth/Welcome";
|
||||
import EmbeddedPage from "matrix-react-sdk/src/components/structures/EmbeddedPage";
|
||||
|
||||
const DEFAULT_HS_URL='http://my_server';
|
||||
const DEFAULT_IS_URL='http://my_is';
|
||||
|
@ -124,7 +125,6 @@ describe('loading:', function() {
|
|||
};
|
||||
}
|
||||
|
||||
const MatrixChat = sdk.getComponent('structures.MatrixChat');
|
||||
const fragParts = parseQsFromFragment(windowLocation);
|
||||
|
||||
const config = Object.assign({
|
||||
|
@ -269,7 +269,7 @@ describe('loading:', function() {
|
|||
return awaitLoginComponent(matrixChat).then(() => {
|
||||
// we expect a single <Login> component
|
||||
ReactTestUtils.findRenderedComponentWithType(
|
||||
matrixChat, sdk.getComponent('structures.auth.Login'));
|
||||
matrixChat, LoginComponent);
|
||||
|
||||
// the only outstanding request should be a GET /login
|
||||
// (in particular there should be no /register request for
|
||||
|
@ -290,7 +290,7 @@ describe('loading:', function() {
|
|||
}).then(() => {
|
||||
// once the sync completes, we should have a room view
|
||||
ReactTestUtils.findRenderedComponentWithType(
|
||||
matrixChat, sdk.getComponent('structures.EmbeddedPage'));
|
||||
matrixChat, EmbeddedPage);
|
||||
expect(windowLocation.hash).toEqual("#/home");
|
||||
});
|
||||
});
|
||||
|
@ -343,7 +343,7 @@ describe('loading:', function() {
|
|||
// once the sync completes, we should have a home page
|
||||
httpBackend.verifyNoOutstandingExpectation();
|
||||
ReactTestUtils.findRenderedComponentWithType(
|
||||
matrixChat, sdk.getComponent('structures.EmbeddedPage'));
|
||||
matrixChat, EmbeddedPage);
|
||||
expect(windowLocation.hash).toEqual("#/home");
|
||||
});
|
||||
});
|
||||
|
@ -384,7 +384,7 @@ describe('loading:', function() {
|
|||
|
||||
// we expect a single <Login> component
|
||||
ReactTestUtils.findRenderedComponentWithType(
|
||||
matrixChat, sdk.getComponent('structures.auth.Login'),
|
||||
matrixChat, LoginComponent,
|
||||
);
|
||||
|
||||
// the only outstanding request should be a GET /login
|
||||
|
@ -413,7 +413,7 @@ describe('loading:', function() {
|
|||
// we should see a home page, even though we previously had
|
||||
// a stored mx_last_room_id
|
||||
ReactTestUtils.findRenderedComponentWithType(
|
||||
matrixChat, sdk.getComponent('structures.EmbeddedPage'));
|
||||
matrixChat, EmbeddedPage);
|
||||
expect(windowLocation.hash).toEqual("#/home");
|
||||
});
|
||||
});
|
||||
|
@ -447,7 +447,7 @@ describe('loading:', function() {
|
|||
// once the sync completes, we should have a welcome page
|
||||
httpBackend.verifyNoOutstandingExpectation();
|
||||
ReactTestUtils.findRenderedComponentWithType(
|
||||
matrixChat, sdk.getComponent('auth.Welcome'));
|
||||
matrixChat, WelcomeComponent);
|
||||
expect(windowLocation.hash).toEqual("#/welcome");
|
||||
});
|
||||
});
|
||||
|
@ -480,7 +480,7 @@ describe('loading:', function() {
|
|||
// once the sync completes, we should have a welcome page
|
||||
httpBackend.verifyNoOutstandingExpectation();
|
||||
ReactTestUtils.findRenderedComponentWithType(
|
||||
matrixChat, sdk.getComponent('auth.Welcome'));
|
||||
matrixChat, WelcomeComponent);
|
||||
expect(windowLocation.hash).toEqual("#/welcome");
|
||||
expect(MatrixClientPeg.get().baseUrl).toEqual(DEFAULT_HS_URL);
|
||||
expect(MatrixClientPeg.get().idBaseUrl).toEqual(DEFAULT_IS_URL);
|
||||
|
@ -539,7 +539,7 @@ describe('loading:', function() {
|
|||
}).then(() => {
|
||||
// once the sync completes, we should have a home page
|
||||
ReactTestUtils.findRenderedComponentWithType(
|
||||
matrixChat, sdk.getComponent('structures.EmbeddedPage'));
|
||||
matrixChat, EmbeddedPage);
|
||||
|
||||
// we simulate a click on the 'login' button by firing off
|
||||
// the relevant dispatch.
|
||||
|
@ -561,7 +561,7 @@ describe('loading:', function() {
|
|||
|
||||
// we expect a single <Login> component
|
||||
ReactTestUtils.findRenderedComponentWithType(
|
||||
matrixChat, sdk.getComponent('structures.auth.Login'),
|
||||
matrixChat, LoginComponent,
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -569,7 +569,7 @@ describe('loading:', function() {
|
|||
// ILAG renders this obsolete. I think.
|
||||
it('should allow us to return to the app', function() {
|
||||
const login = ReactTestUtils.findRenderedComponentWithType(
|
||||
matrixChat, sdk.getComponent('structures.auth.Login')
|
||||
matrixChat, LoginComponent
|
||||
);
|
||||
|
||||
const linkText = 'Return to app';
|
||||
|
@ -586,7 +586,7 @@ describe('loading:', function() {
|
|||
return sleep(1).then(() => {
|
||||
// we should be straight back into the home page
|
||||
ReactTestUtils.findRenderedComponentWithType(
|
||||
matrixChat, sdk.getComponent('structures.EmbeddedPage'));
|
||||
matrixChat, EmbeddedPage);
|
||||
});
|
||||
});
|
||||
*/
|
||||
|
@ -733,19 +733,19 @@ function awaitRoomView(matrixChat, retryLimit?, retryCount?) {
|
|||
|
||||
function awaitLoginComponent(matrixChat, attempts?) {
|
||||
return MatrixReactTestUtils.waitForRenderedComponentWithType(
|
||||
matrixChat, sdk.getComponent('structures.auth.Login'), attempts,
|
||||
matrixChat, LoginComponent, attempts,
|
||||
);
|
||||
}
|
||||
|
||||
function awaitWelcomeComponent(matrixChat, attempts?) {
|
||||
return MatrixReactTestUtils.waitForRenderedComponentWithType(
|
||||
matrixChat, sdk.getComponent('auth.Welcome'), attempts,
|
||||
matrixChat, WelcomeComponent, attempts,
|
||||
);
|
||||
}
|
||||
|
||||
function moveFromWelcomeToLogin(matrixChat) {
|
||||
ReactTestUtils.findRenderedComponentWithType(
|
||||
matrixChat, sdk.getComponent('auth.Welcome'));
|
||||
matrixChat, WelcomeComponent);
|
||||
dis.dispatch({ action: 'start_login' });
|
||||
return awaitLoginComponent(matrixChat);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue