mirror of
https://github.com/SchildiChat/element-web.git
synced 2024-10-01 01:26:12 -04:00
Merge pull request #4201 from vector-im/luke/fix-tests
Fix tests for new-guest-access
This commit is contained in:
commit
88e843d992
@ -62,7 +62,7 @@ module.exports = React.createClass({
|
|||||||
{ method: "GET", url: src },
|
{ method: "GET", url: src },
|
||||||
(err, response, body) => {
|
(err, response, body) => {
|
||||||
if (err || response.status < 200 || response.status >= 300) {
|
if (err || response.status < 200 || response.status >= 300) {
|
||||||
console.log(error);
|
console.log(err);
|
||||||
this.setState({ page: "Couldn't load home page" });
|
this.setState({ page: "Couldn't load home page" });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,13 +88,13 @@ describe('joining a room', function () {
|
|||||||
var mc = (
|
var mc = (
|
||||||
<MatrixChat config={{}}
|
<MatrixChat config={{}}
|
||||||
makeRegistrationUrl={()=>{throw new Error("unimplemented");}}
|
makeRegistrationUrl={()=>{throw new Error("unimplemented");}}
|
||||||
|
initialScreenAfterLogin={{
|
||||||
|
screen: 'directory',
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
matrixChat = ReactDOM.render(mc, parentDiv);
|
matrixChat = ReactDOM.render(mc, parentDiv);
|
||||||
|
|
||||||
// switch to the Directory
|
|
||||||
matrixChat._setPage(PageTypes.RoomDirectory);
|
|
||||||
|
|
||||||
var roomView;
|
var roomView;
|
||||||
|
|
||||||
// wait for /sync to happen. This may take some time, as the client
|
// wait for /sync to happen. This may take some time, as the client
|
||||||
@ -138,7 +138,11 @@ describe('joining a room', function () {
|
|||||||
httpBackend.when('GET', '/directory/room/'+encodeURIComponent(ROOM_ALIAS)).respond(200, { room_id: ROOM_ID });
|
httpBackend.when('GET', '/directory/room/'+encodeURIComponent(ROOM_ALIAS)).respond(200, { room_id: ROOM_ID });
|
||||||
httpBackend.when('GET', '/rooms/'+encodeURIComponent(ROOM_ID)+"/initialSync")
|
httpBackend.when('GET', '/rooms/'+encodeURIComponent(ROOM_ID)+"/initialSync")
|
||||||
.respond(401, {errcode: 'M_GUEST_ACCESS_FORBIDDEN'});
|
.respond(401, {errcode: 'M_GUEST_ACCESS_FORBIDDEN'});
|
||||||
return httpBackend.flush();
|
|
||||||
|
return q.all([
|
||||||
|
httpBackend.flush('/directory/room/'+encodeURIComponent(ROOM_ALIAS)),
|
||||||
|
httpBackend.flush('/rooms/'+encodeURIComponent(ROOM_ID)+"/initialSync"),
|
||||||
|
]);
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
httpBackend.verifyNoOutstandingExpectation();
|
httpBackend.verifyNoOutstandingExpectation();
|
||||||
|
|
||||||
@ -146,30 +150,20 @@ describe('joining a room', function () {
|
|||||||
roomView = ReactTestUtils.findRenderedComponentWithType(
|
roomView = ReactTestUtils.findRenderedComponentWithType(
|
||||||
matrixChat, RoomView);
|
matrixChat, RoomView);
|
||||||
|
|
||||||
var previewBar = ReactTestUtils.findRenderedComponentWithType(
|
const previewBar = ReactTestUtils.findRenderedComponentWithType(
|
||||||
roomView, RoomPreviewBar);
|
roomView, RoomPreviewBar);
|
||||||
|
|
||||||
var joinLink = ReactTestUtils.findRenderedDOMComponentWithTag(
|
const joinLink = ReactTestUtils.findRenderedDOMComponentWithTag(
|
||||||
previewBar, 'a');
|
previewBar, 'a');
|
||||||
|
|
||||||
ReactTestUtils.Simulate.click(joinLink);
|
ReactTestUtils.Simulate.click(joinLink);
|
||||||
|
|
||||||
// that will fire off a request to check our displayname, followed by a
|
httpBackend.when('POST', '/join/'+encodeURIComponent(ROOM_ID))
|
||||||
// join request
|
|
||||||
httpBackend.when('GET', '/profile/'+encodeURIComponent(USER_ID))
|
|
||||||
.respond(200, {displayname: 'boris'});
|
|
||||||
httpBackend.when('POST', '/join/'+encodeURIComponent(ROOM_ALIAS))
|
|
||||||
.respond(200, {room_id: ROOM_ID});
|
.respond(200, {room_id: ROOM_ID});
|
||||||
return httpBackend.flush();
|
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
// wait for the join request to be made
|
// wait for the join request to be made
|
||||||
return q.delay(1);
|
return q.delay(1);
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
// flush it through
|
|
||||||
return httpBackend.flush();
|
|
||||||
}).then(() => {
|
|
||||||
httpBackend.verifyNoOutstandingExpectation();
|
|
||||||
|
|
||||||
// the roomview should now be loading
|
// the roomview should now be loading
|
||||||
expect(roomView.state.room).toBe(null);
|
expect(roomView.state.room).toBe(null);
|
||||||
expect(roomView.state.joining).toBe(true);
|
expect(roomView.state.joining).toBe(true);
|
||||||
@ -178,6 +172,14 @@ describe('joining a room', function () {
|
|||||||
ReactTestUtils.findRenderedDOMComponentWithClass(
|
ReactTestUtils.findRenderedDOMComponentWithClass(
|
||||||
roomView, "mx_Spinner");
|
roomView, "mx_Spinner");
|
||||||
|
|
||||||
|
// flush it through
|
||||||
|
return httpBackend.flush('/join/'+encodeURIComponent(ROOM_ID));
|
||||||
|
}).then(() => {
|
||||||
|
httpBackend.verifyNoOutstandingExpectation();
|
||||||
|
|
||||||
|
// We've joined, expect this to false
|
||||||
|
expect(roomView.state.joining).toBe(false);
|
||||||
|
|
||||||
// now send the room down the /sync pipe
|
// now send the room down the /sync pipe
|
||||||
httpBackend.when('GET', '/sync').
|
httpBackend.when('GET', '/sync').
|
||||||
respond(200, {
|
respond(200, {
|
||||||
@ -197,7 +199,6 @@ describe('joining a room', function () {
|
|||||||
}).then(() => {
|
}).then(() => {
|
||||||
// now the room should have loaded
|
// now the room should have loaded
|
||||||
expect(roomView.state.room).toExist();
|
expect(roomView.state.room).toExist();
|
||||||
expect(roomView.state.joining).toBe(false);
|
|
||||||
}).done(done, done);
|
}).done(done, done);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -122,7 +122,7 @@ describe('loading:', function () {
|
|||||||
function routeUrl(location, matrixChat) {
|
function routeUrl(location, matrixChat) {
|
||||||
console.log(Date.now() + ` routing URL '${location}'`);
|
console.log(Date.now() + ` routing URL '${location}'`);
|
||||||
const s = getScreenFromLocation(location);
|
const s = getScreenFromLocation(location);
|
||||||
console.log("Showing screen "+ s);
|
console.log("Showing screen ", s);
|
||||||
matrixChat.showScreen(s.screen, s.params);
|
matrixChat.showScreen(s.screen, s.params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -193,14 +193,12 @@ describe('loading:', function () {
|
|||||||
|
|
||||||
return httpBackend.flush();
|
return httpBackend.flush();
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
// Wait for another trip around the event loop for the UI to update
|
// we expect a single <Login> component following session load
|
||||||
return q.delay(1);
|
|
||||||
}).then(() => {
|
|
||||||
// we expect a single <Login> component
|
|
||||||
ReactTestUtils.findRenderedComponentWithType(
|
ReactTestUtils.findRenderedComponentWithType(
|
||||||
matrixChat, sdk.getComponent('structures.login.Login'));
|
matrixChat, sdk.getComponent('structures.login.Login'));
|
||||||
expect(windowLocation.hash).toEqual("");
|
expect(windowLocation.hash).toEqual("");
|
||||||
}).done(done, done);
|
done();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should follow the original link after successful login', function(done) {
|
it('should follow the original link after successful login', function(done) {
|
||||||
|
Loading…
Reference in New Issue
Block a user