mirror of
https://github.com/element-hq/element-web
synced 2024-11-22 17:25:50 +03:00
Use promises in tests properly
This commit is contained in:
parent
eac6c46d28
commit
0a209fc340
1 changed files with 24 additions and 24 deletions
|
@ -213,10 +213,10 @@ describe('loading:', function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
describe("Clean load with no stored credentials:", function() {
|
describe("Clean load with no stored credentials:", function() {
|
||||||
it('gives a welcome page by default', function(done) {
|
it('gives a welcome page by default', function() {
|
||||||
loadApp();
|
loadApp();
|
||||||
|
|
||||||
sleep(1).then(() => {
|
return sleep(1).then(() => {
|
||||||
// at this point, we're trying to do a guest registration;
|
// at this point, we're trying to do a guest registration;
|
||||||
// we expect a spinner
|
// we expect a spinner
|
||||||
assertAtLoadingSpinner(matrixChat);
|
assertAtLoadingSpinner(matrixChat);
|
||||||
|
@ -231,10 +231,10 @@ describe('loading:', function() {
|
||||||
return awaitWelcomeComponent(matrixChat);
|
return awaitWelcomeComponent(matrixChat);
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
expect(windowLocation.hash).toEqual("#/welcome");
|
expect(windowLocation.hash).toEqual("#/welcome");
|
||||||
}).then(done, done);
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should follow the original link after successful login', function(done) {
|
it('should follow the original link after successful login', function() {
|
||||||
loadApp({
|
loadApp({
|
||||||
uriFragment: "#/room/!room:id",
|
uriFragment: "#/room/!room:id",
|
||||||
});
|
});
|
||||||
|
@ -243,7 +243,7 @@ describe('loading:', function() {
|
||||||
httpBackend.when("GET", "/versions").respond(200, {versions: ["r0.4.0"]});
|
httpBackend.when("GET", "/versions").respond(200, {versions: ["r0.4.0"]});
|
||||||
httpBackend.when("GET", "/api/v1").respond(200, {});
|
httpBackend.when("GET", "/api/v1").respond(200, {});
|
||||||
|
|
||||||
sleep(1).then(() => {
|
return sleep(1).then(() => {
|
||||||
// at this point, we're trying to do a guest registration;
|
// at this point, we're trying to do a guest registration;
|
||||||
// we expect a spinner
|
// we expect a spinner
|
||||||
assertAtLoadingSpinner(matrixChat);
|
assertAtLoadingSpinner(matrixChat);
|
||||||
|
@ -272,7 +272,7 @@ describe('loading:', function() {
|
||||||
expect(localStorage.getItem('mx_access_token')).toEqual('access_token');
|
expect(localStorage.getItem('mx_access_token')).toEqual('access_token');
|
||||||
expect(localStorage.getItem('mx_hs_url')).toEqual(DEFAULT_HS_URL);
|
expect(localStorage.getItem('mx_hs_url')).toEqual(DEFAULT_HS_URL);
|
||||||
expect(localStorage.getItem('mx_is_url')).toEqual(DEFAULT_IS_URL);
|
expect(localStorage.getItem('mx_is_url')).toEqual(DEFAULT_IS_URL);
|
||||||
}).then(done, done);
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not register as a guest when using a #/login link', function() {
|
it('should not register as a guest when using a #/login link', function() {
|
||||||
|
@ -348,7 +348,7 @@ describe('loading:', function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('shows a home page by default if we have no joined rooms', function(done) {
|
it('shows a home page by default if we have no joined rooms', function() {
|
||||||
localStorage.removeItem("mx_last_room_id");
|
localStorage.removeItem("mx_last_room_id");
|
||||||
|
|
||||||
httpBackend.when('GET', '/pushrules').respond(200, {});
|
httpBackend.when('GET', '/pushrules').respond(200, {});
|
||||||
|
@ -356,7 +356,7 @@ describe('loading:', function() {
|
||||||
|
|
||||||
loadApp();
|
loadApp();
|
||||||
|
|
||||||
awaitLoggedIn(matrixChat).then(() => {
|
return awaitLoggedIn(matrixChat).then(() => {
|
||||||
// we are logged in - let the sync complete
|
// we are logged in - let the sync complete
|
||||||
return expectAndAwaitSync();
|
return expectAndAwaitSync();
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
|
@ -365,10 +365,10 @@ describe('loading:', function() {
|
||||||
ReactTestUtils.findRenderedComponentWithType(
|
ReactTestUtils.findRenderedComponentWithType(
|
||||||
matrixChat, sdk.getComponent('structures.EmbeddedPage'));
|
matrixChat, sdk.getComponent('structures.EmbeddedPage'));
|
||||||
expect(windowLocation.hash).toEqual("#/home");
|
expect(windowLocation.hash).toEqual("#/home");
|
||||||
}).then(done, done);
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('shows a room view if we followed a room link', function(done) {
|
it('shows a room view if we followed a room link', function() {
|
||||||
httpBackend.when('GET', '/pushrules').respond(200, {});
|
httpBackend.when('GET', '/pushrules').respond(200, {});
|
||||||
httpBackend.when('POST', '/filter').respond(200, { filter_id: 'fid' });
|
httpBackend.when('POST', '/filter').respond(200, { filter_id: 'fid' });
|
||||||
|
|
||||||
|
@ -376,7 +376,7 @@ describe('loading:', function() {
|
||||||
uriFragment: "#/room/!room:id",
|
uriFragment: "#/room/!room:id",
|
||||||
});
|
});
|
||||||
|
|
||||||
awaitLoggedIn(matrixChat).then(() => {
|
return awaitLoggedIn(matrixChat).then(() => {
|
||||||
// we are logged in - let the sync complete
|
// we are logged in - let the sync complete
|
||||||
return expectAndAwaitSync();
|
return expectAndAwaitSync();
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
|
@ -385,7 +385,7 @@ describe('loading:', function() {
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
httpBackend.verifyNoOutstandingExpectation();
|
httpBackend.verifyNoOutstandingExpectation();
|
||||||
expect(windowLocation.hash).toEqual("#/room/!room:id");
|
expect(windowLocation.hash).toEqual("#/room/!room:id");
|
||||||
}).then(done, done);
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('/#/login link:', function() {
|
describe('/#/login link:', function() {
|
||||||
|
@ -442,10 +442,10 @@ describe('loading:', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Guest auto-registration:', function() {
|
describe('Guest auto-registration:', function() {
|
||||||
it('shows a welcome page by default', function(done) {
|
it('shows a welcome page by default', function() {
|
||||||
loadApp();
|
loadApp();
|
||||||
|
|
||||||
sleep(1).then(() => {
|
return sleep(1).then(() => {
|
||||||
// at this point, we're trying to do a guest registration;
|
// at this point, we're trying to do a guest registration;
|
||||||
// we expect a spinner
|
// we expect a spinner
|
||||||
assertAtLoadingSpinner(matrixChat);
|
assertAtLoadingSpinner(matrixChat);
|
||||||
|
@ -469,13 +469,13 @@ describe('loading:', function() {
|
||||||
ReactTestUtils.findRenderedComponentWithType(
|
ReactTestUtils.findRenderedComponentWithType(
|
||||||
matrixChat, sdk.getComponent('auth.Welcome'));
|
matrixChat, sdk.getComponent('auth.Welcome'));
|
||||||
expect(windowLocation.hash).toEqual("#/welcome");
|
expect(windowLocation.hash).toEqual("#/welcome");
|
||||||
}).then(done, done);
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('uses the default homeserver to register with', function(done) {
|
it('uses the default homeserver to register with', function() {
|
||||||
loadApp();
|
loadApp();
|
||||||
|
|
||||||
sleep(1).then(() => {
|
return sleep(1).then(() => {
|
||||||
// at this point, we're trying to do a guest registration;
|
// at this point, we're trying to do a guest registration;
|
||||||
// we expect a spinner
|
// we expect a spinner
|
||||||
assertAtLoadingSpinner(matrixChat);
|
assertAtLoadingSpinner(matrixChat);
|
||||||
|
@ -503,14 +503,14 @@ describe('loading:', function() {
|
||||||
expect(windowLocation.hash).toEqual("#/welcome");
|
expect(windowLocation.hash).toEqual("#/welcome");
|
||||||
expect(MatrixClientPeg.get().baseUrl).toEqual(DEFAULT_HS_URL);
|
expect(MatrixClientPeg.get().baseUrl).toEqual(DEFAULT_HS_URL);
|
||||||
expect(MatrixClientPeg.get().idBaseUrl).toEqual(DEFAULT_IS_URL);
|
expect(MatrixClientPeg.get().idBaseUrl).toEqual(DEFAULT_IS_URL);
|
||||||
}).then(done, done);
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('shows a room view if we followed a room link', function(done) {
|
it('shows a room view if we followed a room link', function() {
|
||||||
loadApp({
|
loadApp({
|
||||||
uriFragment: "#/room/!room:id",
|
uriFragment: "#/room/!room:id",
|
||||||
});
|
});
|
||||||
sleep(1).then(() => {
|
return sleep(1).then(() => {
|
||||||
// at this point, we're trying to do a guest registration;
|
// at this point, we're trying to do a guest registration;
|
||||||
// we expect a spinner
|
// we expect a spinner
|
||||||
assertAtLoadingSpinner(matrixChat);
|
assertAtLoadingSpinner(matrixChat);
|
||||||
|
@ -533,7 +533,7 @@ describe('loading:', function() {
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
httpBackend.verifyNoOutstandingExpectation();
|
httpBackend.verifyNoOutstandingExpectation();
|
||||||
expect(windowLocation.hash).toEqual("#/room/!room:id");
|
expect(windowLocation.hash).toEqual("#/room/!room:id");
|
||||||
}).then(done, done);
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Login as user', function() {
|
describe('Login as user', function() {
|
||||||
|
@ -611,12 +611,12 @@ describe('loading:', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Token login:', function() {
|
describe('Token login:', function() {
|
||||||
it('logs in successfully', function(done) {
|
it('logs in successfully', function() {
|
||||||
loadApp({
|
loadApp({
|
||||||
queryString: "?loginToken=secretToken&homeserver=https%3A%2F%2Fhomeserver&identityServer=https%3A%2F%2Fidserver",
|
queryString: "?loginToken=secretToken&homeserver=https%3A%2F%2Fhomeserver&identityServer=https%3A%2F%2Fidserver",
|
||||||
});
|
});
|
||||||
|
|
||||||
sleep(1).then(() => {
|
return sleep(1).then(() => {
|
||||||
// we expect a spinner while we're logging in
|
// we expect a spinner while we're logging in
|
||||||
assertAtLoadingSpinner(matrixChat);
|
assertAtLoadingSpinner(matrixChat);
|
||||||
|
|
||||||
|
@ -645,7 +645,7 @@ describe('loading:', function() {
|
||||||
expect(localStorage.getItem('mx_access_token')).toEqual('access_token');
|
expect(localStorage.getItem('mx_access_token')).toEqual('access_token');
|
||||||
expect(localStorage.getItem('mx_hs_url')).toEqual('https://homeserver');
|
expect(localStorage.getItem('mx_hs_url')).toEqual('https://homeserver');
|
||||||
expect(localStorage.getItem('mx_is_url')).toEqual('https://idserver');
|
expect(localStorage.getItem('mx_is_url')).toEqual('https://idserver');
|
||||||
}).then(done, done);
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue