Merge pull request #36 from matrix-org/bwindels/checkleavesmemberlist

test leaving members disappear from memberlist
This commit is contained in:
Bruno Windels 2019-04-03 13:30:40 +00:00 committed by GitHub
commit 240c715c84
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 34 additions and 2 deletions

View file

@ -59,6 +59,11 @@ module.exports = class RestMultiSession {
this.log.done();
return new RestMultiRoom(rooms, roomIdOrAlias, this.log);
}
room(roomIdOrAlias) {
const rooms = this.sessions.map(s => s.room(roomIdOrAlias));
return new RestMultiRoom(rooms, roomIdOrAlias, this.log);
}
}
class RestMultiRoom {
@ -82,7 +87,7 @@ class RestMultiRoom {
this.log.step(`leave ${this.roomIdOrAlias}`)
await Promise.all(this.rooms.map(async (r) => {
r.log.mute();
await r.leave(message);
await r.leave();
r.log.unmute();
}));
this.log.done();

View file

@ -24,6 +24,7 @@ module.exports = class RestSession {
this.log = new Logger(credentials.userId);
this._credentials = credentials;
this._displayName = null;
this._rooms = {};
}
userId() {
@ -51,7 +52,18 @@ module.exports = class RestSession {
this.log.step(`joins ${roomIdOrAlias}`);
const {room_id} = await this._post(`/join/${encodeURIComponent(roomIdOrAlias)}`);
this.log.done();
return new RestRoom(this, room_id, this.log);
const room = new RestRoom(this, room_id, this.log);
this._rooms[room_id] = room;
this._rooms[roomIdOrAlias] = room;
return room;
}
room(roomIdOrAlias) {
if (this._rooms.hasOwnProperty(roomIdOrAlias)) {
return this._rooms[roomIdOrAlias];
} else {
throw new Error(`${this._credentials.userId} is not in ${roomIdOrAlias}`);
}
}
async createRoom(name, options) {

View file

@ -40,6 +40,10 @@ module.exports = async function lazyLoadingScenarios(alice, bob, charlies) {
await checkMemberList(alice, charly1to5);
await joinCharliesWhileAliceIsOffline(alice, charly6to10);
await checkMemberList(alice, charly6to10);
await charlies.room(alias).leave();
await delay(1000);
await checkMemberListLacksCharlies(alice, charlies);
await checkMemberListLacksCharlies(bob, charlies);
}
const room = "Lazy Loading Test";
@ -92,6 +96,17 @@ async function checkMemberList(alice, charlies) {
alice.log.done();
}
async function checkMemberListLacksCharlies(session, charlies) {
session.log.step(`checks the memberlist doesn't contain ${charlies.log.username}`);
const displayNames = (await getMembersInMemberlist(session)).map((m) => m.displayName);
charlies.sessions.forEach((charly) => {
assert(!displayNames.includes(charly.displayName()),
`${charly.displayName()} should not be in the member list, ` +
`only have ${displayNames}`);
});
session.log.done();
}
async function joinCharliesWhileAliceIsOffline(alice, charly6to10) {
await alice.setOffline(true);
await delay(1000);