|
|
|
@ -22,7 +22,7 @@ import React from 'react';
|
|
|
|
|
import ReactDOM from 'react-dom'; |
|
|
|
|
import ReactTestUtils from 'react-addons-test-utils'; |
|
|
|
|
import expect from 'expect'; |
|
|
|
|
import q from 'q'; |
|
|
|
|
import Promise from 'bluebird'; |
|
|
|
|
import MatrixReactTestUtils from 'matrix-react-test-utils'; |
|
|
|
|
|
|
|
|
|
import jssdk from 'matrix-js-sdk'; |
|
|
|
@ -104,7 +104,7 @@ describe('loading:', function () {
|
|
|
|
|
toString: function() { return this.search + this.hash; }, |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
let tokenLoginCompleteDefer = q.defer(); |
|
|
|
|
let tokenLoginCompleteDefer = Promise.defer(); |
|
|
|
|
tokenLoginCompletePromise = tokenLoginCompleteDefer.promise; |
|
|
|
|
|
|
|
|
|
function onNewScreen(screen) { |
|
|
|
@ -140,7 +140,7 @@ describe('loading:', function () {
|
|
|
|
|
realQueryParams={params} |
|
|
|
|
startingFragmentQueryParams={fragParts.params} |
|
|
|
|
enableGuest={true} |
|
|
|
|
onTokenLoginCompleted={tokenLoginCompleteDefer.resolve} |
|
|
|
|
onTokenLoginCompleted={() => tokenLoginCompleteDefer.resolve()} |
|
|
|
|
initialScreenAfterLogin={getScreenFromLocation(windowLocation)} |
|
|
|
|
makeRegistrationUrl={() => {throw new Error('Not implemented');}} |
|
|
|
|
/>, parentDiv |
|
|
|
@ -172,7 +172,7 @@ describe('loading:', function () {
|
|
|
|
|
it('gives a login panel by default', function (done) { |
|
|
|
|
loadApp(); |
|
|
|
|
|
|
|
|
|
q.delay(1).then(() => { |
|
|
|
|
Promise.delay(1).then(() => { |
|
|
|
|
// at this point, we're trying to do a guest registration;
|
|
|
|
|
// we expect a spinner
|
|
|
|
|
assertAtLoadingSpinner(matrixChat); |
|
|
|
@ -195,7 +195,7 @@ describe('loading:', function () {
|
|
|
|
|
uriFragment: "#/room/!room:id", |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
q.delay(1).then(() => { |
|
|
|
|
Promise.delay(1).then(() => { |
|
|
|
|
// at this point, we're trying to do a guest registration;
|
|
|
|
|
// we expect a spinner
|
|
|
|
|
assertAtLoadingSpinner(matrixChat); |
|
|
|
@ -207,7 +207,7 @@ describe('loading:', function () {
|
|
|
|
|
return httpBackend.flush(); |
|
|
|
|
}).then(() => { |
|
|
|
|
// Wait for another trip around the event loop for the UI to update
|
|
|
|
|
return q.delay(10); |
|
|
|
|
return Promise.delay(10); |
|
|
|
|
}).then(() => { |
|
|
|
|
return completeLogin(matrixChat); |
|
|
|
|
}).then(() => { |
|
|
|
@ -337,7 +337,7 @@ describe('loading:', function () {
|
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
return q.delay(1).then(() => { |
|
|
|
|
return Promise.delay(1).then(() => { |
|
|
|
|
// we expect a loading spinner while we log into the RTS
|
|
|
|
|
assertAtLoadingSpinner(matrixChat); |
|
|
|
|
|
|
|
|
@ -401,7 +401,7 @@ describe('loading:', function () {
|
|
|
|
|
it('shows a home page by default', function (done) { |
|
|
|
|
loadApp(); |
|
|
|
|
|
|
|
|
|
q.delay(1).then(() => { |
|
|
|
|
Promise.delay(1).then(() => { |
|
|
|
|
// at this point, we're trying to do a guest registration;
|
|
|
|
|
// we expect a spinner
|
|
|
|
|
assertAtLoadingSpinner(matrixChat); |
|
|
|
@ -434,7 +434,7 @@ describe('loading:', function () {
|
|
|
|
|
|
|
|
|
|
loadApp(); |
|
|
|
|
|
|
|
|
|
q.delay(1).then(() => { |
|
|
|
|
Promise.delay(1).then(() => { |
|
|
|
|
// at this point, we're trying to do a guest registration;
|
|
|
|
|
// we expect a spinner
|
|
|
|
|
assertAtLoadingSpinner(matrixChat); |
|
|
|
@ -469,7 +469,7 @@ describe('loading:', function () {
|
|
|
|
|
loadApp({ |
|
|
|
|
uriFragment: "#/room/!room:id" |
|
|
|
|
}); |
|
|
|
|
q.delay(1).then(() => { |
|
|
|
|
Promise.delay(1).then(() => { |
|
|
|
|
// at this point, we're trying to do a guest registration;
|
|
|
|
|
// we expect a spinner
|
|
|
|
|
assertAtLoadingSpinner(matrixChat); |
|
|
|
@ -557,7 +557,7 @@ describe('loading:', function () {
|
|
|
|
|
|
|
|
|
|
ReactTestUtils.Simulate.click(returnToApp); |
|
|
|
|
|
|
|
|
|
return q.delay(1).then(() => { |
|
|
|
|
return Promise.delay(1).then(() => { |
|
|
|
|
// we should be straight back into the home page
|
|
|
|
|
ReactTestUtils.findRenderedComponentWithType( |
|
|
|
|
matrixChat, sdk.getComponent('structures.HomePage')); |
|
|
|
@ -572,7 +572,7 @@ describe('loading:', function () {
|
|
|
|
|
queryString: "?loginToken=secretToken&homeserver=https%3A%2F%2Fhomeserver&identityServer=https%3A%2F%2Fidserver", |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
q.delay(1).then(() => { |
|
|
|
|
Promise.delay(1).then(() => { |
|
|
|
|
// we expect a spinner while we're logging in
|
|
|
|
|
assertAtLoadingSpinner(matrixChat); |
|
|
|
|
|
|
|
|
@ -626,7 +626,7 @@ describe('loading:', function () {
|
|
|
|
|
|
|
|
|
|
return httpBackend.flush().then(() => { |
|
|
|
|
// Wait for another trip around the event loop for the UI to update
|
|
|
|
|
return q.delay(1); |
|
|
|
|
return Promise.delay(1); |
|
|
|
|
}).then(() => { |
|
|
|
|
// we expect a spinner
|
|
|
|
|
ReactTestUtils.findRenderedComponentWithType( |
|
|
|
@ -671,7 +671,7 @@ function awaitSyncingSpinner(matrixChat, retryLimit, retryCount) {
|
|
|
|
|
} |
|
|
|
|
// loading can take quite a long time, because we delete the
|
|
|
|
|
// indexedDB store.
|
|
|
|
|
return q.delay(5).then(() => { |
|
|
|
|
return Promise.delay(5).then(() => { |
|
|
|
|
return awaitSyncingSpinner(matrixChat, retryLimit, retryCount + 1); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
@ -680,7 +680,7 @@ function awaitSyncingSpinner(matrixChat, retryLimit, retryCount) {
|
|
|
|
|
|
|
|
|
|
// state looks good, check the rendered output
|
|
|
|
|
assertAtSyncingSpinner(matrixChat); |
|
|
|
|
return q(); |
|
|
|
|
return Promise.resolve(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function assertAtSyncingSpinner(matrixChat) { |
|
|
|
@ -708,7 +708,7 @@ function awaitRoomView(matrixChat, retryLimit, retryCount) {
|
|
|
|
|
throw new Error("MatrixChat still not ready after " + |
|
|
|
|
retryCount + " tries"); |
|
|
|
|
} |
|
|
|
|
return q.delay(0).then(() => { |
|
|
|
|
return Promise.delay(0).then(() => { |
|
|
|
|
return awaitRoomView(matrixChat, retryLimit, retryCount + 1); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
@ -718,7 +718,7 @@ function awaitRoomView(matrixChat, retryLimit, retryCount) {
|
|
|
|
|
// state looks good, check the rendered output
|
|
|
|
|
ReactTestUtils.findRenderedComponentWithType( |
|
|
|
|
matrixChat, sdk.getComponent('structures.RoomView')); |
|
|
|
|
return q(); |
|
|
|
|
return Promise.resolve(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function awaitLoginComponent(matrixChat, attempts) { |
|
|
|
|