mirror of
https://github.com/element-hq/element-web
synced 2024-11-22 17:25:50 +03:00
Merge pull request #3537 from vector-im/luke/fix-flaky-tests-maybe
Fix tests to reflect recent changes
This commit is contained in:
commit
6380f1a24a
2 changed files with 22 additions and 11 deletions
|
@ -23,6 +23,7 @@ var jssdk = require('matrix-js-sdk');
|
||||||
var sdk = require('matrix-react-sdk');
|
var sdk = require('matrix-react-sdk');
|
||||||
var peg = require('matrix-react-sdk/lib/MatrixClientPeg');
|
var peg = require('matrix-react-sdk/lib/MatrixClientPeg');
|
||||||
var dis = require('matrix-react-sdk/lib/dispatcher');
|
var dis = require('matrix-react-sdk/lib/dispatcher');
|
||||||
|
var PageTypes = require('matrix-react-sdk/lib/PageTypes');
|
||||||
var MatrixChat = sdk.getComponent('structures.MatrixChat');
|
var MatrixChat = sdk.getComponent('structures.MatrixChat');
|
||||||
var RoomDirectory = sdk.getComponent('structures.RoomDirectory');
|
var RoomDirectory = sdk.getComponent('structures.RoomDirectory');
|
||||||
var RoomPreviewBar = sdk.getComponent('rooms.RoomPreviewBar');
|
var RoomPreviewBar = sdk.getComponent('rooms.RoomPreviewBar');
|
||||||
|
@ -90,9 +91,7 @@ describe('joining a room', function () {
|
||||||
matrixChat = ReactDOM.render(mc, parentDiv);
|
matrixChat = ReactDOM.render(mc, parentDiv);
|
||||||
|
|
||||||
// switch to the Directory
|
// switch to the Directory
|
||||||
dis.dispatch({
|
matrixChat._setPage(PageTypes.RoomDirectory);
|
||||||
action: 'view_room_directory',
|
|
||||||
});
|
|
||||||
|
|
||||||
var roomView;
|
var roomView;
|
||||||
// wait for /sync to happen
|
// wait for /sync to happen
|
||||||
|
|
|
@ -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 MatrixChat = sdk.getComponent('structures.MatrixChat');
|
||||||
const fragParts = parseQsFromFragment(windowLocation);
|
const fragParts = parseQsFromFragment(windowLocation);
|
||||||
var params = parseQs(windowLocation);
|
var params = parseQs(windowLocation);
|
||||||
|
@ -118,16 +135,10 @@ describe('loading:', function () {
|
||||||
startingFragmentQueryParams={fragParts.params}
|
startingFragmentQueryParams={fragParts.params}
|
||||||
enableGuest={true}
|
enableGuest={true}
|
||||||
onLoadCompleted={loadCompleteDefer.resolve}
|
onLoadCompleted={loadCompleteDefer.resolve}
|
||||||
|
initialScreenAfterLogin={getScreenFromLocation(windowLocation)}
|
||||||
/>, parentDiv
|
/>, 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
|
// pause for a cycle, then simulate the window.onload handler
|
||||||
window.setTimeout(() => {
|
window.setTimeout(() => {
|
||||||
console.log(Date.now() + " simulating window.onload");
|
console.log(Date.now() + " simulating window.onload");
|
||||||
|
@ -476,7 +487,8 @@ function awaitRoomView(matrixChat, retryLimit, retryCount) {
|
||||||
retryCount = 0;
|
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.");
|
console.log(Date.now() + " Awaiting room view: not ready yet.");
|
||||||
if (retryCount >= retryLimit) {
|
if (retryCount >= retryLimit) {
|
||||||
throw new Error("MatrixChat still not ready after " +
|
throw new Error("MatrixChat still not ready after " +
|
||||||
|
|
Loading…
Reference in a new issue