Fix tests to reflect recent changes

This is an attempt to reduce flakiness (see https://github.com/matrix-org/matrix-react-sdk/pull/781 also)
This commit is contained in:
Luke Barnard 2017-03-29 16:07:11 +01:00
parent ff2a9f4b20
commit e40d3852ff
2 changed files with 22 additions and 11 deletions

View File

@ -23,6 +23,7 @@ var jssdk = require('matrix-js-sdk');
var sdk = require('matrix-react-sdk');
var peg = require('matrix-react-sdk/lib/MatrixClientPeg');
var dis = require('matrix-react-sdk/lib/dispatcher');
var PageTypes = require('matrix-react-sdk/lib/PageTypes');
var MatrixChat = sdk.getComponent('structures.MatrixChat');
var RoomDirectory = sdk.getComponent('structures.RoomDirectory');
var RoomPreviewBar = sdk.getComponent('rooms.RoomPreviewBar');
@ -90,9 +91,7 @@ describe('joining a room', function () {
matrixChat = ReactDOM.render(mc, parentDiv);
// switch to the Directory
dis.dispatch({
action: 'view_room_directory',
});
matrixChat._setPage(PageTypes.RoomDirectory);
var roomView;
// wait for /sync to happen

View File

@ -104,6 +104,23 @@ describe('loading:', function () {
}
}
// Parse the given window.location and return parameters that can be used when calling
// MatrixChat.showScreen(screen, params)
function getScreenFromLocation(location) {
const fragparts = parseQsFromFragment(location);
return {
screen: fragparts.location.substring(1),
params: fragparts.params,
}
}
function routeUrl(location, matrixChat) {
console.log(Date.now() + "Routing URL " + location);
const s = getScreenFromLocation(location);
console.log("Showing screen", s);
matrixChat.showScreen(s.screen, s.params);
}
const MatrixChat = sdk.getComponent('structures.MatrixChat');
const fragParts = parseQsFromFragment(windowLocation);
var params = parseQs(windowLocation);
@ -118,16 +135,10 @@ describe('loading:', function () {
startingFragmentQueryParams={fragParts.params}
enableGuest={true}
onLoadCompleted={loadCompleteDefer.resolve}
initialScreenAfterLogin={getScreenFromLocation(windowLocation)}
/>, parentDiv
);
function routeUrl(location, matrixChat) {
console.log(Date.now() + " Routing URL "+location);
var fragparts = parseQsFromFragment(location);
matrixChat.showScreen(fragparts.location.substring(1),
fragparts.params);
}
// pause for a cycle, then simulate the window.onload handler
window.setTimeout(() => {
console.log(Date.now() + " simulating window.onload");
@ -476,7 +487,8 @@ function awaitRoomView(matrixChat, retryLimit, retryCount) {
retryCount = 0;
}
if (!matrixChat.state.ready) {
if (matrixChat.state.loading ||
!(matrixChat.state.loggedIn && matrixChat.state.ready)) {
console.log(Date.now() + " Awaiting room view: not ready yet.");
if (retryCount >= retryLimit) {
throw new Error("MatrixChat still not ready after " +